/* glass.cwx Creates the effect of carving the selected object out of beveled glass. Works for any region and effect. Written by Chris Wenham for the OS/2 e-Zine! http://www.os2ezine.com 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. */ handle = CwGetSelectedObject() /* no object selected */ if \CwIsHandleValid(handle) then do say "No object selected." exit end /* Duplicate object */ FirstDup = CwDuplicateObject(handle) /* Find its center and height */ Ycenter = CwGetProperty(FirstDup, "Position:Y Center") Xcenter = CwGetProperty(FirstDup, "Position:X Center") Height = CwGetProperty(FirstDup, "Position:Height") Width = CwGetProperty(FirstDup, "Position:Width") /* Calculate its width and height when increased 2% (to account for thicker lines) */ NewWidth = Width + Width * .02 NewHeight = Height + Height * .02 /* Turn duplicate into custom region w/solid color */ call CwSetRegion FirstDup, "Custom Region" call CwSetPosition FirstDup, Xcenter, Ycenter, NewWidth, NewHeight, 0, 0 call CwSetTool FirstDup, "Solid Color" DupTool = CwGetTool(FirstDup) /* Set color to black */ call CwSetProperty Duptool, "Color:Red", 0 call CwSetProperty Duptool, "Color:Green", 0 call CwSetProperty Duptool, "Color:Blue", 0 /* Now copy-n-paste original into our first custom region */ regview = CwGetRegion(FirstDup) CustView = CwGetView(regview) call CwCopy handle call CwSelectView CustView call CwPaste /* Turn first object in custom-tool to black */ iv1 = CwFindFirstObject(CwGetCurrentView()) call CwSetPosition iv1, Xcenter, Ycenter, Width, Height, 0, 0 call CwSetTool iv1, "Solid Color" iv1tool = CwGetTool(iv1) call CwSetProperty iv1tool, "Color:Red", 0 call CwSetProperty iv1tool, "Color:Green", 0 call CwSetProperty iv1tool, "Color:Blue", 0 /* Duplicate it into a blur effect */ Blurring = CwDuplicateObject(iv1) call CwSetPosition Blurring, Xcenter, Ycenter, NewWidth, NewHeight, 0, 0 call CwSetRegion Blurring, "Rectangle" call CwSetTool Blurring, "Blur" /* Set the blur radius to 2.5 */ BlurTool = CwGetTool( Blurring) call CwSetProperty BlurTool, "Radius", 2.5 /* Finished making first custom region */ /* Turn original into a custom region */ call CwSetRegion handle, "Custom Region" /* Make it 2% bigger to accommodate for the thickening of the edges */ call CwSetPosition handle, Xcenter, Ycenter, NewWidth, NewHeight, 0, 0 /* Paste our custom region into the Original object's view */ regview = CwGetRegion(handle) CustView = CwGetView(regview) call CwCut FirstDup call CwSelectView CustView call CwPaste /* Create duplicate of our custom region */ FirstDup2 = CwFindFirstObject(CwGetCurrentView()) call CwSetPosition FirstDup2, Xcenter, Ycenter, NewWidth, NewHeight, 0, 0 Embosser = CwDuplicateObject(FirstDup2) /* Set the second duplicate's effect to emboss */ call CwSetTool Embosser, "Emboss" /* Duplicate it into a Sharpen effect */ Sharpener = CwDuplicateObject(Embosser) call CwSetTool Sharpener, "Sharpen" /* Done! */