Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

generateColors() (See related posts)

//Generates an array of size howMany with colors from start RGB to end RGB
//toHex() function is on my profile.

function generateColors(sred, sgreen, sblue, ered, egreen, eblue, howMany) {
	// loop to create
	var arColors = new Array();
	for(var i = 0; i < howMany; ++i) {
			// set current red descriptor
			var red = Math.floor(sred * ((howMany - i) / howMany) + ered * (i / howMany));

			// set current green descriptor
			var green = Math.floor(sgreen * ((howMany - i) / howMany) +egreen * (i / howMany));

			// set current green descriptor
			var blue = Math.floor(sblue * ((howMany - i) / howMany) + eblue * (i / howMany));
			
			arColors[i] = [toHex(red), toHex(green), toHex(blue)];
	}
	return arColors;
}

You need to create an account or log in to post comments to this site.