REM Created in CorelPhotoPaint Version 9.397 REM Created On December 7, 1999 by linkaxdx REM Spiral Toy ' spirotoy.csc WITHOBJECT "CorelPhotoPaint.Automation.9" .SetDocumentInfo 1200, 1200 ' 4 x 4 inch at 300 dpi cx& = 600 cy& = 600 GLOBAL CONST pi AS DOUBLE = 3.1415926535 BEGIN DIALOG Dialog1 20, 20, 240, 200, " SPIROGRAPH TOY" TEXT 40, 6, 200, 14, "<== Resolution of curve (10)" TEXTBOX 6, 6, 30, 14, RS$ TEXT 40, 26, 200, 14, "<== Thickness of bounding line (2)" TEXTBOX 6, 26, 30, 14, TK$ TEXT 40, 46, 200, 14, "<== Number of spokes (6)" TEXTBOX 6, 46, 30, 14, SD$ TEXT 40, 66, 200, 14, "<== Size of design (30)" TEXTBOX 6, 66, 30, 14, SZ$ TEXT 6, 106, 220, 80, \\ "Entering a larger number in the top cell makes a smoother spiral" & CHR(13) & \\ "curve. Larger numbers take longer to calculate. Use numbers > 2." & CHR(13) & \\ "The thickness of the bounding line must be at least 1." & CHR(13) & \\ "Try entering 1 in the number of spokes to see the design element." & CHR(13) & \\ "Keep the design size under a hundred to fit on page." & CHR(13) & \\ "If no number is entered, then the (default) values apply." & CHR(13) & \\ "TAB past any cell to use default, ENTER to draw design. ENJOY!" END DIALOG DIALOG Dialog1 IF RS$ = "" THEN pq& = 10 ELSE pq& = VAL(RS$) ENDIF IF TK$ = "" THEN ptk& = 2 ELSE ptk& = VAL(TK$) ENDIF IF SD$ = "" THEN s = 6 ELSE s = VAL(SD$) ENDIF IF SZ$ = "" THEN pSZ& = 30 ELSE pSZ& = VAL(SZ$) ENDIF ' check for bad input IF pq& < 3 OR ptk& < 1 OR s = 0 OR pSZ& < 10 THEN Message "DATA ERROR, please try again." STOP ENDIF ' .............................................................. ' call sub with x,y of center, radian angle of rotation, size, resolution ' of curve and thickness of bounding line SUB nSpiro (ByVal pRX&, ByVal pRY&, ByVal pT, ByVal pRR&, ByVal q, ByVal xtk&) ' q = ? "resolution" of spiral, higher number--smoother curve DIM xA(q+1) AS DOUBLE DIM yA(q+1) AS DOUBLE DIM x2A(q+1) AS DOUBLE DIM y2A(q+1) AS DOUBLE xr = 0 n = 0 FOR K = 0 TO q n = n+1 xr = K*2*pi/q xA(n) = 256*pRX& + 256*pRR&*cos(xr+pT)*xr yA(n) = 256*pRY& + 256*pRR&*sin(xr+pT)*xr x2A(n) = 256*pRX& + 256*pRR&*cos(-xr+pT)*xr y2A(n) = 256*pRY& + 256*pRR&*sin(-xr+pT)*xr NEXT K .PolygonTool xtk&, 0, 0, 3, TRUE, FALSE, TRUE .SetPaintColor 5, 0, 0, 255, 0 .FillSolid 5, 255, 0, 0, 0 .StartDraw xA(1), yA(1), 0, 0, 0, 0 For z = 2 TO q+1 .ContinueDraw xA(z), yA(z), 0, 0, 0, 0 Next z .EndDraw .StartDraw x2A(1), y2A(1), 0, 0, 0, 0 For z = 2 TO q+1 .ContinueDraw x2A(z), y2A(z), 0, 0, 0, 0 Next z .EndDraw END SUB ' .............................................. .ImageInvert .EndColorEffect FOR I = 0 TO (2*s - 2)*pi/s STEP 2*pi/s nSpiro cx&, cy&, I, pSZ&, pq&, ptk& NEXT I END WITHOBJECT