Automated Drawing

Mike Bonner bonnmike at gmail.com
Sat Mar 21 14:12:36 EDT 2015


Here:

function getLineByLen pX,pY,pLen,pAngle
   put pi * pAngle / 180 into tRadians -- sin and cos require radians, so
convert from degrees
   put pX + pLen * cos(tRadians) into pX2 -- get the end x point
   put pY + pLen * sin(tRadians) into pY2 -- get the end y point
   return px2,py2 -- return the end coords
end getLineByLen

Just hand it the starting points for x and y, give it a length and angle
and it will return the x,y for the end point for that length of line.
Since partial pixel positioning works now, you don't necessarily have to
worry about rounding or truncating either.

On Sat, Mar 21, 2015 at 10:17 AM, Jim Hurley <jhurley0305 at sbcglobal.net>
wrote:

> Richmond,
>
> I wrote this Turtle Graphics library in the dark ages of RR, before “sum”
> became a reserved word.
>
> So, comment out the “sum” handler in the stack script.
>
> Jim
> >> Automated Drawing
> >>
> >> Richmond richmondmathewson at gmail.com  <mailto:
> use-livecode%40lists.runrev.com
> ?Subject=Re%3A%20Automated%20Drawing&In-Reply-To=%3C550D8A50.20300%
> 40gmail.com%3E>
> >> Sat Mar 21 16:12:16 CET 2015
> >>
> >> Previous message: Automated Drawing <
> http://lists.runrev.com/pipermail/use-livecode/2015-March/212900.html>
> >> Next message: Automated Drawing <
> http://lists.runrev.com/pipermail/use-livecode/2015-March/212902.html>
> >> Messages sorted by: [ date ] <
> http://lists.runrev.com/pipermail/use-livecode/2015-March/date.html#212901>
> [ thread ] <
> http://lists.runrev.com/pipermail/use-livecode/2015-March/thread.html#212901>
> [ subject ] <
> http://lists.runrev.com/pipermail/use-livecode/2015-March/subject.html#212901>
> [ author ] <
> http://lists.runrev.com/pipermail/use-livecode/2015-March/author.html#212901
> >
> > On 21/03/15 17:09, Richmond wrote:
> > > On 21/03/15 13:57, Jim Hurley wrote:
> > >>> Message: 21
> > >>> Date: Sat, 21 Mar 2015 09:02:23 +0200
> > >>> From: Richmond <richmondmathewson at gmail.com <
> http://lists.runrev.com/mailman/listinfo/use-livecode>
> > >>> <mailto:richmondmathewson at gmail.com <
> http://lists.runrev.com/mailman/listinfo/use-livecode>>>
> > >>> To: How to use LiveCode <use-livecode at lists.runrev.com <
> http://lists.runrev.com/mailman/listinfo/use-livecode>
> > >>> <mailto:use-livecode at lists.runrev.com <
> http://lists.runrev.com/mailman/listinfo/use-livecode>>>
> > >>> Subject: Automated Drawing
> > >>> Message-ID: <550D177F.10609 at gmail.com <
> http://lists.runrev.com/mailman/listinfo/use-livecode>
> > >>> <mailto:550D177F.10609 at gmail.com <
> http://lists.runrev.com/mailman/listinfo/use-livecode>>>
> > >>> Content-Type: text/plain; charset=utf-8; format=flowed
> > >>>
> > >>> I set up a little stack with THIS in a button:
> > >>>
> > >>> on mouseUp
> > >>>    choose pencil tool
> > >>>    drag from 100,100 to 200,200
> > >>> end mouseUp
> > >>>
> > >>> and it drew me a jolly diagonal line . . . super!
> > >>>
> > >>> HOWEVER
> > >>>
> > >>> I wonder if it is possible to do something like THIS:
> > >>>
> > >>> drag for 100 pixels at 60 degrees
> > >>>
> > >>> probably not, BUT ??????
> > >>>
> > >>> Richmond.
> > >>>
> > >>
> > >> Of course:
> > >>
> > >> on mouseUp
> > >>     startTurtle
> > >>     setHeading 60
> > >>     forward 100
> > >> end mouseUp
> > >>
> > >>
> > >
> > > You have in a matter of seconds made me feel totally stupid as my
> > > whole question is geared
> > > towards an interface I am designing to control a USB-tethered turtle.
> > >
> > > Thank you for the great help.
> > >
> > > Richmond.
> >
> > Possibly NOT as stupid as all that:
> >
> > "button "Button": execution error at line 2 (Handler: can't find
> > handler) near "startTurtle", char 1"
> >
> > Richmond.
>
> You need the Turtle Graphics library:
> http://jamesphurley.com/Revolution.html <
> http://jamesphurley.com/Revolution.html>
>
> Jim
>
> Previous message: Automated Drawing <
> http://lists.runrev.com/pipermail/use-livecode/2015-March/212900.html>
> Next message: Automated Drawing <
> http://lists.runrev.com/pipermail/use-livecode/2015-March/212902.html>
> Messages sorted by: [ date ] <
> http://lists.runrev.com/pipermail/use-livecode/2015-March/date.html#212901>
> [ thread ] <
> http://lists.runrev.com/pipermail/use-livecode/2015-March/thread.html#212901>
> [ subject ] <
> http://lists.runrev.com/pipermail/use-livecode/2015-March/subject.html#212901>
> [ author ] <
> http://lists.runrev.com/pipermail/use-livecode/2015-March/author.html#212901
> >
> More information about the use-livecode mailing list <
> http://lists.runrev.com/mailman/listinfo/use-livecode>
>
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



More information about the use-livecode mailing list