home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD1.iso / GFX / Painting / OpalPaint2,3-020+Version.LHA / Rexx / Bevell.oprx next >
Encoding:
Text File  |  1994-04-19  |  2.2 KB  |  122 lines

  1. /* Draw a bevelled drop box, plus a stencil mask, using OpalPaint.
  2.    Requires OpalPaint 2.3 and above.
  3.  */
  4.  
  5.  
  6. address 'OpalPaint_Rexx'
  7.  
  8. options Results
  9.  
  10. SaveSetUp
  11. GetRect
  12. parse var Result X1  Y1  X2  Y2
  13.  
  14. Width = X2-X1
  15. Height = Y2-Y1
  16.  
  17. If Width < Height then MaxDepth = (Width/2)%1
  18. If Height < Width then MaxDepth = (Height/2)%1
  19.  
  20. /* Simple requester for bevel & stencil */
  21. ReqBuild '200 150 "Bevel Box Creator"'
  22. AddGadget 'HProp DepthGad 30 45 120 16 0 'MaxDepth''
  23. AddGadget 'Check StencilGad Below DepthGad 0 15 Medium'
  24. AddText 'Above DepthGad 0 -3 "Bevel depth"'
  25. AddText 'Right StencilGad 2 7 "Create Stencil?"'
  26. InitGadget DepthGad 10
  27. InitGadget 'StencilGad Selected'
  28. Request
  29. GadgetStatus Cancel
  30. if Result=1 Then do
  31.     FreeRequest
  32.     Exit
  33.     END
  34. GadgetStatus DepthGad
  35. Depth = Result           /* Set depth of bevel */
  36. GadgetStatus StencilGad
  37. StencilStatus = Result
  38. FreeRequest
  39.  
  40. GetPen
  41. RGBtoHSV Result
  42. Parse var Result Hue Sat Val
  43.  
  44.     /* Make a stencil mask of the bevel box area */
  45.  
  46. if StencilStatus=1 then do
  47. /*
  48.     Key StencilEditMode
  49. */
  50.     WorkMode STENCIL
  51.     SolidRect X1 Y1 X2 Y2-1
  52.     WorkMode IMAGE
  53.     StenEnable 0
  54. end
  55.  
  56.     /* Box body. Set up a diagonal HSV gradient */
  57.  
  58. FillMode Gradient
  59. ClearColGrad
  60. ClearTransGrad
  61. ColourDither 0
  62. TransDither 0
  63.  
  64. HSVtoRGB Hue Sat Val
  65. ColGradTag 0 Result
  66. S2 = (Sat-(0.4*65535))%1 /* Note: %1 converts number to an integer */
  67. S2 = MAX(S2,0)    
  68. HSVtoRGB Hue S2 Val
  69. ColGradTag 0.5 Result
  70. HSVtoRGB Hue Sat Val
  71. ColGradTag 1 Result
  72. GradType LinearFree HSV
  73. GradRange X1+Depth Y1+Depth X2-Depth Y2-Depth
  74. SolidRect X1+Depth Y1+Depth X2-Depth Y2-Depth
  75.  
  76. FillMode Solid
  77.     /* Top */
  78.  
  79. V2 = (Val+0.1*65535)%1
  80. V2 = MIN(V2,65535)
  81.  
  82. HSVtoRGB Hue Sat V2
  83. SetPen Result
  84.  
  85. SolidPoly X1 Y1 X2 Y1 X2-Depth Y1+Depth X1+Depth Y1+Depth X1 Y1
  86. LastPoint
  87.  
  88.  
  89.     /* Right */
  90.  
  91. V2 = (Val-0.15*65535)%1
  92. V2 = MAX(V2,0)
  93.  
  94. HSVtoRGB Hue Sat V2
  95. SetPen Result
  96.  
  97. SolidPoly X2 Y1 X2 Y2 X2-Depth Y2-Depth X2-Depth Y1+Depth X2 Y1
  98. LastPoint
  99.  
  100.     /* Left */
  101.  
  102. V2 = (Val+0.15*65535)%1
  103. V2 = MIN(V2,65535)
  104.  
  105. HSVtoRGB Hue Sat V2
  106. SetPen Result
  107.  
  108. SolidPoly X1 Y1 X1+Depth Y1+Depth X1+Depth Y2-Depth X1 Y2 X1 Y1
  109. LastPoint
  110.  
  111.     /* Bottom */
  112.  
  113. V2 = (Val-0.1*65535)%1
  114. V2 = MAX(V2,0)
  115.  
  116. HSVtoRGB Hue Sat V2
  117. SetPen Result
  118.  
  119. SolidPoly X2 Y2 X1 Y2 X1+Depth Y2-Depth X2-Depth Y2-Depth X2 Y2
  120. LastPoint
  121. RestoreSetUp
  122.