PDA

View Full Version : Bevel script: ArtRage Studio Pro only.



AndyRage
07-14-2011, 10:39 AM
This script produces an effect like a raised surface on an object in a layer.
To use the script, select a layer which has a stroke or other object with some areas of transparency. Run the bevel script.



//================================================== =========================
//================================================== =========================
// 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: "Simple Bevel"
Comment: "This script will generate a simple bevel 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 = "Bevel 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.75
real rDirection = 315
flag fMergeResult = true
// Get the user data
InputBox(sMessage + "\n\rBevel Radius (1 to 100): $$rRadius\n\rBevel Opacity (0 - 1): $$rOpacity\n\rLight Direction (0 - 360 degrees): $$rDirection\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 (rDirection < 0) rDirection = 0
if (rDirection > 360) rDirection = 360
// Convert direction to offset
real pi = 3.14159265359
real rRad = rDirection / 360 * pi * 2 - (pi / 2)
real rOffX = cos(rRad) * rRadius
real rOffY = sin(rRad) * rRadius
// Apply cutout
// Check if we're going to have a problem, with a non-paint layer.
int nSelLayer = nLayer
int nWorkingLayer = 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
nWorkingLayer = 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 }
}
}
//========================
// Dark side of highlight
//========================
// 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 shadow
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: { nWorkingLayer }
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: nWorkingLayer Blur Radius: rRadius
Wait: 0.000s EvType: Command CommandID: LayerXForm Idx: nWorkingLayer 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: { nWorkingLayer }
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: { nWorkingLayer, rOpacity }
Wait: 0.000s EvType: Command CommandID: CID_SetSpecificLayerBlend ParamType: LayerTwoOp Value: { nWorkingLayer, 3000000193 }

//========================
// Light side of highlight
//========================
// 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: { 0x0FFFFFFFF }
Wait: 0.000s EvType: Command CommandID: CID_ToolSelect ParamType: ToolID Value: { 4921 (Fill Tool ) }
<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 highlight
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: { nWorkingLayer }
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: nWorkingLayer Blur Radius: rRadius
Wait: 0.000s EvType: Command CommandID: LayerXForm Idx: nWorkingLayer 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: { nWorkingLayer }
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: { nWorkingLayer, rOpacity }
Wait: 0.000s EvType: Command CommandID: CID_SetSpecificLayerBlend ParamType: LayerTwoOp Value: { nWorkingLayer, 3000000192 }

// Delete selection layer if we created it
if (nLayerType != 0) {
Wait: 0.000s EvType: Command CommandID: CID_DeleteSpecificLayer ParamType: uint32 Value: { nSelLayer }
nSelLayer = nLayer
nWorkingLayer = nLayer + 1
}
// Apply merge if needed
if (fMergeResult) {
Wait: 0.000s EvType: Command CommandID: CID_MergeSpecificLayerDown ParamType: uint32 Value: { nWorkingLayer }
Wait: 0.000s EvType: Command CommandID: CID_MergeSpecificLayerDown ParamType: uint32 Value: { nWorkingLayer }
}
// Fix names if not merged, then select the original layer.
if (!fMergeResult) {
Wait: 0.000s EvType: Command CommandID: LayerName Idx: nWorkingLayer Name: (sLayerName + " Highlight")
Wait: 0.000s EvType: Command CommandID: LayerName Idx: (nWorkingLayer + 1) Name: (sLayerName + " Shadow")
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/bevel.arscript).