Porting Postscript code to TRANSCRIPT (Bezier curve)

Jean-Jacques Wagner diwag at pingnet.ch
Sat Jan 17 05:41:17 EST 2004


Hi,
Here you get a small samples of Bezier curve made in hypertalk. It is self
explanotary and work quite well, depend about what you want to do.

JJW



on mouseUp
  put the first item of the loc of btn startpoint into x1
  put the first item of the loc of btn endpoint into x2
  put the first item of the loc of btn control1 into xa
  put the first item of the loc of btn control2 into xb
  put the second item of the loc of btn startpoint into y1
  put the second item of the loc of btn endpoint into y2
  put the second item of the loc of btn control1 into ya
  put the second item of the loc of btn control2 into yb
  put 0 into v1
  if the hilite of cd btn "Multiple" = false then cleanUpPicture
  put cd fld bezierResolution into zdt
  Repeat with i = 1 TO zdt
    put i * 1/zdt into v1
    put 1 - v1 into v2
    put (x1 * (v2 * v2 * v2) + (3 * xa * v1 * v2 * v2) + (3 * xb * v1 * v1 *
v2) + (x2 * (v1 ^ 3))) into x
    put (y1 * (v2 * v2 * v2) + (3 * ya * v1 * v2 * v2) + (3 * yb * v1 * v1 *
v2) + (y2 * (v1 ^ 3))) into y
    put x div 1 & "," & y div 1 & return after variablezxc
  end repeat
  put the loc of btn "startpoint" & return before variablezxc
  choose tool "9"
  repeat with i = 1 to the number of lines of variablezxc -1
    put line 1 of variablezxc into cde
    put line 2 of variablezxc into cda
    drag from cde to cda
    delete line 1 of variablezxc
  end repeat
  if the hilite of cd btn "No" = false
  then
    if the hilite of cd btn "Box" = true
    then
      drag from the loc of btn "startpoint" to the loc of btn "control1"
      drag from the loc of btn "control1" to the loc of btn "control2"
      drag from the loc of btn "control2" to the loc of btn "endpoint"
      drag from the loc of btn "endpoint" to the loc of btn "startpoint"
    else -- if the hilite of cd btn "Line" is true
      drag from the loc of btn "startpoint" to the loc of btn "control1"
      drag from the loc of btn "control2" to the loc of btn "endpoint"
    end if
  end if
  choose tool 1
end mouseUp

on cleanUpPicture
  choose tool 4 -- selection tool
  drag from the topleft of this card to the bottomright of this card
  if menuitem 6 of menu "edit" = "Clear Picture" then domenu "Clear Picture"
end cleanUpPicture


on mouseenter
  set the visible of cd fld "BezierText" to not the visible of cd fld
"BezierText"
end mouseenter


> Hi Developers,
> 
> In the web, finally found a code that
> could fit a bezier curve in a set of
> points.
> 
> But, this code was made in Postscript.
> 
> If you understand Postscript,
> 
> Could you explain me how did works this code?
> 
> http://www.tinaja.com/text/fuzzybez.html
> http://www.tinaja.com/glib/bez4pts.pdf
> 
> Thanks in advance.
> 
> al
> 
> =====
> Visit my site:
> http://www.geocities.com/capellan2000/
> Search the mail list:
> http://mindlube.com/cgi-bin/search-use-rev.cgi
> 
> __________________________________
> Do you Yahoo!?
> Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
> http://hotjobs.sweepstakes.yahoo.com/signingbonus
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution



More information about the use-livecode mailing list