PDA

View Full Version : color fun



eXceed69
02-22-2007, 11:57 AM
what i want to do is divide a range of colors from red to blue into 255 colors store them in an array and get them later

but do you thin I can divide the color range

I have started this but it starts at green and i cant get it to work..

im using out of sequence sin phases to get the color range but thatís about where i get stuck. I canít divide the range into a certain amount of colors with in a color range. That doesnít loop


var frequency = .3;
for (var i = 0; i < 32; ++i){
r = Math.sin(frequency*i + 0) * 127 + 128;
g = Math.sin(frequency*i + 2) * 127 + 128;
b = Math.sin(frequency*i +4) * 127 + 128;
var color24:Number = r << 16 | g << 8 | b
bmpData.setPixel(400, i, color24);
bmpData.setPixel(401, i, color24);
bmpData.setPixel(402, i, color24);
}

Anyone who knows how to do this please let me know

BLiZZaRD
02-22-2007, 04:58 PM
Are you by chance trying to make something similar to a color chooser?

There are many different methods to doing so, and sin/cos is one of the more difficult.

If you are doing something similar to this and are not against dropping the current method I have a few ideas.

eXceed69
02-23-2007, 01:42 AM
Well I have solved with a bit of a hack and thinking outside the box, but it works for me thought you might like to know.

I have a symbol that is 255px wide with the color range I require, I then create a bmpdata object, attach the symbol with the color range I want. Copy the symbol to the bmpdata object then, loop through one line of pixels and extract the colors into the array.

This works surprisingly fast with no hanging while I loop… but with a larger size I can foresee a speed issue

You could also do this by creating a movieclip dynamically with the gradient/color range you want.

If anyone has a better solution please let me know



And what idea it would be?

BLiZZaRD
02-23-2007, 05:17 PM
Sounds like you have one of the more efficient methods for doing it with single MCs instead of multiples inside a single.

nice job :D

eXceed69
02-24-2007, 02:13 PM
If anyone has a better solution please let me know