Skip to main content
laurac17586749
Participant
November 23, 2022
Answered

random couleur expression

  • November 23, 2022
  • 3 replies
  • 1182 views

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 🙂

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

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

 

3 replies

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
November 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 - inPoint)/dur);
seedRandom(seed,true);
random([0,0,0,1],[1,1,1,1])

 

laurac17586749
Participant
November 24, 2022

thank you ! exactly what i want !

Mylenium
Legend
November 23, 2022

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

ShiveringCactus
Community Expert
Community Expert
November 23, 2022

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.