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/1TDk22qzU6A

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
}
}

Pat McDonald
07-01-2019, 06:23 PM
I couldn’t find the YouTube video. Is it still there?

RedSaucers
07-05-2019, 08:24 AM
here we are! https://youtu.be/1TDk22qzU6A

Pat McDonald
07-05-2019, 08:07 PM
Found it and watched it. Very impressive - great coding ...

Pat McDonald
07-05-2019, 11:55 PM
The thing I particularly want to do is create an Action that sets a Blend mode ...


... for a start

RedSaucers
07-06-2019, 10:30 PM
I have created just this thing for all the blend modes!, I will look to post them on the forum for you!

RedSaucers
07-06-2019, 10:59 PM
Here we go, just unzip and copy in the directory :)

https://1drv.ms/u/s!AtMMyTeySVJKgbhUTAVElEiM1nWQqQ?e=yPo6kT

RedSaucers
07-06-2019, 11:39 PM
and here is a quick video showing how the action shortcuts to the layer blend modes work :

https://youtu.be/7hXd24fGXOM

Pat McDonald
07-07-2019, 08:53 AM
Thanks for this, I have just watched the video on my iPad, as soon as I can get to my desktop I will unpack and instal your zip file.

Again, thank you.

Pat

RedSaucers
07-07-2019, 09:59 PM
No problem!, I have a feeling that we are just scratching the surface of the new Actions feature!

Pat McDonald
07-08-2019, 07:13 AM
RedSaucers,

Brilliant!

I've installed them - they are remarkable. Thank you.

I agree, we are just scratching the surface of actions ...

Pat

RedSaucers
07-08-2019, 08:23 AM
I am going to continue to play around with Actions and see what I can come up with.

markw
07-08-2019, 09:52 AM
Hello you two:)
Just wanted to say I like what you are doing here RedSaucers.:cool:
I too installed your Blend Mode Action, very useful indeed!
Do either of you know if there is a key command to bring up the Actions panel? I looked in the Keyboard Shortcuts panel but didn’t see one?

Pat McDonald
07-08-2019, 11:41 PM
I couldn't find a shortcut key to display the Actions palette, so I set up my own: Shift Alt A

I agree with you about the outstanding work by RedSaucers.

Pat

RedSaucers
07-09-2019, 07:55 PM
Thanks Pat and markw ! :)

c0ns1d1ne
05-06-2021, 03:51 AM
Hi. I was about to start trying to figure out how to script this myself when I found this thread. :)

Many thanks to RedSaucers for posting this. I used your scripts as a reference to help me write my own actions to cycle through the modes. The forum won't let me post a link to a zip file because I'm too new so...

101599
101620

Hopefully someone might find them useful.

Now if only we could bind actions to keyboard shortcuts...

Hang
06-09-2021, 07:47 AM
Hi RedSaucers

mega.nz deleted your zip file. Would you please be so kind to reupload the file.

Best regards
Hang

RedSaucers
06-10-2021, 10:14 AM
Updated!

https://1drv.ms/u/s!AtMMyTeySVJKgbhUTAVElEiM1nWQqQ?e=yPo6kT

Hang
06-10-2021, 10:57 PM
Best regards
Hang