Sha256: 84364aaeaa21cc867958d0564c3950a4f5e20f9728786536bdfd402fcca118a6
Contents?: true
Size: 495 Bytes
Versions: 2
Compression:
Stored size: 495 Bytes
Contents
module ChunkyPNG::Color # See http://en.wikipedia.org/wiki/Hue#Computing_hue_from_RGB def self.hue(pixel) r, g, b = r(pixel), g(pixel), b(pixel) return 0 if r == b and b == g ((180 / Math::PI * Math.atan2((2 * r) - g - b, Math.sqrt(3) * (g - b))) - 90) % 360 end # The modular distance, as the hue is circular def self.distance(pixel, poxel) hue_pixel, hue_poxel = hue(pixel), hue(poxel) [(hue_pixel - hue_poxel) % 360, (hue_poxel - hue_pixel) % 360].min end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
camalian-0.0.3 | lib/chunky_png_patch/color.rb |
camalian-0.0.2 | lib/chunky_png_patch/color.rb |