REM Created in CorelPhotoPaint Version 9.439 REM Created On Saturday, February, 12, 2000 by Alex Link REM With special thanks for the insights and improvements from REM Alex Vakulenko. ' spinfill9.csc - a mask rotater script ' The script requires only an active mask but no masks saved to channel. ' The center of the screen is always the center of rotation. ' The center of the mask must be on the right-half of the screen for ' correct operation of the script. ' Use guidelines with rulers on for precision mask placement. ' Use the Channels Docker to access more than 20 masks. WITHOBJECT "CorelPhotoPaint.Automation.9" csw& = .GetDocumentWidth() csh& = .GetDocumentHeight() CONST pi# = 3.1415926536 FUNCTION ATAN2(y#, x#) ' Thank you for this gem, Alex IF x=0 THEN ATAN2=SGN(y)*pi/2 ELSE ATAN2=ATAN(y/x) - (x<0)*pi END IF END FUNCTION .MaskChannelAdd "m1" Msg$ = "Enter the number of rotation steps desired: " & CHR(13) & \\ "Even dividers of 360 work best for large numbers," & CHR(13) & \\ "for example 90 plots fine, 50 does not." uix$ = INPUTBOX(Msg$) n = VAL(uix$) IF n = 0 THEN n = 12 xstep& = 360/n For I = 1 TO n-1 STEP 1 xrot& = I*xstep& ' angle of rotation in degrees rot = ANGLECONVERT(1,2,xrot&) ' angle of rotation in radians cx& = csw&/2 ' default center of rotation cy& = csh&/2 .GetMaskRectangle l&, t&, r&, b& r&=r&+1 ' mask size correction factor b&=b&+1 ' mask size correction factor w# = r&-l& ' width of mask h# = b&-t& ' height of mask da# = ATAN2(h,w) ' diagonal angle of corner 2 Ra# = SQR(w*w + h*h)/2 ' radius size to corner positions of bounding box ' find center of mask ocx&= (l&+r&)/2 ocy&= (t&+b&)/2 ' calculate rotation of offset (if any) ox# = ocx-cx ' x-offset oy# = cy-ocy ' y-offset (with -y) oa# = ATAN2(oy,ox) ' angle of offset ro# = SQR(ox*ox+oy*oy) ' length of offset radius ' calculate final rotated offset fox& = ro*cos(oa+rot) foy& = -ro*sin(oa+rot) ' (with -y) ' new corner positions converted to -y space ' new corner positions translated to screen center (200, 200) ' new corner positions translated for rotated offset x1& = cx-Ra*cos(da-rot)+fox y1& = cy-Ra*sin(da-rot)+foy x2& = cx+Ra*cos(da+rot)+fox y2& = cy-Ra*sin(da+rot)+foy x3& = cx+Ra*cos(da-rot)+fox y3& = cy+Ra*sin(da-rot)+foy x4& = cx-Ra*cos(da+rot)+fox y4& = cy+Ra*sin(da+rot)+foy .MaskDistort x1&, y1&, x2&, y2&, x3&, y3&, x4&, y4&, TRUE ' plot it .MaskChannelAdd "m" & STR(I+1) .MaskChannelToMask 0, 0 Next I ' ............................................................ ' Create transparent overlay view FOR J = 0 TO n-1 .MaskChannelToMask J, 0 ' >>>>>>> edit here: .EditFill 4, 90, 100, 1, 0, 0, csh&-1, 0, csh&-1, 0, csh&-1 ' fill merge mode, transparency .FillSolid 5, 0, 0, 0, 0 'and here for color .EndEditFill NEXT J ' Create a shape mask FOR K = 0 TO n-1 .MaskChannelToMask K, 1 NEXT K .MaskChannelAdd "shape" END WITHOBJECT