Sha256: 6bc06988d09e736700211e489e5a67a8032cbe4545d74653e7ffa230be5f3003
Contents?: true
Size: 1.86 KB
Versions: 1
Compression:
Stored size: 1.86 KB
Contents
require "minitest/spec" require "minitest/autorun" require 'rcade_colors' describe Rcade::Color do it 'can create black from hex' do c = Rcade::Color.from_hex('000000') [c.red, c.green, c.blue, c.alpha].must_equal [0,0,0,255] c = Rcade::Color.from_hex('000') [c.red, c.green, c.blue, c.alpha].must_equal [0,0,0,255] c = Rcade::Color.from_hex('#000000') [c.red, c.green, c.blue, c.alpha].must_equal [0,0,0,255] c = Rcade::Color.from_hex('#000') [c.red, c.green, c.blue, c.alpha].must_equal [0,0,0,255] end it 'can create white from hex' do c = Rcade::Color.from_hex('ffffff') [c.red, c.green, c.blue, c.alpha].must_equal [255,255,255,255] c = Rcade::Color.from_hex('fff') [c.red, c.green, c.blue, c.alpha].must_equal [255,255,255,255] c = Rcade::Color.from_hex('#ffffff') [c.red, c.green, c.blue, c.alpha].must_equal [255,255,255,255] c = Rcade::Color.from_hex('#fff') [c.red, c.green, c.blue, c.alpha].must_equal [255,255,255,255] c = Rcade::Color.from_hex('fFf') # case shouldnt matter [c.red, c.green, c.blue, c.alpha].must_equal [255,255,255,255] end it 'can create red from hex' do c = Rcade::Color.from_hex('ff0000') [c.red, c.green, c.blue, c.alpha].must_equal [255,0,0,255] c = Rcade::Color.from_hex('f00') [c.red, c.green, c.blue, c.alpha].must_equal [255,0,0,255] c = Rcade::Color.from_hex('#ff0000') [c.red, c.green, c.blue, c.alpha].must_equal [255,0,0,255] c = Rcade::Color.from_hex('#f00') [c.red, c.green, c.blue, c.alpha].must_equal [255,0,0,255] end it 'can modify opacity' do c = Rcade::Color.from_hex('#f00').opacity(0) [c.red, c.green, c.blue, c.alpha].must_equal [255,0,0,0] color = Rcade::Color.from_hex('#f00').opacity(1) color.alpha.must_equal(255) color = Rcade::Color.from_hex('#f00').opacity(0.5) color.alpha.must_equal(127) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rcade_colors-0.0.5 | test/rcade_colors_test.rb |