Skip to main content
March 9, 2010
Answered

Randomly rotate layer in specific increments

  • March 9, 2010
  • 1 reply
  • 4209 views

The random(x) expression is simple enough to randomly rotate a layer to any angle, but what if I want that angle to be to the nearest 45 degrees? So my layer would randomly rotate to any of the following angles: 0, 45, 90, 135, 180, 225, 270, 315, or 360 degrees.  Thanks, Jim

This topic has been closed for replies.
Correct answer Dan Ebberts

This should give you what you're looking for:

Math.floor(random(8))*45

I didn't include 360 because that's the same as 0, but if you want it, just change the 8 to a 9.

Dan

1 reply

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
March 9, 2010

This should give you what you're looking for:

Math.floor(random(8))*45

I didn't include 360 because that's the same as 0, but if you want it, just change the 8 to a 9.

Dan

March 10, 2010

Dan, thank you for your help! Really appreciate the tip. Best, Jim