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

Randomly rotate layer in specific increments

Guest
Mar 08, 2010 Mar 08, 2010

Copy link to clipboard

Copied

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

TOPICS
Expressions

Views

3.7K

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 , Mar 09, 2010 Mar 09, 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

Votes

Translate

Translate
Community Expert ,
Mar 09, 2010 Mar 09, 2010

Copy link to clipboard

Copied

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

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
Guest
Mar 09, 2010 Mar 09, 2010

Copy link to clipboard

Copied

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

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
Explorer ,
Nov 09, 2023 Nov 09, 2023

Copy link to clipboard

Copied

LATEST

You’re the man Dan! Sending good vibrations your way 🙂

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