home *** CD-ROM | disk | FTP | other *** search
- /* Automatic brush drop shadow creator for OpalPaint.
- AREXX script by Greg Niles, Centaur Development.
-
- Version 1.0 - Initial release!
- Version 1.1 - now deletes the spare page when it's done...
- Version 2.0 - automatically configures to OpalPaint 2.3's new AREXX
- requesters!
- - Added feather out capability -- much better for handling
- thinner brushes, such as text brushes in narrow fonts
- (Times or similar), although slower to calculate than the
- normal method.
- - Deleting the temporary spare page is now an option, just
- in case you want to recover the old brush.
- - Cleaned a few things up, also added a little error checking...
- - Instruction window, plus online help button (!?)
- - Noticably faster than before, due to new AREXX commands for
- alpha channel control...
- */
-
- address 'OpalPaint_Rexx'
-
- options Results
-
- SaveSetUp
-
- call TestVersion
- if VersionNum > 2.2 then
- call OptionsRequester
- else
- call StandardIO
- endif
- call ComputeShadow
-
- Okay "We're done! Paste your new brush anywhere you want!"
-
- RestoreSetUp
- ColorSource Multicolor
- EXIT
-
-
- TestVersion:
- Version
- VersionNum = substr(Result,17,3)
- Return
-
-
- OptionsRequester:
- ActiveBrush
- BrushBay = Result
-
- if BrushBay=-1 then BrushBay=1
-
- ReqBuild '450 238 "Drop Shadow Maker v2.0"'
-
- /* Brush exclusive gadgets */
- AddGadget 'Toggle Brush1 30 67 Small "B1"'
- AddGadget 'Toggle Brush2 Right Brush1 10 0 Small "B2"'
- AddGadget 'Toggle Brush3 Right Brush2 10 0 Small "B3"'
- AddText 'Above Brush2 -22 -3 "Brush Number"'
- MutualEx Brush1 Brush2 Brush3
- InitGadget 'Brush'BrushBay' Selected'
-
- /* Feathering amount gadgets */
- AddGadget 'HProp Feather1 Below Brush1 5 26 45 20 0 20 1'
- AddGadget 'Toggle FeatherIn Right Feather1 35 0 40 20 "IN"'
- AddGadget 'Toggle FeatherOut Right FeatherIn 5 0 40 20 "OUT"'
- AddText 'Above Feather1 13 -3 "Feathering Amount"'
- MutualEx FeatherIn FeatherOut
- InitGadget Feather1 0
- InitGadget 'FeatherIn Selected'
-
- /* Transparency prop gadgets */
- AddGadget 'HProp Trans1 Below Feather1 0 25 130 16 0 100 1 Percent'
- AddText 'Above Trans1 15 -3 "Transparency"'
- InitGadget 'Trans1 50'
-
- /* Spare page delete toggle gadget */
- AddGadget 'Toggle TempPage1 Below Trans1 CenterX 20 Large "Delete temp page"'
- InitGadget 'TempPage1 Selected'
-
- /* Help gadget */
- AddGadget 'Button HelpGad 402 30 20 20 "?"'
-
- /* Bevel boxes & headers */
- AddBox 'Above Brush1 -10 -40 194 167'
- AddHeading 'Above Brush2 -34 -24 "Shadow Options"'
-
- AddBox 'Right Brush3 30 -41 194 167'
- AddHeading 'Above Brush3 130 -24 "INSTRUCTIONS"'
-
- AddText 'Right Brush3 35 -5 "-----------------------"'
- AddText 'Right Brush3 35 5 "Selects the brush to"'
- AddText 'Right Brush3 35 15 "apply the shadow to."'
-
- AddText 'Right Brush3 35 40 "-----------------------"'
- AddText 'Right Brush3 35 50 "The ''fuzziness'' of the"'
- AddText 'Right Brush3 35 60 "shadow, inwards or out."'
- AddText 'Right Brush3 35 70 "0 = sharp, max = 20"'
-
- AddText 'Right Brush3 35 88 "-----------------------"'
- AddText 'Right Brush3 35 98 "Selects the level of"'
- AddText 'Right Brush3 35 108 "shadow transparency."'
-
- Request
-
- GadgetStatus Cancel
- if Result=1 Then do
- Exit
- END
-
- /* go to online help screen */
- GadgetStatus HelpGad
- if Result=1 then do
- call Help
- call OptionsRequester
- Return
- END
-
- /* get which brush was selected */
- GadgetStatus Brush1
- if Result=1 then BrushBay=1
-
- GadgetStatus Brush2
- if Result=1 then BrushBay=2
-
- GadgetStatus Brush3
- if Result=1 then BrushBay=3
-
- /* See if the selected brush is empty */
- ActiveBrush BrushBay
- BrushSize
- parse var result CheckWidth CheckHeight
- if CheckWidth = -1 then do
- Okay "Brush "BrushBay" is empty! Please select another brush."
- call OptionsRequester
- Return
- end
-
- /* get the feather amount */
- GadgetStatus Feather1
- FeatherAmt = Result
-
- /* get the feather type */
- GadgetStatus FeatherIn
- if Result=1 then FeatherType = IN
-
- GadgetStatus FeatherOut
- if Result=1 then FeatherType = OUT
-
- /* get the transparency amount */
- GadgetStatus Trans1
- TransAmt = Result
-
- /* find whether to delete the temp page or not */
- GadgetStatus TempPage1
- KillTempPage = Result
- Return
-
-
- ComputeShadow:
- Panic
-
- /* Get size of selected brush */
- ActiveBrush BrushBay
- BrushSize
- parse var result BWidth BHeight
-
- /* Make a new screen */
- CurrPage
- OrigPage = Result
- ClonePage OrigPage
- OpenPages
- NewPage = Result
- PickPage NewPage
-
- /* Place brush in center of new screen & in alpha channel */
- PageSize
- parse var result PageWidth PageHeight
- XPosition = Trunc((PageWidth/2)-(BWidth/2))
- YPosition = Trunc((PageHeight/2)-(BHeight/2))
- ActiveBrush BrushBay
- Handle 0 0
- ColorSource Multicolor
- PutBrush XPosition YPosition
- if VersionNum > 2.2 then do
- AddAlpha
- InvertAlpha
- AlphaPattern GreyScale
- WorkMode ALPHA
- end
- if VersionNum <= 2.2 then do
- WorkMode ALPHA
- SetDrawMode 4
- Zap
- end
- SetDrawMode 1
- ActiveBrush BrushBay
- Handle 0 0
- ColorSource PaintPot
- ActivePot 1
- PutBrush XPosition YPosition
- WorkMode Image
-
- /* Ask for position of drop shadow */
- AskBool "Now, choose the location of your drop shadow.\nSelect CANCEL now if you don't want to lose B"BrushBay"!"
- If Result = 0 then do
- PickPage OrigPage
- DeletePage NewPage
- NotBusy
- RestoreSetUp
- EXIT
- end
- Handle 0 0
- GetPoint
- parse var result XDropPos YDropPos
-
- /* Feather the brush */
- if FeatherAmt > 0 then do
- if FeatherType=OUT then do
- do OutlineNum = 1 to FeatherAmt
- Key OutlineBrush
- end
- BWidth = BWidth+(FeatherAmt*2)
- BHeight = BHeight+(FeatherAmt*2)
- XDropPos = XDropPos-FeatherAmt
- YDropPos = YDropPos-FeatherAmt
- end
- Feather FeatherAmt
- end
-
- /* Let's do it! */
- Busy
- WorkMode Alpha /* Paste drop shadow into alpha channel */
- Panic
- SetDrawMode 1
- ActiveBrush BrushBay
- Handle 0 0
- ColorSource PaintPot
- TransType Standard TransAmt
- Trans Enable
- ActivePot 1
- PutBrush XDropPos YDropPos
- Trans Disable
-
- /* Calculate size of area to contain brush & drop shadow */
- X1 = MIN(XPosition,XDropPos)
- Y1 = MIN(YPosition,YDropPos)
- X2 = MAX(XPosition+BWidth,XDropPos+BWidth)
- Y2 = MAX(YPosition+BHeight,YDropPos+BHeight)
-
- /* Cut brush with alpha drop shadow */
- WorkMode Image
- ActiveBrush BrushBay
- CutMode Normal 1
- RectCut X1 Y1 X2 Y2
-
- /* Go back to original page & delete temp page */
- PickPage OrigPage
- if KillTempPage=1 then do
- DeletePage NewPage
- end
- NotBusy
- Return
-
-
- Help:
- ReqBuild '640 310 "Help for Drop Shadow Maker v2.0"'
- AddBox '15 30 610 235'
- AddGadget 'Button ExitHelp CenterX 275 Medium "Exit Help"'
-
- AddHeading 'CenterX 40 "Shadow Options"'
- AddText '25 55 "- The FEATHERING option ''softens'' the edges of the drop shadow. To apply"'
- AddText '25 65 " feathering to the drop shadow, simply drag the slider to the amount of"'
- AddText '25 75 " feathering desired, in pixels. Depending on the size of the brush,"'
- AddText '25 85 " amounts of more than 10 pixels usually produce undesirable results."'
-
- AddText '25 95 "- The TRANSPARENCY slider determines the opacity of the drop shadow. The"'
- AddText '25 105 " higher the setting, the more transparent the drop shadow."'
-
- AddText '25 115 "- The DELETE TEMP PAGE option determines whether the temporary page"'
- AddText '25 125 " created by Drop Shadow Maker is deleted after the shadow is created."'
- AddText '25 135 " Turn this option off only if you have a burning need for the original"'
- AddText '25 145 " for the original brush and it hasn''t been saved."'
-
- AddHeading 'CenterX 160 "When to use Feathering IN or OUT"'
- AddText '25 175 "There are two types of feathering: IN will fade the transparency from the"'
- AddText '25 185 "edge of the brush inwards, while OUT will fade from the edge of the brush"'
- AddText '25 195 "outward. FEATHER IN is the default, suitable for brushes with a solid and"'
- AddText '25 205 "continuous edge (spheres, rectangles, free shapes, etc.), while FEATHER"'
- AddText '25 215 "OUT gives much better results for text brushes, which contain complex"'
- AddText '25 225 "curves and narrow passages that may disappear if the feathering setting is"'
- AddText '25 235 "too high. FEATHER OUT also takes more time to compute, so only use it for"'
- AddText '25 245 "text brushes where the effect is needed."'
-
- Request NoOk NoCancel
- Return
-
-
- StandardIO:
- AskBool "Drop Shadow Maker v2.0 - by Greg Niles\nClick OK to continue, Cancel to Abort."
- If Result = 0 then EXIT
-
- do forever
- /* Ask which brush to use */
- AskProp 1 3 1 "Select brush number (1-3).\n(Select CANCEL if you don't want to lose your brush!)"
- If RC = 5 then EXIT
- BrushBay = Result
-
- /* See if the selected brush is empty */
- ActiveBrush BrushBay
- BrushSize
- parse var result CheckWidth CheckHeight
- if CheckWidth ~= -1 then break
- Okay "Brush "BrushBay" is empty! Please select another brush."
- end
-
- /* Get feather amount from user */
- AskInt 0 20 0 "Enter feather amount (0=no feathering).\nThis determines the 'fuzziness' of your drop shadow, in pixels."
- If RC = 5 then EXIT
- FeatherAmt = Result
-
- /* Get feather type from user */
- if FeatherAmt > 0 then do
- AskBool "Select feathering type:\n\n[OK] Feather in (standard)\n[CANCEL] Feather out"
- if Result=0 then FeatherType = OUT
- if Result=1 then FeatherType = IN
- end
-
- /* Get transparency level from user */
- AskProp 0 100 50 "Select transparency level of drop shadow."
- If RC = 5 then EXIT
- TransAmt = Result
-
- /* Ask about deleting the spare page */
- AskBool "Delete the temporary spare page?"
- KillTempPage = Result
- Return
-
-
- EXIT
-