From my memories of Live Messenger, it sounds like you're trying to do gradients, which can be applied really quite easily in Windows Presentation Foundation (WPF, part of. Presumably for Hue, Saturation and Lightness (HSL) colours, you can just raise the L component, but I can't say for certain I'm less familiar with this colour space.Īs I say, though, this method is quite crude. #ff0000 will give you a bright red, which can then be faded by increasing the values of the G and B componenets by the same amount, such as #ff5555 (gives a lighter red). E.g., in HTML colours are represented as three two-digit hex numbers. If your colours are in RGB format (or, presumably CMYK), you can use the fairly crude method of increasing the value of each component of the colour. Void HSVToRGB(double h,double s,double v,unsigned char *pr,unsigned char *pg,unsigned char *pb) * chromatic case: Saturation is not 0, so determine hue */ So convert from RGB to HSV, brighten the 'V', then convert back to RGB.īelow is some C code to convert void RGBToHSV(unsigned char cr, unsigned char cg, unsigned char cb,double *ph,double *ps,double *pv) Using this representation is it easier to adjust the brightness. HSV ( Hue / Saturation / Value ) also called HSL ( Hue / Saturation / Lightness ) is just a different color representation. lerp the colours to get the differenceĪn example of applying this would be something like: // make red 50% lighter: So then a simple lerp operation between two colours using RGB would be: public static Color Lerp(this Color colour, Color to, float amount)įloat sr = colour.R, sg = colour.G, sb = colour.B Here's an extension method to do it to a float: public static float Lerp( this float start, float end, float amount) Lerp is a mathematical operation between two floats that changes the value of the first by a ratio of the difference between them. In XNA there is the Color.Lerp static method that does this as the difference between two colours.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |