Copy link to clipboard
Copied
I would like to use the randon blend mode method on the selected level
I put this together
var blendModes = [BlendMode.NORMAL, BlendMode.SCREEN, BlendMode.MULTIPLY, BlendMode.OVERLAY];
blendMode = Math.random();
where am I wrong?
Try
blendMode = blendModes[Math.floor(Math.random()*4)];
Have fun
Copy link to clipboard
Copied
Try
blendMode = blendModes[Math.floor(Math.random()*4)];
Have fun
Copy link to clipboard
Copied
I tried but it does not work
this and what I did.
var blendModes = [BlendMode.NORMAL, BlendMode.SCREEN, BlendMode.MULTIPLY, BlendMode.OVERLAY];
blendMode = blendModes[Math.floor(Math.random()*4)];
Copy link to clipboard
Copied
add alert(blendMode)
Copy link to clipboard
Copied
Don't forget to set it to a layer
var blendModes = [BlendMode.SOFTLIGHT, BlendMode.SCREEN, BlendMode.MULTIPLY, BlendMode.OVERLAY];
activeDocument.activeLayer.blendMode = blendModes[Math.floor(Math.random()*4)];
Copy link to clipboard
Copied
I run the snipt and it works well. Is it posible to chenge the random method to cycle the blend modes in sequential order?
Copy link to clipboard
Copied
Take out the Math random Spartans just loop through the array.
Copy link to clipboard
Copied
I am not sure what the spartas are. When I remove the *4, or the Math.random() method, the script does not run.
How do I remove the Math random spartans?
Copy link to clipboard
Copied
If you just loop through the blend modes on the same layer, all you will get is the last blend mode, when the script is done. What do you want to do? To select a particular band mode in your loop you want:
activeDocument.activeLayer.blendMode = blendModes[i];
Copy link to clipboard
Copied
Thanks for your help! I am trying to loop throug the blend modes in the array to toogle between the Normal and Multiplie blend modes. When the script runs, it sets the active layer blend mode to NORMAL if it is MULTIPLE. And NORMAL if the active layer blend mode is MULTIPLE.
Do I need a conditonal satament to check the acltive layer blend mode?
Copy link to clipboard
Copied
It's better if you said at beginning what you exactly wish:
aL.blendMode = (bm = BlendMode)[({NORMAL: 'MULTIPLY', MULTIPLY: 'NORMAL'})
[unescape((aL = activeDocument.activeLayer).blendMode).split(bm + '.')[1]]]
Copy link to clipboard
Copied
I undesrstand the snipe only works when the layers are in NORMAL and MULTIPLY blend modes.
When I try to change the blend modes to NORMAL and COLOR I get an error alert.
Error: Invalid enumartion vlaue
What needs to change on the code so that the it works with the NORMAL and COLOR blend modes?
Copy link to clipboard
Copied
COLORBLEND
Copy link to clipboard
Copied
Thanks for your quick response. This is not working in a mac system. Am I missing something?
Copy link to clipboard
Copied
I tried it in CS6 and PS 2020 on no background layer. Maybe change unescape to String, and use one line of that code instead of current two. Set layer to Normal or Color blend mode.
Copy link to clipboard
Copied
Do you mean one continuous line for the code instead of two lines?
Copy link to clipboard
Copied
Yes. Didn't multiply / normal version work for you?
Copy link to clipboard
Copied
Got it I wanted to make ssure I undesrtand what to do. The code works with the String change in PS2022 Tested succesfully with diffrent blend mode pairs. Many thansk for your generous help!
Copy link to clipboard
Copied
Thank you! The last snipet works well when the active layer is in Normal or Mutiple mode.
Copy link to clipboard
Copied
That's right. There had not to be other blendings, so it works only for these two.
Copy link to clipboard
Copied
Can you tell me if this solution works on Macintosh: May 31, 2021
Copy link to clipboard
Copied
bm = ['NORMAL', 'SCREEN', 'MULTIPLY', 'OVERLAY']; while(bm.length)
activeDocument.activeLayer.blendMode = BlendMode[bm.shift()]
Copy link to clipboard
Copied
This snipet does not work on Mac system. It chenges the blend mode of the active layer from Normal to Overlay and persits in Overlay.
Copy link to clipboard
Copied
So as intended due to your original description before specifying what you exactly need.
A working code for you is the other I left later. As to Mac I asked of code in linked topic.