home *** CD-ROM | disk | FTP | other *** search
- /***************************************************************************
- P>G Pro Script
-
- Prompt the user for rotation parameters, then do it!
-
- Copyright 1997 by TrueSpectra Inc.
-
- This code is provided purely for demonstration purposes and is not
- supported or under warranty. Feel free to modify and examine this
- example script for your own purposes.
-
- */
-
- /* what is selected? */
- original_object = CwGetSelectedObject()
-
- /* nothing selected? Continue */
- if \CwIsHandleValid(original_object) then
- do
- say "You MUST select an object before running this script!"
- Signal DONE
- end
-
- /* get it's current angle from the original_position. stem */
- call CwGetPosition original_object, original_position
-
- startangle = original_position.Rotation
-
- /* Prompt user for Total Degrees Rotation & size of each step */
- call prompt
-
- /* now wait form them to press the green button */
- call wait
-
-
- finalangle = startangle + totaldegrees
- count = 0
- newangle = 0
- Do until newangle >= finalangle
- count = count + 1
-
- /* duplicate the object */
- newobject = CwDuplicateObject(original_object)
-
- /* calculate the new angle */
- newangle = startangle + (step * count)
-
- /* rotate the new object */
- call CwSetPosition newobject,,
- original_position.x,,
- original_position.y,,
- original_position.width,,
- original_position.height,,
- newangle,,
- original_position.XShear
-
- end
-
- DONE:
-
- Exit
-
- /* Routine to display the prompt information */
- Prompt:
-
- /* Stop drawing until we've setup the display */
- Window=CwGetCurrentView()
- call CwStopRender window
-
- /* find out the area we have to draw in */
- ah=CwGetAppHandle('output settings')
- maxwidth=CwGetProperty(ah, 'output size:width')
- maxheight=CwGetProperty(ah, 'output size:height')
-
- /* Drop a white box over everything so we can see our prompts */
- boxeffect = CwCreateEffect('Rectangle', 'Solid Color')
- call CwSetPosition boxeffect, maxwidth/2, maxheight/2, maxwidth, maxheight, 0,0
- call CWSetName boxeffect, "_TS_BOX"
-
- whitebox = CwGetTool(boxeffect)
- call CWSetProperty whitebox, "Color", "(255,255,255)"
-
- /* show the prompts */
- text1effect = CwCreateEffect('Headline Text', 'Solid Color')
- call CwSetPosition text1effect, maxwidth/4, maxheight-maxheight/12, maxwidth/2, maxheight/6, 0, 0
- call CWSetName text1effect, "_TS_TEXT1"
-
- textobj = CwGetRegion(text1effect)
- call CWSetProperty textobj, "Caption", "TOTAL ROTATION"
- textobj = CwGetTool(text1effect)
- call CWSetProperty textobj, "Color", "(0,0,0)"
-
- /* show the prompts */
- text2effect = CwCreateEffect('Headline Text', 'Solid Color')
- call CwSetPosition text2effect, maxwidth-maxwidth/6, maxheight-maxheight/12, maxwidth/3, maxheight/6, 0, 0
- call CWSetName text2effect, "_TS_TEXT2"
-
- textobj = CwGetRegion(text2effect)
- call CWSetProperty textobj, "Caption", "EACH STEP IS:"
- textobj = CwGetTool(text2effect)
- call CWSetProperty textobj, "Color", "(0,0,0)"
-
- /* show the prompts */
- degreeseffect = CwCreateEffect('Headline Text', 'Solid Color')
- call CwSetPosition degreeseffect, maxwidth/6, maxheight/1.3, maxwidth/3, maxheight/4, 0, 0
- call CWSetName degreeseffect, "_TS_ITEM1"
-
- o = CwGetRegion(degreeseffect)
- call CWSetProperty o, "Caption", "90"
- o = CwGetTool(degreeseffect)
- call CWSetProperty o, "Color", "(255,0,0)"
-
- /* show the prompts */
- stepeffect = CwCreateEffect('Headline Text', 'Solid Color')
- call CwSetPosition stepeffect, maxwidth-maxwidth/6, maxheight/1.3, maxwidth/3, maxheight/4, 0, 0
- call CWSetName stepeffect, "_TS_ITEM2"
-
- o = CwGetRegion(stepeffect)
- call CWSetProperty o, "Caption", "5"
- o = CwGetTool(stepeffect)
- call CWSetProperty o, "Color", "(255,0,0)"
-
- /* show the prompts */
- blockeffect = CwCreateEffect('Block Text', 'Solid Color')
- call CwSetPosition blockeffect, maxwidth/2, maxheight/2, maxwidth/1.5, maxheight/3, 0, 0
- call CWSetName blockeffect, "_TS_TEXT3"
-
- o = CwGetRegion(blockeffect)
- call CWSetProperty o, "Caption", "Change the RED numbers above then select Green Button"
- o = CwGetTool(blockeffect)
- call CWSetProperty o, "Color", "(0,0,0)"
-
- /* show the prompts */
- btneffect = CwCreateEffect('Ellipse', 'Solid Color')
- call CwSetPosition btneffect, maxwidth/2, maxheight/6, maxwidth/4, maxheight/3, 0, 0
- call CWSetName btneffect, "_TS_BUTTON"
-
- o = CwGetTool(btneffect)
- call CWSetProperty o, "Color", "(0,255,0)"
-
- /* Now render the screen for the user */
- call CwStartRender window
-
-
-
- return
-
- /* Routine to wait until the green button is pressed */
- WAIT:
-
- /* Begin loop to wait for "green button" selection */
- if RxFuncQuery('SysLoadFuncs') then
- do
- call RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'
- call SysLoadFuncs
- end
-
- do forever
- /* sleep */
- rc = SysSleep 5
-
- /* see what (if anything) is selected */
- obj = CWGetSelectedObject()
-
- /* nothing selected? Continue */
- if \CwIsHandleValid(obj) then ITERATE
-
- /* Something selected. What is it? */
- name = CWGetName(obj)
-
- /* if it is the button then go on */
- If name = "_TS_BUTTON" then
- do
- o = CwGetRegion(degreeseffect)
- TotalDegrees = CWGetProperty(o,"Caption")
- o = CwGetRegion(stepeffect)
- Step = CWGetProperty(o,"Caption")
- say "Rotating: "totaldegrees "Step by: "step
- LEAVE
- end
- end
-
- /* delete all the "prompting" stuff before continuing */
- rc = CwDeleteObject(blockeffect)
- rc = CwDeleteObject(boxeffect)
- rc = CwDeleteObject(btneffect)
- rc = CwDeleteObject(stepeffect)
- rc = CwDeleteObject(degreeseffect)
- rc = CwDeleteObject(text1effect)
- rc = CwDeleteObject(text2effect)
-
- return
-