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

Random blend mode

  • November 19, 2018
  • 2 replies
  • 3406 views

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?

This topic has been closed for replies.
Correct answer pixxxelschubser

Try

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

Have fun

2 replies

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?

Chuck Uebele
Community Expert
Community Expert
June 3, 2021

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

pixxxelschubser
Community Expert
pixxxelschubserCommunity ExpertCorrect answer
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)