/* Gauze filter for OpalPaint v1.1
 *
 *   Effect concept by Greg Niles.
 *   ARexx script by Martin Boyd & Greg Niles.
 */

address 'OpalPaint_Rexx'
 
options Results

SaveSetUp
/*
GetPrefs		/* NOTE: This is attempting to turn brush outlines */
Prefs = Result		/* off, but for some reason doesn't work */
Prefs = BITSET(Prefs,10)
*/

SetPrefs Prefs			   /* Turn brush outlines off for speed */

AskBool "Soft-focus this picture?"	/* Give user a chance to get out */
if Result=0 then EXIT
Okay "Select the area you wish to effect."
GetRect
parse var Result X1  Y1  X2  Y2	   /* Get region to perform effect over */

AskInt 0 50 "Enter amount of contrast (RETURN = default (7%))"
ContrastAmt = Result		   /* Select amount of contrast */
if ContrastAmt = "" then ContrastAmt = 7

ActiveBrush 1
RectCut X1 Y1 X2+8 Y2+8		   /* Cut region into B1 + a border */
Rescale 25 25			   /* Make brush quarter size */
BrushSize
BSize = Result
parse var Result Bw Bh
CurrPage
OrigPage = Result		   /* Add a page the same size as the brush */
PageRes				   /* and the same resolution as the */
Pw = MAX(Bw,16)
Ph = MAX(Bh,16)
AddPage Pw Ph Result		   /* current page */
OpenPages
NewPage = Result
PickPage NewPage		   /* Select new page */
ActiveBrush 1
Handle 0 0
PutBrush 0 0			   /* Paste brush into new page */

SetSpare 4 Blur 100		   /* Set draw mode to Blur at 100% */
SetDrawMode 22 100		   /* Could also use Smooth 100% here */
Zap				   /* Blur image 4 times */
Zap
Zap
Zap

SetDrawMode 9 ContrastAmt	   /* Set draw mode to contrast */
Zap				   /* Increase contrast */
ActiveBrush 1
RectCut 0 0 Bw-2 Bh-2		   /* Cut out modified brush */
PickPage OrigPage		   /* Go back to original page */
DeletePage NewPage		   /* Delete temporary page */
ActiveBrush 1			   /* Make brush 4x larger to get */
Rescale 400 400			  /* it back to the original size */
TransType Standard 0 50		   /* Transparency = 50 % */
Trans Enable			   /* Turn transparency on */
Handle 0 0
PutBrush X1 Y1			   /* Paste brush over region */
RestoreSetUp			   /* Remove if you want to undo*/

EXIT
