PDA

View Full Version : Cutout Script: ArtRage Studio Pro only.



AndyRage
07-14-2011, 10:37 AM
Here is a script to make a cutout effect on an object on a layer.
To use the script, select a layer that has a stroke of paint, or sticker or other element with some areas of transparency. Run the script and enter the parameters.

The result will be an effect as though the element were underneath a cut out hole in the layer.

Remember to save the script code in a UTF16 Unicode text file.



//================================================== =========================
//================================================== =========================
// ArtRage Script File.
//================================================== =========================
//================================================== =========================

//================================================== =========================
// Version Block - Script version and ArtRage version:
//================================================== =========================
<Version>
ArtRage Version: ArtRage 3 Studio Pro
ArtRage Build: 3.5.0
Professional Edition: Yes
Script Version: 1
</Version>

//================================================== =========================
// Header block - Info about the painting/person who generated this script:
//================================================== =========================
<Header>
// === Project data
Painting Name: "Untitled"
Painting Width: 1479
Painting Height: 1115
Painting DPI: 72
// === Author data
Author Name: "Andy Bearsley"
Script Name: "Cutout Shadow"
Comment: "This script will generate a cutout shadow for the current layer"
Script Type: ""
Script Feature Flags: 0
</Header>

//================================================== =========================
// ArtRage project features. Sets the startup state of the script:
//================================================== =========================

