Download
(2 Kb)
Download
Updated: 09-27-13 09:28 AM
Pictures
File Info
Compatibility:
Siege of Orgrimmar (5.4)
Updated:09-27-13 09:28 AM
Created:09-26-13 01:15 PM
Downloads:236
Favorites:1
MD5:
5.4
ColorSmudge
Version: 50400.02
by: zork [More]

Info:
Addon takes two RGB colors and and on a given percentage morphs from colorA to colorB using HSV returning a new intermediate RGB color.
Function:
Lua Code:
  1. local CS = CreateFrame("ColorSelect")
  2.  
  3. --GetSmudgeColorRGB function
  4. --arg1: color table in RGB {r=0,g=0,b=0}
  5. --arg2: color table in RGB {r=1,g=1,b=1}
  6. --arg3: percentage 0-1
  7. function CS:GetSmudgeColorRGB(colorA,colorB,percentage)
  8.   self:SetColorRGB(colorA.r, colorA.g, colorA.b)
  9.   colorA.h, colorA.s, colorA.v = self:GetColorHSV()
  10.   self:SetColorRGB(colorB.r, colorB.g, colorB.b)
  11.   colorB.h, colorB.s, colorB.v = self:GetColorHSV()
  12.   local colorC = {}
  13.   --check if the angle between the two H values is > 180
  14.   if abs(colorA.h-colorB.h) > 180 then
  15.     local angle = (360-abs(colorA.h-colorB.h))*percentage
  16.     if colorA.h < colorB.h then
  17.       colorC.h = floor(colorA.h-angle)
  18.       if colorC.h < 0 then
  19.         colorC.h = 360+colorC.h
  20.       end
  21.     else
  22.       colorC.h = floor(colorA.h+angle)
  23.       if colorC.h > 360 then
  24.         colorC.h = colorC.h-360
  25.       end
  26.     end
  27.   else
  28.     colorC.h = floor(colorA.h-(colorA.h-colorB.h)*percentage)
  29.   end    
  30.   colorC.s = colorA.s-(colorA.s-colorB.s)*percentage
  31.   colorC.v = colorA.v-(colorA.v-colorB.v)*percentage
  32.   self:SetColorHSV(colorC.h, colorC.s, colorC.v)
  33.   colorC.r, colorC.g, colorC.b = self:GetColorRGB()
  34.   return colorC
  35. end
  36.  
  37. --GetSmudgeColorRGB function call
  38. local color = CS:GetSmudgeColorRGB({r=1,g=0,b=0}, {r=0,g=1,b=0}, 0.5)
SVN:
http://code.google.com/p/rothui/sour....0/ColorSmudge
50400.02
- color smudge will now use the shortest path between two colors

50400.01
- initial release
Optional Files (0)


Archived Files (1)
File Name
Version
Size
Author
Date
50400.01
2kB
zork
09-26-13 01:15 PM


Post A Reply Comment Options
Old 09-27-13, 02:10 AM  
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view AddOns

Forum posts: 1308
File comments: 3288
Uploads: 84
--upodated-----

Fixed the drycode.

Lua Code:
  1. if abs(self.colorA.h-self.colorB.h) > 180 then
  2.       local radius = (360-abs(self.colorA.h-self.colorB.h))*self.percentage/100
  3.       --calculate the 360 breakpoint
  4.       if self.colorA.h < self.colorB.h then
  5.         self.colorC.h = floor(self.colorA.h-radius)
  6.         if self.colorC.h < 0 then
  7.           self.colorC.h = 360+self.colorC.h
  8.         end
  9.       else
  10.         self.colorC.h = floor(self.colorA.h+radius)
  11.         if self.colorC.h > 360 then
  12.           self.colorC.h = self.colorC.h-360
  13.         end
  14.       end
  15.     else
  16.       self.colorC.h = floor(self.colorA.h-(self.colorA.h-self.colorB.h)*self.percentage/100)
  17.     end
__________________
| Simple is beautiful.
| Roth UI | Roth UI FAQ | GoogleCode | Zork | TDMOG

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
Last edited by zork : 09-28-13 at 05:27 AM.
zork is offline Report comment to moderator  
Reply With Quote
Old 09-27-13, 04:30 PM  
suicidalkatt
A Rage Talon Dragon Guard
 
suicidalkatt's Avatar
AddOn Author - Click to view AddOns

Forum posts: 309
File comments: 1377
Uploads: 60
Does perfectly!

Thanks for your work!
suicidalkatt is offline Report comment to moderator  
Reply With Quote
Old 10-01-13, 08:38 AM  
zork
A Pyroguard Emberseer
 
zork's Avatar
AddOn Author - Click to view AddOns

Forum posts: 1308
File comments: 3288
Uploads: 84
Some functions
Lua Code:
  1. --color lib
  2. local CS = CreateFrame("ColorSelect")
  3.  
  4. --ConvertColorRgbToHsv
  5. function ConvertColorRgbToHsv(color)
  6.   CS:SetColorRGB(color.r, color.g, color.b)
  7.   local h,s,v = CS:GetColorHSV()
  8.   return {h=h,s=s,v=v}
  9. end
  10.  
  11. --ConvertColorHsvToRgb
  12. function ConvertColorHsvToRgb(color)
  13.   CS:SetColorHSV(color.h, color.s, color.v)
  14.   local r,g,b = CS:GetColorRGB()
  15.   return {r=r,g=g,b=b}
  16. end
  17.  
  18. --CalculateNewColor
  19. function CalculateNewColor(colorA,colorB,percentage)
  20.   local colorC = {}
  21.   --check if the angle between the two H values is > 180
  22.   if abs(colorA.h-colorB.h) > 180 then
  23.     local angle = (360-abs(colorA.h-colorB.h))*percentage
  24.     if colorA.h < colorB.h then
  25.       colorC.h = floor(colorA.h-angle)
  26.       if colorC.h < 0 then
  27.         colorC.h = 360+colorC.h
  28.       end
  29.     else
  30.       colorC.h = floor(colorA.h+angle)
  31.       if colorC.h > 360 then
  32.         colorC.h = colorC.h-360
  33.       end
  34.     end
  35.   else
  36.     colorC.h = floor(colorA.h-(colorA.h-colorB.h)*percentage)
  37.   end    
  38.   colorC.s = colorA.s-(colorA.s-colorB.s)*percentage
  39.   colorC.v = colorA.v-(colorA.v-colorB.v)*percentage
  40.   return colorC
  41. end
  42.  
  43. --GetSmudgeColor
  44. function GetSmudgeColor(colorA,colorB,percentage)
  45.   if colorA.r then
  46.     return ConvertColorHsvToRgb(CalculateNewColor(ConvertColorRgbToHsv(colorA),ConvertColorRgbToHsv(colorB),percentage))
  47.   elseif colorA.h then
  48.     return CalculateNewColor(colorA,colorB,percentage)  
  49.   end
  50.   return nil
  51. end
  52.  
  53. --function call
  54. local color = GetSmudgeColor({r=1,g=0,b=0}, {r=0,g=1,b=0}, 0.5)
__________________
| Simple is beautiful.
| Roth UI | Roth UI FAQ | GoogleCode | Zork | TDMOG

"I wonder what the non-pathetic people are doing tonight?" - Rajesh Koothrappali (The Big Bang Theory)
Last edited by zork : 10-22-13 at 02:04 AM.
zork is offline Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: