Skip to content

Commit

Permalink
Merge pull request #7 from felix-d/update-hsluv
Browse files Browse the repository at this point in the history
Update HSLUV to latest version
  • Loading branch information
boronine authored Dec 8, 2023
2 parents 18b838c + 9f445db commit 80c8e4c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion hsluv.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Gem::Specification.new do |spec|
spec.name = 'hsluv'
spec.version = '1.0.1'
spec.version = '1.0.2'
spec.authors = ['Radu-Bogdan Croitoru', 'HSLuv Contributors']
spec.email = ['[email protected]', '[email protected]']

Expand Down
18 changes: 13 additions & 5 deletions lib/hsluv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,18 @@ def xyz_to_luv (arr)

def luv_to_lch (arr)
l, u, v = arr
c = ((u ** 2) + (v ** 2)) ** (1 / 2.0)
hrad = Math.atan2(v, u)
h = radians_to_degrees(hrad)
h += 360.0 if h < 0.0

c = Math.sqrt(u * u + v * v)

h = if c < 0.00000001
0.0
else
hrad = Math.atan2(v, u)
h = hrad * 180.0 / Math::PI
h += 360.0 if h < 0.0
h
end

[l, c, h]
end

Expand Down Expand Up @@ -271,4 +279,4 @@ def dot_product (a, b)
def rgb_prepare (arr)
arr.map! { |ch| ch = ch.round(3); ch = [0, ch].max; ch = [1, ch].min; (ch * 255).round }
end
end
end
1 change: 0 additions & 1 deletion spec/fixtures/snapshot-rev3.json

This file was deleted.

1 change: 1 addition & 0 deletions spec/fixtures/snapshot-rev4.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion spec/hsluv_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
describe Hsluv do

describe 'snapshot' do
snapshot = JSON.parse(File.read('spec/fixtures/snapshot-rev3.json'))
snapshot = JSON.parse(File.read('spec/fixtures/snapshot-rev4.json'))

snapshot.each do |block|
hex = block.first
Expand Down

0 comments on commit 80c8e4c

Please sign in to comment.