Overview
Color functions provide utilities for creating, manipulating, and converting colors. Raylib includes predefined color constants and functions for color operations.Color Type
Colors in Talon are represented by theColor class with RGBA components (0-255).
Predefined Colors
Raylib provides many predefined color constants:Available Color Constants
- Basic:
White,Black,Red,Green,Blue,Yellow,Magenta - Grayscale:
LightGray,Gray,DarkGray - Warm Colors:
Orange,Gold,Pink,Maroon,Brown,DarkBrown,Beige - Cool Colors:
SkyBlue,DarkBlue,Lime,DarkGreen - Purple Family:
Purple,Violet,DarkPurple - Special:
RayWhite(off-white for backgrounds),Blank(transparent)
Color Manipulation
fade
Returns color with alpha applied (fade).Source color
Alpha value (0.0 to 1.0)
Color - Color with applied alpha
colorAlpha
Returns color with alpha value.Source color
Alpha value (0.0 to 1.0)
Color - Color with new alpha
colorTint
Returns color tinted with another color.Source color
Tint color
Color - Tinted color
colorBrightness
Returns color with brightness offset.Source color
Brightness factor (-1.0 to 1.0)
Color - Adjusted color
colorContrast
Returns color with contrast correction.Source color
Contrast value (-1.0 to 1.0)
Color - Adjusted color
colorLerp
Returns color interpolation (linear) between two colors.Start color
End color
Interpolation factor (0.0 to 1.0)
Color - Interpolated color
colorAlphaBlend
Returns src alpha-blended into dst color with tint.Destination color
Source color
Tint color
Color - Blended color
Color Comparison
colorIsEqual
Checks if two colors are equal.First color
Second color
Boolean - True if colors are equal
Color Conversion
colorToInt
Converts color to hexadecimal value.Color to convert
Number - Hexadecimal color value
getColor
Returns a Color from a hexadecimal value.Hexadecimal color value
Color - Color from hex
colorNormalize
Returns color normalized as float [0..1].Color to normalize
Vector4 - Normalized color (r, g, b, a)
colorFromNormalized
Returns color from normalized values [0..1].Normalized color values
Color - Color
HSV Conversion
colorToHSV
Converts color to HSV values.Color to convert
Vector3 - HSV values (hue, saturation, value)
colorFromHSV
Returns a Color from HSV values.Hue (0.0 to 360.0)
Saturation (0.0 to 1.0)
Value (0.0 to 1.0)
Color - Color from HSV
Complete Color Example
Best Practices
The
fade() function is useful for UI animations, fade-in/fade-out effects, and particle systems.