PDA

View Full Version : Cycling through layer blend modes



RedSaucers
07-29-2017, 01:40 AM
I have created an ArtRage script file that allows the cycling through all of the layer blend modes on a mouse canvas click,
which terminates when the Shift key is held down on a mouse canvas click.

It seems to only work however when the play script dialog is stopped, it initially says "Awaiting Input..", see the video below :

https://youtu.be/rmVACmVh6M0

I have completely removed the Header Block and did play around with commenting out the script feature flags or setting them to all 0s but I still get the dialog, is this expected behaviour?

Here is my code :



//================================================== =========================
//================================================== =========================
// ArtRage Script File.
// Cycle through all blend modes with a click on the canvas
// by James Dyer (RedSaucers)
//================================================== =========================
//================================================== =========================

//================================================== =========================
// Version Block - Script version and ArtRage version:
//================================================== =========================
<Version>
ArtRage Version: ArtRage 3 5
ArtRage Build: 5.0.5
Professional Edition: Yes
Script Version: 1
</Version>
//================================================== =========================
// and now for the code!
//================================================== =========================
intarray bm_values;
// All blend modes in order
bm_values ={ 169, 194, 192, 193, 195, 178, 170, 176, 185, 186,
171, 177, 184, 187, 179, 181, 180, 188, 189, 190,
191, 182, 183, 172, 173, 174, 175 }
int bm_len = bm_values.GetSize()
int bm_index = 1
while (true) {
WaitResumeAtMouse()

if (!KeyShiftIsDown()) {
Wait: 0.000s EvType: Command CommandID: CID_SetSpecificLayerBlend ParamType: LayerTwoOp Value: { CurrentLayerIndex(), 3000000000+bm_values[bm_index] }

bm_index++

if (bm_index > bm_len-1) {
bm_index = 0
}
}
else {
exit
}
}

HannahRage
08-01-2017, 02:33 PM
We're having a look, but the main problem is going to be that ArtRage doesn't really allow you to interact while a script is playing, only when a dialogue box with playback options pops up. The 'playing/awaiting' dialogue box is just there to show the script status, it isn't something you can disable. So you may have come up with the best possible workaround ;)

For an example of a script with repeating dialogue options, see https://forums.artrage.com/showthread.php?36174-Spirograph&p=366620#post366620

RedSaucers
08-24-2017, 01:35 AM
I have improved on my script above to allow selection of both blend modes and opacity on canvas touch, here is a video demonstration :

https://youtu.be/jFV0D8P_OBE

and here is my script


//================================================== =========================
//================================================== =========================
// ArtRage Script File.
//
// SET SELECTED LAYER BLEND MODE / OPACITY
// USING CANVAS PIXEL POSITION OF PEN ON CANVAS
//
// Left half of canvas & Y Pixel - layer blend mode
// Right half of canvas & Y Pixel - layer opacity
//
// by James Dyer (RedSaucers)
//================================================== =========================
//================================================== =========================
//================================================== =========================
// Version Block - Script version and ArtRage version:
//================================================== =========================
<Version>
ArtRage Version: ArtRage 3 5
ArtRage Build: 5.0.5
Professional Edition: Yes
Script Version: 1
</Version>
//================================================== =========================
// and now for the code!
//================================================== =========================
intarray bm_values;
bm_values ={ 169, 194, 192, 193, 195, 178, 170, 176, 185, 186,
171, 177, 184, 187, 179, 181, 180, 188, 189, 190,
191, 182, 183, 172, 173, 174, 175 } // all blend mode ids in order
int nWidth = PaintingWidth();
int nHeight = PaintingHeight();
real x
real y
while (true) {
// wait for the pen to touch the canvas
WaitSampleMouse()

// get the x and y coords of the pen
x = MouseX();
y = MouseY();

if (!KeyShiftIsDown()) { // a script exit strategy if Shift and pen down is selected

if (y >= 0 && y <= nHeight) { // only perform layer actions if pen is within canvas vertical

// the left half of the canvas o set up blend modes
if (x >= 0 && x < nWidth / 2) {
int bm_index = (y / nHeight) * bm_values.GetSize()
Wait: 0.000s EvType: Command CommandID: CID_SetSpecificLayerBlend ParamType: LayerTwoOp Value: { CurrentLayerIndex(), 3000000000+bm_values[bm_index] }
}
// the right half of the canvas to set up opacity
else if (x >= nWidth / 2 && x <= nWidth) {
real opacity = (nHeight - y) / nHeight
Wait: 0.000s EvType: Command CommandID: CID_SetSpecificLayerOpacity ParamType: LayerProp Value: { CurrentLayerIndex(), opacity }
}
}
}
else {
exit // Executing exit strategy
}
}