Draw from commands

Visuals, audio, animation. Blended, not stirred. If LiveCode is part of your rich media production toolbox, this is the forum for you.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Ron Zellner
Posts: 106
Joined: Wed May 31, 2006 9:56 pm
Location: College Station, Texas
Contact:

Draw from commands

Post by Ron Zellner » Tue Nov 17, 2009 9:00 pm

Is there a good way to draw on the screen using commands? like control the brush or pencil with a move command, or create a series of of line segments with the create command?
Is there a sample somewhere?

Ron

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9867
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Post by FourthWorld » Tue Nov 17, 2009 9:12 pm

See the choose command and the drag command.

But if what you want are the resulting graphics, you can get much faster results with less code using the create command.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Ron Zellner
Posts: 106
Joined: Wed May 31, 2006 9:56 pm
Location: College Station, Texas
Contact:

Drag works well

Post by Ron Zellner » Wed Nov 18, 2009 3:56 am

The drag works well- with some clever math it can be used to create the desired graphics.
I had tried creating graphics (Lines) and controlling their size and direction by setting the points. The math to calculate the points is about the same as the drag from-to math. I couldn't find a way to rotate them- seems like only images can be rotated, and then it is the content that rotates.

We are hoping to create a stack that lets the user create objects by specifying the sequence of draw, turn-right, draw, turn-left, etc. movements.

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Drag works well

Post by sturgis » Wed Nov 18, 2009 6:10 pm

Oh cool. You're writing logo! Loved playing with that.

If you want the user to be able to do this step by step and see the results on screen I think you can do it by setting the points of a polygon.

First point is the start location. If they put in "move forward 10" calculate the 2nd point, add it to the list and set the points of your polygon to that list. The only things you'd need to track are your current orientation so you know which way is forward, and the current list of points. Any time a new "forward" command is entered, calculate the new point based on distance and angle tack the new point on to the end of the points list and set the poly to that list.
Ron Zellner wrote:The drag works well- with some clever math it can be used to create the desired graphics.
I had tried creating graphics (Lines) and controlling their size and direction by setting the points. The math to calculate the points is about the same as the drag from-to math. I couldn't find a way to rotate them- seems like only images can be rotated, and then it is the content that rotates.

We are hoping to create a stack that lets the user create objects by specifying the sequence of draw, turn-right, draw, turn-left, etc. movements.

Post Reply

Return to “Multimedia”