class Colors::XYZ
Constants
- EPSILON
- KAPPA
Attributes
Public Class Methods
Source
# File lib/colors/xyz.rb, line 9 def initialize(x, y, z) @x, @y, @z = canonicalize(x, y, z) end
Public Instance Methods
Source
# File lib/colors/xyz.rb, line 19 def ==(other) case other when XYZ x == other.x && y == other.y && z == other.z else super end end
Calls superclass method
Source
# File lib/colors/xyz.rb, line 36 def luv_components(wp) yy = y/wp.y uu, vv = uv_values l = if yy <= EPSILON KAPPA * yy else 116 * Math.cbrt(yy).to_r - 16 end if l <= 1e-8 u = v = 0r else wp_u, wp_v = wp.uv_values u = 13*l*(uu - wp_u) v = 13*l*(vv - wp_v) end [l, u, v] end
Source
# File lib/colors/xyz.rb, line 32 def rgb_components Convert.xyz_to_rgb(x, y, z) end
Source
# File lib/colors/xyz.rb, line 54 def uv_values d = x + 15*y + 3*z return [0r, 0r] if d == 0 u = 4*x / d v = 9*y / d [u, v] end
Private Instance Methods
Source
# File lib/colors/xyz.rb, line 62 def canonicalize(x, y, z) [ Rational(x), Rational(y), Rational(z) ] end