Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. --PALETTE Adjust: Shift Hue v0.9
  2. --by Richard Fhager
  3. --http://hem.fyristorg.com/dawnbringer/
  4.  
  5. -- Copyright 2010 Richard Fhager
  6. --
  7. -- This program is free software; you can redistribute it and/or
  8. -- modify it under the terms of the GNU General Public License
  9. -- as published by the Free Software Foundation; version 2
  10. -- of the License. See <http://www.gnu.org/licenses/>
  11.  
  12. -- This script was adopted from Evalion, a Javascript codecrafting/imageprocessing project
  13. -- http://goto.glocalnet.net/richard_fhager/evalion/evalion.html
  14.  
  15.  
  16. --Shift_degrees = 45
  17.  
  18. OK,Shift_degrees = inputbox("Shift Hue v0.9","Degrees", 45, 0,360,3);
  19.  
  20.  
  21. --
  22. function shiftHUE(r,g,b,deg) -- V1.3 R.Fhager 2007, adopted from Evalion
  23.  local c,h,mi,mx,d,s,p,i,f,q,t
  24.  c = {g,b,r}
  25.  mi = math.min(r,g,b)
  26.  mx = math.max(r,g,b); v = mx;
  27.  d = mx - mi;
  28.  s = 0; if mx ~= 0 then s = d/mx; end
  29.  p = 1; if g ~= mx then p = 2; if b ~= mx then p = 0; end; end
  30.  
  31.  if s~=0 then
  32.   h=(deg/60+(6+p*2+(c[1+p]-c[1+(p+1)%3])/d))%6;
  33.   i=math.floor(h);
  34.   f=h-i;
  35.   p=v*(1-s);
  36.   q=v*(1-s*f);
  37.   t=v*(1-s*(1-f));
  38.   c={v,q,p,p,t,v}
  39.   r = c[1+i]
  40.   g = c[1+(i+4)%6]
  41.   b = c[1+(i+2)%6]
  42.  end
  43.  
  44.  return r,g,b
  45. end
  46. --
  47.  
  48. if OK == true then
  49.  
  50.   for c = 0, 255, 1 do
  51.     r,g,b = getcolor(c)
  52.     setcolor(c, shiftHUE(r,g,b,Shift_degrees))
  53.   end
  54.  
  55. end