//================================================== =========================
// Script data follows:
//================================================== =========================
<Events>
int nLayer = CurrentLayerIndex()
string sLayerName = LayerName(nLayer)
string sMessage = "Cutout settings for layer %%nLayer"
if (sLayerName.Length() > 0) {
sMessage += " ( %%sLayerName )"
}
// Check we can run on this layer (paint, text, or sticker)
int nLayerType = LayerType(nLayer)
if (nLayerType != 0 && nLayerType != 4 && nLayerType != 5) {
MessageBox("This script wont work on this layer. (Layer %%nLayer)")
exit
}
real rRadius = 3
real rOpacity = 0.7
real rOffX = 3
real rOffY = 3
flag fMergeResult = true
// Get the user data
InputBox(sMessage + "\n\rShadow Radius (1 to 100): $$rRadius\n\rShadow Opacity (0 - 1): $$rOpacity\n\rCutout Offset X (-100 to 100): $$rOffX\n\rCutout Offset Y (-100 to 100): $$rOffY\n\rMerge Result: $$fMergeResult")
// Clamp user data to sensible ranges.
if (rRadius < 0) rRadius = 0
if (rRadius > 10) rRadius = 10
if (rOpacity < 0) rOpacity = 0
if (rOpacity > 1) rOpacity = 1
if (rOffX < -100) rOffX = -100
if (rOffX > 100) rOffX = 100
if (rOffY < -100) rOffY = -100
if (rOffY > 100) rOffY = 100
// Apply cutout
// Check if we're going to have a problem, with a non-paint layer.
int nSelLayer = nLayer
int nCutoutLayer = nLayer + 1
if (nLayerType != 0) { // Not a paint layer
if (fMergeResult) { // We're merging the results later, so we can just rasterize first and get rid of the problem
Wait: 0.000s EvType: Command CommandID: CID_RasteriseSpecificLayer ParamType: uint32 Value: { nLayer }
nLayerType = 0; // Now it's a paint layer. No problem.
}
else { // Not merging - Houston we have a problem. Have to duplicate layer and rasterize to get selection alpha.
nSelLayer = nLayer + 1 // Layer for selection will be layer above
nCutoutLayer = nLayer + 2 // Cutout layer is above selection layer.
Wait: 0.000s EvType: Command CommandID: CID_DuplicateSpecificLayer ParamType: uint32 Value: { nLayer }
Wait: 0.000s EvType: Command CommandID: CID_RasteriseSpecificLayer ParamType: uint32 Value: { nSelLayer }
}
}
// Create a layer of black, using the Fill tool.
Wait: 0.000s EvType: Command CommandID: CID_SelectSpecificLayer ParamType: uint32 Value: { nSelLayer }
Wait: 0.000s EvType: Command CommandID: Add New Layer
Wait: 0.000s EvType: Command CommandID: SetForeColour ParamType: Pixel Value: { 0x0FF000000 }
Wait: 0.000s EvType: Command CommandID: CID_ToolSelect ParamType: ToolID Value: { 4921 (Fill Tool ) }
Wait: 0.000s EvType: Command CommandID: ToolPreset ToolID: 4921 (Fill) Tool Data: {
┹┓──┘───────◭╖╧┽───────────┿━───└─────▀┿────━───── ────▀┿
} // End of tool preset binary data.
<StrokeEvent>
<StrokeHeader>
<EventPt> Wait: 0.000s Loc: (0, 0) Pr: 1 Ti: 1 Ro: 0 Rv: NO Iv: NO </EventPt>
</StrokeHeader>
Wait: 0.000s Loc: (0, 0) Pr: 1 Ti: 1 Ro: 0 Rv: NO Iv: NO
</StrokeEvent>
// Create the cutout
Wait: 0.000s EvType: Command CommandID: CID_SelectSpecificLayer ParamType: uint32 Value: { nSelLayer }
Wait: 0.000s EvType: Command CommandID: Select Layer Contents
Wait: 0.000s EvType: Command CommandID: CID_SelectSpecificLayer ParamType: uint32 Value: { nCutoutLayer }
Wait: 0.000s EvType: Command CommandID: Clear
Wait: 0.000s EvType: Command CommandID: Deselect All
Wait: 0.000s EvType: Command CommandID: LayerAdjustment ID: 0x000000002 Idx: nCutoutLayer Blur Radius: rRadius
Wait: 0.000s EvType: Command CommandID: LayerXForm Idx: nCutoutLayer Scale: (1, 1) Rot: 0 Off: (rOffX, rOffY) MirH: NO MirV: NO Ras: NO
Wait: 0.000s EvType: Command CommandID: CID_SelectSpecificLayer ParamType: uint32 Value: { nSelLayer }
Wait: 0.000s EvType: Command CommandID: Select Layer Contents
Wait: 0.000s EvType: Command CommandID: Invert Selection
Wait: 0.000s EvType: Command CommandID: CID_SelectSpecificLayer ParamType: uint32 Value: { nCutoutLayer }
Wait: 0.000s EvType: Command CommandID: Clear
Wait: 0.000s EvType: Command CommandID: Deselect All
Wait: 0.000s EvType: Command CommandID: CID_SetSpecificLayerOpacity ParamType: LayerProp Value: { nCutoutLayer, rOpacity }
// Delete selection layer if we created it
if (nLayerType != 0) {
Wait: 0.000s EvType: Command CommandID: CID_DeleteSpecificLayer ParamType: uint32 Value: { nSelLayer }
nSelLayer = nLayer
nCutoutLayer = nLayer + 1
}
// Apply merge if needed
if (fMergeResult) {
Wait: 0.000s EvType: Command CommandID: CID_MergeSpecificLayerDown ParamType: uint32 Value: { nCutoutLayer }
}
// Fix names if not merged, then select the original layer.
if (!fMergeResult) {
Wait: 0.000s EvType: Command CommandID: LayerName Idx: nCutoutLayer Name: (sLayerName + " Cutout")
Wait: 0.000s EvType: Command CommandID: LayerName Idx: nLayer Name: sLayerName
Wait: 0.000s EvType: Command CommandID: CID_SelectSpecificLayer ParamType: uint32 Value: { nLayer }
}


You can download the script file here (http://www2.ambientdesign.com/files/cutout.arscript).

semd74
07-14-2011, 10:41 AM
What is a UTF16 unicode text file? what does that mean?

AndyRage
07-14-2011, 10:42 AM
Good question, and I'll answer that in it's own sticky thread. :)