Minion Beta! - Help us test our new AddOn updater. Get it now!
(2 Kb)
Updated: 09-27-13 09:28 AM
Pictures
File Info
 Updated: 09-27-13 09:28 AM Created: 09-26-13 01:15 PM Downloads: 495 Favorites: 1 MD5:

# 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:
`local CS = CreateFrame("ColorSelect") --GetSmudgeColorRGB function--arg1: color table in RGB {r=0,g=0,b=0}--arg2: color table in RGB {r=1,g=1,b=1}--arg3: percentage 0-1function CS:GetSmudgeColorRGB(colorA,colorB,percentage)  self:SetColorRGB(colorA.r, colorA.g, colorA.b)  colorA.h, colorA.s, colorA.v = self:GetColorHSV()  self:SetColorRGB(colorB.r, colorB.g, colorB.b)  colorB.h, colorB.s, colorB.v = self:GetColorHSV()  local colorC = {}  --check if the angle between the two H values is > 180  if abs(colorA.h-colorB.h) > 180 then    local angle = (360-abs(colorA.h-colorB.h))*percentage    if colorA.h < colorB.h then      colorC.h = floor(colorA.h-angle)      if colorC.h < 0 then        colorC.h = 360+colorC.h      end    else      colorC.h = floor(colorA.h+angle)      if colorC.h > 360 then        colorC.h = colorC.h-360      end    end  else    colorC.h = floor(colorA.h-(colorA.h-colorB.h)*percentage)  end      colorC.s = colorA.s-(colorA.s-colorB.s)*percentage  colorC.v = colorA.v-(colorA.v-colorB.v)*percentage  self:SetColorHSV(colorC.h, colorC.s, colorC.v)  colorC.r, colorC.g, colorC.b = self:GetColorRGB()  return colorCend --GetSmudgeColorRGB function calllocal color = CS:GetSmudgeColorRGB({r=1,g=0,b=0}, {r=0,g=1,b=0}, 0.5)`
SVN:

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

 Comment Options
10-01-13, 08:38 AM
zork
A Pyroguard Emberseer

Forum posts: 1417
Some functions
Lua Code:
`--color liblocal CS = CreateFrame("ColorSelect") --ConvertColorRgbToHsvfunction ConvertColorRgbToHsv(color)  CS:SetColorRGB(color.r, color.g, color.b)  local h,s,v = CS:GetColorHSV()  return {h=h,s=s,v=v}end --ConvertColorHsvToRgbfunction ConvertColorHsvToRgb(color)  CS:SetColorHSV(color.h, color.s, color.v)  local r,g,b = CS:GetColorRGB()  return {r=r,g=g,b=b}end --CalculateNewColorfunction CalculateNewColor(colorA,colorB,percentage)  local colorC = {}  --check if the angle between the two H values is > 180  if abs(colorA.h-colorB.h) > 180 then    local angle = (360-abs(colorA.h-colorB.h))*percentage    if colorA.h < colorB.h then      colorC.h = floor(colorA.h-angle)      if colorC.h < 0 then        colorC.h = 360+colorC.h      end    else      colorC.h = floor(colorA.h+angle)      if colorC.h > 360 then        colorC.h = colorC.h-360      end    end  else    colorC.h = floor(colorA.h-(colorA.h-colorB.h)*percentage)  end      colorC.s = colorA.s-(colorA.s-colorB.s)*percentage  colorC.v = colorA.v-(colorA.v-colorB.v)*percentage  return colorCend --GetSmudgeColorfunction GetSmudgeColor(colorA,colorB,percentage)  if colorA.r then    return ConvertColorHsvToRgb(CalculateNewColor(ConvertColorRgbToHsv(colorA),ConvertColorRgbToHsv(colorB),percentage))  elseif colorA.h then    return CalculateNewColor(colorA,colorB,percentage)    end  return nilend --function calllocal color = GetSmudgeColor({r=1,g=0,b=0}, {r=0,g=1,b=0}, 0.5)`
__________________
| Simple is beautiful.
| Roth UI | Roth UI FAQ | GitHub | 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.

 09-27-13, 04:30 PM suicidalkatt A Rage Talon Dragon Guard   Forum posts: 326 File comments: 1427 Uploads: 62 Does perfectly! Thanks for your work! __________________ -->> The Ultimate Shaman UI - Official Thread <<--
09-27-13, 02:10 AM
zork
A Pyroguard Emberseer

Forum posts: 1417
--upodated-----

Fixed the drycode.

Lua Code:
`if abs(self.colorA.h-self.colorB.h) > 180 then      local radius = (360-abs(self.colorA.h-self.colorB.h))*self.percentage/100      --calculate the 360° breakpoint      if self.colorA.h < self.colorB.h then        self.colorC.h = floor(self.colorA.h-radius)        if self.colorC.h < 0 then          self.colorC.h = 360+self.colorC.h        end      else        self.colorC.h = floor(self.colorA.h+radius)        if self.colorC.h > 360 then          self.colorC.h = self.colorC.h-360        end      end    else      self.colorC.h = floor(self.colorA.h-(self.colorA.h-self.colorB.h)*self.percentage/100)    end`
__________________
| Simple is beautiful.
| Roth UI | Roth UI FAQ | GitHub | 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.

Category Jump: