Skip to main content
Geppetto Luis
Legend
November 19, 2018
Beantwortet

Random blend mode

  • November 19, 2018
  • 2 Antworten
  • 3390 Ansichten

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?

Dieses Thema wurde für Antworten geschlossen.
Beste Antwort von pixxxelschubser

Try

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

Have fun

2 Antworten

Inspiring
November 19, 2018

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

Inspiring
June 3, 2021

I run the snipt and it works well. Is it posible to chenge the random method to cycle the blend modes in sequential order?

Kukurykus
Legend
June 3, 2021

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

 

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

pixxxelschubser
Community Expert
Community Expert
November 19, 2018

Try

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

Have fun

Geppetto Luis
Legend
November 19, 2018

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

pixxxelschubser
Community Expert
Community Expert
November 19, 2018

add alert(blendMode)