mercredi 18 mars 2015

Creating a gradient hex color (in RGB and maybe add an A) array


First off, this is almost exactly what I want: http://ift.tt/1O7RnMT


I don't really know where to start.


I have managed in the past to generate a three color gradient that depends on an integer between 1 and 100.



color = (i <= 50.0) ? (floatround((i / 50) * 255) * 0x00010000) + 0xFF0000FF : (100.0 >= i > 50.0) ? ((floatround(255 / (i / 100)) - 255) * 0x01000000) + 0x00FF00FF : 0x00FF00FF; // I based that on this: (RR*16777216)+(GG*65536)+(BB*256)+AA


What I don't know how to do is make an array of hex colors between 2 colors. Like, say I want to store all hex colors between red and crimson in a 100 cell array, how do I start? Maybe someone could make me a function that I can provide two color parameters and a 'steps' parameter. The two colors would obviously be the colors (in RGB or RGBA format) and the steps would be the number of cells in the array and the number of steps it takes. I'd like to make a function that returns the array directly. I like to learn from things, so if you could please explain what your doing in your code...


Thanks for any help, I'm a beginner when it comes to this stuff...


Also, the language I'll be using is PAWN, it is very similar to C++ so if you would please use C++ that would be easier for me to interpret.




Aucun commentaire:

Enregistrer un commentaire