This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Animate Your Name Forum

View Course

3691 points
55df2afa95e3787b9200005e_359368177
Submitted by
Judy
over 3 years ago

Can I make more colors?

There are many ways to define colors. In this project we are using HSL (Hue, Saturation, Lightness). You can read about HSL and other color models here.

In this project you take an array with 3 numbers and assign it a name. You are free to use any words as your array names.

var red = [0, 100, 63];
var tomato = [0, 100, 63];
var punchBuggy = [0, 100, 63];

In the case of red, Hue is 0, Saturation is 100% and Lightness is 63%.

There are many online tools to help you choose new colors. here is one, and here is another

More Colors

If you make a new color like this:

var tardis = [230, 58, 24];

Then you can use your new color in your letterColors array. If you want more than one letter of each color, in a row, then you can build up a pattern like this:

letterColors = [tardis, tardis, tardis, punchBuggy];

Return to Frequently Asked Questions


0 votes

permalink

How can I make the colors random?

217 points
B016cfa0ddde17813598cf22156919d5?s=140&d=retro
Submitted by
ipodlover3354
almost 3 years ago

2 Comments

55df2afa95e3787b9200005e_359368177 Judy almost 3 years ago

Computers are great at picking seemingly random numbers. Have you learned how to get JavaScript to do that for you yet? You'll need to learn how to use Math.random() -- https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random. With that knowledge you could generate random number for the three numbers in the colour arrays. Or you could learn a bit more about array indexes and put random colours into the letterColors array. The first place I remember seeing Math.random() here is in the Rock Paper Scissors game you build in the fourth section of the JavaScript track http://www.codecademy.com/en/tracks/javascript

B016cfa0ddde17813598cf22156919d5?s=140&d=retro ipodlover3354 almost 3 years ago

Yea, I am actually on the lesson all about Math.