Skip to main content
Geppetto Luis
Legend
February 13, 2019
Answered

Channel mixer

  • February 13, 2019
  • 2 replies
  • 1799 views

Channel mixer

I created a small random script

for the variable creation of bn

I'm having a hard time

I would like the sum of the three colors in random to always be +100

AAAOP.jpg

you have some solution

thank you

This topic has been closed for replies.
Correct answer r-bin

Try this

var a = Math.round((400*Math.random())) - 200;

var b;

do { b = Math.round((400*Math.random())) - 200; } while (a+b > 100 || a+b < -100);

var c = 100-a-b;

alert(a + " " + b + " " + c + " = "+(a+b+c));

2 replies

r-binCorrect answer
Legend
February 13, 2019

Try this

var a = Math.round((400*Math.random())) - 200;

var b;

do { b = Math.round((400*Math.random())) - 200; } while (a+b > 100 || a+b < -100);

var c = 100-a-b;

alert(a + " " + b + " " + c + " = "+(a+b+c));

Geppetto Luis
Legend
February 13, 2019

Sig r-bin

I made the change as you suggested above

thank you, you are a great teacher.

Legend
February 13, 2019

There is a mistake. Correct

do { b = Math.round((400*Math.random())) - 200; } while (a+b > 300 || a+b < -100); 

Legend
February 13, 2019

del

\\wrong )