Bezier curves

Jim Hurley jhurley at infostations.com
Sun May 2 16:55:38 EDT 2004


>
>Message: 9
>Date: Sat, 1 May 2004 21:26:26 -0700 (PDT)
>From: Alejandro Tejada <capellan2000 at yahoo.com>
>Subject: Re: Bezier curves
>To: use-revolution at lists.runrev.com
>Message-ID: <20040502042626.88269.qmail at web40504.mail.yahoo.com>
>Content-Type: text/plain; charset=us-ascii
>
>on Sat, 1 May 2004
>Jim Hurley wrote:
>
>[snip]
>>  If you have need of bezier lines you will find this
>>  plug-in at:
>>
>>  http://home.infostations.net/jhurley/
>>
>>  and look for Bezier Line under Utilities.
>
>Excellent!!!
>Thanks a lot for sharing this work, Jim.
>
>It could be enlightening that you explain
>to the list how did work the code of this grouped
>object.

Al,

I didn't protect the stack. But I can't say that the code is self 
explanatory. I'm terrible at commenting my scripts.

It is mostly a matter of sending messages to the adjacent line and 
tangent controls as well as to the bezier line. The tangent controls 
set the values of r2 and r3 as custom properties of the bezier 
graphic line. There are a lot a little details I ran into in getting 
this to work properly, particularly in forcing the slopes of the two 
adjacent tangent controls to be equal (when operating in the 
continuous tangent mode).

In the dragging of the entire bezer line, it is necessary to get the 
loc of all the groups and the displacement between the current mouse 
loc and the group locs. In this way all the groups move together with 
the mouse.

The code for drawing the bezier line is stored in the line itself and 
is pretty straight forward; it is similar to yours:

on DrawBezierLine
   --The four control vectors are r1, r2, r3, and r4. They are custom 
properties of the bezier grc.
   put the r1 of me into pt1
   put the r2 of me into pt2
   put the r3 of me into pt3
   put the r4 of me into pt4
   repeat with i = 0 to 50 -- 0 to 50 is probably sufficient
     put i/50 into t
     put 1-t into s
     repeat with j = 1 to 2
       put round(s*s*s*item j of pt1 + 3*s*s*t*item j of pt2 + \
           3*s*t*t*item j of pt3 + t*t*t*item j of pt4) into item j of thePt
     end repeat
     put thePt & return after tPoints
   end repeat
--"The owner of me" is the group that the bezier line belongs to.
--There are as many bezier line segments as there are line controls, 
each line in its own group
   set the points of grc "BezierLine" of the owner of me to tPoints
end DrawBezierLine


>The size of the uncompressed stack is huge!... Why?

Yes, that bothered me as well. But most of the size is in the help 
substack. As you will see in that substack, you can reduce the size 
of the potential plug-in by deleting or decoupling the help stack. In 
this way, the size of the bezier plug-in itself is reduced to 116K. I 
think you may enjoy the discussion of the math in that stack.

>
>Does this works in MetaCard too or contains Rev
>specific code? Could I link from my website to your
>page?


I can't say if it would work in MC. Probably. I don't think there is 
any RR specific code.

Yes, by all means link us up.

>
>Thanks in advance!
>
>al


More information about the use-livecode mailing list