Raised This Month: $ Target: $400
 0% 

Rainbow HUD messages using the HSV color model


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
[DeathTV] Sid 6.7
Member
Join Date: Oct 2007
Old 03-02-2008 , 16:43   Rainbow HUD messages using the HSV color model
Reply With Quote #1

This is something I gave up on because I don't have the time but for those wanting to know how it could be done, here it is.

To make a rainbow HUD message (assuming you know how to do HUD syncs and work HUD msg's) you will need to setup a synchronized hud msg and redraw it with a new color each time. For the color, we are going to rotate around this cone to get the rainbow effect



Using the Hue value which is measured in degrees. To travel along the outer edge, set saturation and value to 1.0 (100%). You will have to keep a static Float value for hue and increment it, say by 3.0, each time. To get your r,g,b values, we are going to call on this function

Code:
 
//Used for color cycling the HSV model
//Code adapted from http://www.buena.com/articles.shtml, "Adventures in HSV Space"
//saturation: 0 is dull gray, 1 is full color, value: 0.0 is dark, 1.0 is full luminance
HSVtoRGB(&Float:h, Float:s, Float:v, &Float:r, &Float:g, &Float:b){
 if(h > 360.0) h -= 360.0
 else if(h < 0.0) h += 360.0
 if (s == 0) {
  r = v;  g = v;  b = v;
 } else {
  new Float:fHue, Float:fValue, Float:fSaturation;
  new i;  new Float:f;  new Float:p,Float:q,Float:t;
  if (h == 360.0) h = 0.0;
  fHue = h / 60.0;
  i = floatround(fHue,floatround_floor);
  f = fHue - i;
  fValue = v;
  fSaturation = s;
  p = fValue * (1.0 - fSaturation);
  q = fValue * (1.0 - (fSaturation * f));
  t = fValue * (1.0 - (fSaturation * (1.0 - f)));
  switch (i) {
   case 0: {r = fValue; g = t; b = p;}
   case 1: {r = q; g = fValue; b = p; }
   case 2: {r = p; g = fValue; b = t;}
   case 3: {r = p; g = q; b = fValue;}
   case 4: {r = t; g = p; b = fValue;}
   case 5: {r = fValue; g = p; b = q; }
  }
 }
}
This will also make sure your hue value doesn't get out of range, so don't worry about infinitely incrementing your hue value.
The r,g,b values passed back by this function are in the range of 0.0 to 1.0, so do this to them
floatround(r*255.0)
to get them normalized. Then call this on every clock tick you define

set_hudmessage(floatround(r*255.0),floatround (g*255.0),floatround(b*255.0),xpos,ypos,0)

then show it.
Buena suerte~
__________________
Power Votes Core << Democracy at your fingertips
Get Mortal Kombat Miscstats for CS

Last edited by [DeathTV] Sid 6.7; 03-07-2008 at 22:20. Reason: typo
[DeathTV] Sid 6.7 is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:50.


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