Changing graphic Type

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
DavJans
Posts: 275
Joined: Thu Dec 12, 2013 4:21 pm

Changing graphic Type

Post by DavJans » Thu Apr 28, 2016 10:29 pm

I'm sure this is child's play to most of you.

I can make a graphic with script easily enough but it makes a rectangle

Create graphic "L1"

I looked up changing properties..

set the <property> of <object> to <value>

so in my mind...

set the Type of "L1" to Line

but my mind is wrong :(
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här

Opaquer
Posts: 247
Joined: Wed Aug 14, 2013 8:24 am

Re: Changing graphic Type

Post by Opaquer » Fri Apr 29, 2016 3:28 am

Hey DavJans!

So, I'm still a beginner, so I could be wrong, but I think I've got an idea :P

Your mind is right, just the wording isn't quite right - instead of set the Type of "L1", try using style, like this:

Code: Select all

set the style of graphic "L1" to "line"
Keep in mind that for a line, you need to have points so that it knows where to draw the line, so if you try that code and it disappears, you just need to add points, and you can do that by using the "points" property:

Code: Select all

set the points of graphic "L1" to "200,300"&cr&"180,72"
You need to have at least 2 points to make a line (I'm not sure if you can go with 3, I've never tested it :P), and you need to have each point on a new line, hence the use of cr :)

Hopefully this helps you out :)

Edit: I just tested it out, and you can have more than 2 points for a line graphic, as long as you've got each point on a new line :)!

DavJans
Posts: 275
Joined: Thu Dec 12, 2013 4:21 pm

Re: Changing graphic Type

Post by DavJans » Fri Apr 29, 2016 4:38 pm

Thank you, I'll try it out, You can have as many points as you want, I have a line graph already made that works, but I had to create each line manually before I could set the point in it. I just couldn't figure out how to create the line in the first place using code.
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

Re: Changing graphic Type

Post by dunbarx » Fri Apr 29, 2016 6:09 pm

A line can indeed have more than two points, and it will still be a line, though one might think it looks just like a polyLine.

Also, check out the "create" command to make new controls. And then play around with the "templateGraphic"

Craig Newman

Post Reply