Advertisement
Loadus

Inkscape - SoftLight Inverse effect

Apr 3rd, 2011
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.72 KB | None | 0 0
  1. import coloreffect
  2. import math
  3.  
  4. class C(coloreffect.ColorEffect):
  5.   def colmod(self,r,g,b):
  6.     l = (max(r,g,b)+min(r,g,b))/2
  7.    
  8.     l = float(l) / 255
  9.     r = float(r) / 255
  10.     g = float(g) / 255
  11.     b = float(b) / 255
  12.  
  13.     l = 1 - l
  14.  
  15.     if l < 0.5:
  16.       r = (2 * l - 1) * (r - r * r) + r
  17.     else:
  18.       r = (2 * l - 1) * (math.sqrt(r) - r) + r
  19.  
  20.     if l < 0.5:
  21.       g = (2 * l - 1) * (g - g * g) + g
  22.     else:
  23.       g = (2 * l - 1) * (math.sqrt(g) - g) + g
  24.  
  25.     if l < 0.5:
  26.       b = (2 * l - 1) * (b - b * b) + b
  27.     else:
  28.       b = (2 * l - 1) * (math.sqrt(b) - b) + b
  29.  
  30.     r = int(r * 255)
  31.     g = int(g * 255)
  32.     b = int(b * 255)
  33.  
  34.     return '%02x%02x%02x' % (r,g,b)
  35.  
  36. c = C()
  37. c.affect()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement