create a free hand curve

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
Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

create a free hand curve

Post by Da_Elf » Wed Jul 20, 2016 8:45 pm

when i create a graphic i want to make sure the graphic is a free hand curve so i can add some points to it. how do i go about doing this?

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: create a free hand curve

Post by Klaus » Wed Jul 20, 2016 8:55 pm

Hi Da_Elf,

you mean by script? This:
...
set the style of the templategraphic to "curve"
## Optional:
## set the points of the templategraphic to list_of_points
create graphic
reset the templategraphic
...
should do the trick.


Best

Klaus

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: create a free hand curve

Post by [-hh] » Wed Jul 20, 2016 9:09 pm

Code: Select all

on mouseUp
  put "poly6" into gn
  if there is no grc gn then create grc gn
  set style of grc gn to "polygon" # <----------
  set points of grc gn to iAmAHexagon()
  set loc of grc gn to 200,200 -- loc is 230,230
end mouseUp

function iAmAHexagon
  return  "230,130" &cr& "317,180" &cr& \
    "317,280" &cr& "230,330" &cr& \
    "143,280" &cr& "143,180" &cr& "230,130"
end iAmAHexagon
Edit. Sorry Klaus, it's now a double answer. Had a phone break while writing.
shiftLock happens

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

Re: create a free hand curve

Post by dunbarx » Wed Jul 20, 2016 10:23 pm

Hi.

Note that early on, only certain vector graphic objects had a "points" property. But now many more (all?) do, with a new property, the "effective points".

Craig Newman

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: create a free hand curve

Post by Da_Elf » Wed Jul 20, 2016 11:29 pm

i just created one and hit it for when i need it. would be good to create by type like
create grc "thisone" by type "free hand curve"

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: create a free hand curve

Post by [-hh] » Wed Jul 20, 2016 11:52 pm

Hi all.
@Da_Elf
"Free hand curve" is presumably not a style rather a description, the style is "polygon".
Your "Create by type" is alike what Klaus said with using the templategraphic. You could also have several "prototypes" and then clone one of these.

@Craig
You can't *set* the effective points (Da_Elf wishes to set points) ...

[Edit. Replaced the incorrect "type" by "style"]
Last edited by [-hh] on Thu Jul 21, 2016 1:42 am, edited 1 time in total.
shiftLock happens

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: create a free hand curve

Post by Da_Elf » Thu Jul 21, 2016 12:30 am

freehand.JPG
freehand is a type

now all i need to do is make an object move along the path

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: create a free hand curve

Post by [-hh] » Thu Jul 21, 2016 1:03 am

That's because you set in the preferences: Property labels are "Description of option".
So you can choose this description as "style" in the property editor.
But try to set this style by script:

Code: Select all

set style of grc 1 to "freehand" -- yields the default, usually a rectangle
Why don't you ask for the style?

Code: Select all

answer the style of grc 1
Instead of "polygon" you may also use "curve" which is a polygon that has no marker properties.

p.s You don't need to create a graphic in order to move an object along points.
You can simply make a list myList of points (x1,y1) & cr & (x2,y2) ... and then

Code: Select all

 move <object> to myList
shiftLock happens


Post Reply