How to make a square topped, round rect bottomed graphic?
Bob Sneidar
bobs at twft.com
Thu Dec 2 15:30:00 CST 2010
Okay who posted Fortran on a LiveCode Use List??
Bob
On Dec 2, 2010, at 1:13 PM, Mick Collins wrote:
> on doTest
> -- before running this test, create a polygon graphic named "NW"
> put 250 into theLeft
> put 250 into theTop
> repeat with i = 1 to 37
> put 6*i - 5 into theWid
> put pi * (i-1)/18 into angRot
> repeat with j = 1 to 80
> put 2*j into theHeight
> -- this is how you use the function
> set the points of grc "NW" to \
> pointsOfNorman(theLeft,theTop,theWid,theHeight,angRot)
>
> wait 0
> end repeat
> end repeat
>
> end doTest
>
> function pointsOfNorman L,T,wid,hite,rotAng
> --creates the points for a NormanWindow graphic (polygon)
> --"left", "top" (actually starting point), width, height, angle Of rotation
> -- (measured clockwise from rightward)
> -- use 0*pi for semicircle down
> -- use 0.5*pi for semicircle left
> -- use 1*pi for semicircle up
> -- use 1.5*pi for semicircle right
> -- use 2*pi for semicircle down
> -- (interpolate for a rotation other than these)
>
>
> -- first 3 points of rectangle
> put L,T into daPoints
> put round(L+wid*cos(rotAng)),round(T+wid*sin(rotAng)) into line 2 of daPoints
> put round(L+wid*cos(rotAng)-hite*sin(rotAng)),round(T+wid*sin(rotAng)+hite*cos(rotAng)) into line 3 of daPoints
>
> -- center of semiCircle
> put round(L+.5*wid*cos(rotAng)-hite*sin(rotAng)) into xCen
> put round(T+.5*wid*sin(rotAng)+hite*cos(rotAng)) into yCen
>
> put max(8, wid div 3) into numOfAngs -- number of straight lines to make semiCircle
> put wid / 2 into theRadius
>
> put 3 into lineNum
> put pi / numOfAngs into deltaAng
> repeat with i = 1 to numOfAngs
> -- calculates the coordinates for the i-th point of the semicircle
> put deltaAng * i into theAng
> add rotAng to theAng
> put xCen +theRadius*cos(theAng) into theX
> put yCen +theRadius*sin(theAng) into theY
> add 1 to lineNum
> put round(theX),round(theY) into line lineNum of daPoints
> end repeat
>
> -- and go back to the starting point
> add 1 to lineNum
> put L,T into line lineNum of daPoints
>
> return daPoints
> end pointsOfNorman
More information about the use-livecode
mailing list