• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Random blend mode

Advocate ,
Nov 19, 2018 Nov 19, 2018

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?

TOPICS
Actions and scripting

Views

2.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 19, 2018 Nov 19, 2018

Try

blendMode = blendModes[Math.floor(Math.random()*4)];

Have fun

Votes

Translate

Translate
Adobe
Community Expert ,
Nov 19, 2018 Nov 19, 2018

Copy link to clipboard

Copied

Try

blendMode = blendModes[Math.floor(Math.random()*4)];

Have fun

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Nov 19, 2018 Nov 19, 2018

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)]; 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 19, 2018 Nov 19, 2018

Copy link to clipboard

Copied

add alert(blendMode)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Nov 19, 2018 Nov 19, 2018

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)]; 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 03, 2021 Jun 03, 2021

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 03, 2021 Jun 03, 2021

Copy link to clipboard

Copied

Take out the Math random Spartans just loop through the array.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 03, 2021 Jun 03, 2021

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?

 

var blendModes = [BlendMode.SOFTLIGHT, BlendMode.SCREEN, BlendMode.MULTIPLY, BlendMode.OVERLAY];

activeDocument.activeLayer.blendMode = blendModes[Math.floor(Math.random()*4)];
 
for (var i=0; i<blendModes.length; i++)
{
alert(activeDocument.activeLayer.blendMode);
}

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 03, 2021 Jun 03, 2021

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];

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 03, 2021 Jun 03, 2021

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?

 

var blendModes = [BlendMode.NORMAL, BlendMode.MULTIPLY];
 
activeDocument.activeLayer.blendMode = blendModes[i];
 
for (var i=0; i<blendModes.length; i++)
{
alert(activeDocument.activeLayer.blendMode);
}

 

 

 

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 03, 2021 Jun 03, 2021

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

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 03, 2021 Dec 03, 2021

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?

Screen Shot 2021-12-03 at 9.09.44 AM.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 03, 2021 Dec 03, 2021

Copy link to clipboard

Copied

COLORBLEND

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 03, 2021 Dec 03, 2021

Copy link to clipboard

Copied

Thanks for your quick response. This is not working in a mac system.  Am I missing something?

aL.blendMode = (bm = BlendMode)[({NORMAL: 'COLORBLEND', COLORBLEND: 'NORMAL'})
[unescape((aL = activeDocument.activeLayer).blendMode).split(bm + '.')[1]]]

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 03, 2021 Dec 03, 2021

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 03, 2021 Dec 03, 2021

Copy link to clipboard

Copied

Do you mean one continuous line for the code instead of two lines?

aL.blendMode = (bm = BlendMode)[({NORMAL: 'COLORBLEND', COLORBLEND: 'NORMAL'})[String((aL = activeDocument.activeLayer).blendMode).split(bm + '.')[1]]]

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 04, 2021 Dec 04, 2021

Copy link to clipboard

Copied

Yes. Didn't multiply / normal version work for you?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Dec 04, 2021 Dec 04, 2021

Copy link to clipboard

Copied

LATEST

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 03, 2021 Jun 03, 2021

Copy link to clipboard

Copied

Thank you! The last snipet works well when the active layer is in Normal or Mutiple mode.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 03, 2021 Jun 03, 2021

Copy link to clipboard

Copied

That's right. There had not to be other blendings, so it works only for these two.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 03, 2021 Jun 03, 2021

Copy link to clipboard

Copied

Can you tell me if this solution works on Macintosh: May 31, 2021

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 03, 2021 Jun 03, 2021

Copy link to clipboard

Copied

bm = ['NORMAL', 'SCREEN', 'MULTIPLY', 'OVERLAY']; while(bm.length)
	activeDocument.activeLayer.blendMode = BlendMode[bm.shift()]

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jun 03, 2021 Jun 03, 2021

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 03, 2021 Jun 03, 2021

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines