AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [INC] Colour Manipulation (https://forums.alliedmods.net/showthread.php?t=302788)

hmmmmm 11-10-2017 21:11

[INC] Colour Manipulation
 
2 Attachment(s)
Made a small .inc file that has some basic functions for manipulating colours and interpolating them, because interpolating in rgb is yuck.

Can convert from RGB to HSV, and HSV to RGB. Range of values for the HSV is [0,255] for all the values, not [0,100] or [0,360] which some people might be expecting.

Also included a function to do some basic linear interpolation between 2 colours, and a seperate function for interpolating between 2 HSV colours. Since the Hue value is an angle and can wrap around, it needs to be interpolated a bit differently.

Finally, functions that takes an RGB or HSV colour and convert it to the hex string, e.g. (255, 0, 0) -> "#FF0000"

Hopefully someone else whos looking for this stuff doesn't have to go through same trouble I did to get effects they're looking for.

404UserNotFound 12-10-2017 03:47

Re: [INC] Colour Manipulation
 
Thank you! I was actually working on something like this myself.


All times are GMT -4. The time now is 14:58.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.