CCode for Artists - Miles DeCoster

Coding a color palette

This script uses a "for loop" to create a grid of swatches (small divs) inside of a div called "palette" and assigns each swatch a backgound color, in this case, a shade of grey in even steps from black to white. We then add a click function to the swatches that reads the color value of the swatch clicked on and assigns it to the larger box called "target". Use View Source to see the styles and scripts.