Link in Zwischenablage kopieren
Kopiert
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
Link in Zwischenablage kopieren
Kopiert
Try
blendMode = blendModes[Math.floor(Math.random()*4)];
Have fun
Link in Zwischenablage kopieren
Kopiert
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)];
Link in Zwischenablage kopieren
Kopiert
add alert(blendMode)
Link in Zwischenablage kopieren
Kopiert
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)];
Link in Zwischenablage kopieren
Kopiert
I run the snipt and it works well. Is it posible to chenge the random method to cycle the blend modes in sequential order?
Link in Zwischenablage kopieren
Kopiert
Take out the Math random Spartans just loop through the array.
Link in Zwischenablage kopieren
Kopiert
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?
Link in Zwischenablage kopieren
Kopiert
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];
Link in Zwischenablage kopieren
Kopiert
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?
Link in Zwischenablage kopieren
Kopiert
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]]]
Link in Zwischenablage kopieren
Kopiert
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?
Link in Zwischenablage kopieren
Kopiert
COLORBLEND
Link in Zwischenablage kopieren
Kopiert
Thanks for your quick response. This is not working in a mac system. Am I missing something?
Link in Zwischenablage kopieren
Kopiert
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.
Link in Zwischenablage kopieren
Kopiert
Do you mean one continuous line for the code instead of two lines?
Link in Zwischenablage kopieren
Kopiert
Yes. Didn't multiply / normal version work for you?
Link in Zwischenablage kopieren
Kopiert
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!
Link in Zwischenablage kopieren
Kopiert
Thank you! The last snipet works well when the active layer is in Normal or Mutiple mode.
Link in Zwischenablage kopieren
Kopiert
That's right. There had not to be other blendings, so it works only for these two.
Link in Zwischenablage kopieren
Kopiert
Can you tell me if this solution works on Macintosh: May 31, 2021
Link in Zwischenablage kopieren
Kopiert
bm = ['NORMAL', 'SCREEN', 'MULTIPLY', 'OVERLAY']; while(bm.length)
activeDocument.activeLayer.blendMode = BlendMode[bm.shift()]
Link in Zwischenablage kopieren
Kopiert
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.
Link in Zwischenablage kopieren
Kopiert
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.
Weitere Inspirationen, Events und Ressourcen finden Sie in der neuen Adobe Community
Jetzt ansehen