orzubalsky / creative-computing-2018

0 stars 1 forks source link

Java Color Randomization #109

Open gallm551 opened 6 years ago

gallm551 commented 6 years ago

So I managed to randomize the sizes, but the colors won't randomize. I feel like it's something small that I'm overlooking, but I can't figure out what.

var roundtangle2 = document.querySelector(".roundtangle2");

var width = randomNumber(100, 600);
var height = randomNumber(200, 500);

roundtangle2.style.width = width + "px";
roundtangle2.style.height= height + "px";

var background = randomNumber(100, 600);
var borderColor = randomNumber(200, 500);

roundtangle2.style.background = "hslColor(h, 30, 50)";
roundtangle2.style.borderColor = "hslColor(h, 70, 20)";

var container = document.queryselector(".content");

container.style.background = hslColor(h,50,70);
rachael-tomaszewski commented 5 years ago

Hey Martina! I'm actually having trouble with the same thing. Have you figured it out yet by any chance?

bajrushivlora commented 5 years ago

I think you need to define "h" as a variable ! if you define "h" as hue and make it so that the hue # is randomized, then it will work in the function you wrote.

gallm551 commented 5 years ago

Sorry, I just saw this! Basically, this fixed the whole thing! It was because h wasn't recognized as a value, just as a placeholder.

var roundtangle2 = document.querySelector(".roundtangle2");

var width = randomNumber(100, 600);
var height = randomNumber(200, 500);

roundtangle2.style.width = width + "px";
roundtangle2.style.height= height + "px";

var background = randomNumber(50, 150);
var borderColor = randomNumber(100, 350);

roundtangle2.style.background = hslColor(background, 40, 75);
roundtangle2.style.borderColor = hslColor(borderColor, 60, 70);