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

# random couleur expression

New Here ,
Nov 23, 2022 Nov 23, 2022

Copied

Bonjour,

j'ai utilisé une expression pour un random color sur des couleurs de pixel avec un color control mais cela me créer des transitions entre les couleur. Je souhaite avoir les bonnes couleurs directement les unes après les autres sans passé par un dégradé.

Quelqu'un sait comment faire ?

Merci 🙂

TOPICS
Expressions , Freeze or hang , Scripting

Views

201

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 Expert , Nov 23, 2022 Nov 23, 2022

There are a number of possibilities. This one would randomly select from a list of colors every 0.5 seconds:

``````colors = [[1,.5,0,1],[1,1,0,1],[1,0,0,1],[.5,0,1,1],[1,0,1,1]]; // orange, yellow, red, purple, magenta
dur = .5; // duration of each color (seconds)

seed = Math.floor((time - inPoint)/dur);
seedRandom(seed,true);
colors[Math.floor(random(colors.length))]``````

and this one just selects a random color every 0.5 seconds:

``````dur = .5; // duration of each color (seconds)
seed = Math.floor((time - in``````
...

4 Replies 4
Community Expert ,
Nov 23, 2022 Nov 23, 2022

Copied

Can you post the expression you've used?  And maybe a screenshot of the current result and a mockup of the result you're trying to achieve?  I think that would help us answer your question.

Report

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

Copied

Without knowing what expression you used we cannot tell you much. Simply sounds like you are using a "dumb" random function that doesn't quantize the colors or picks them from an array. Of course then there's always the chance the function will just pick undesirable inbetween colors. Anyway, provide the code and explain what you exactly need.

Mylenium

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 Expert ,
Nov 23, 2022 Nov 23, 2022

Copied

There are a number of possibilities. This one would randomly select from a list of colors every 0.5 seconds:

``````colors = [[1,.5,0,1],[1,1,0,1],[1,0,0,1],[.5,0,1,1],[1,0,1,1]]; // orange, yellow, red, purple, magenta
dur = .5; // duration of each color (seconds)

seed = Math.floor((time - inPoint)/dur);
seedRandom(seed,true);
colors[Math.floor(random(colors.length))]``````

and this one just selects a random color every 0.5 seconds:

``````dur = .5; // duration of each color (seconds)
seed = Math.floor((time - inPoint)/dur);
seedRandom(seed,true);
random([0,0,0,1],[1,1,1,1])``````

Report

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

Copied

LATEST

thank you ! exactly what i want !