Sha256: 8728fd2b4815c596202552e5497c0870f550db276409714a9d9a1067e22bad37
Contents?: true
Size: 1.97 KB
Versions: 11
Compression:
Stored size: 1.97 KB
Contents
require_relative 'helper' class TestGraphicsContext < Test::Unit::TestCase P = Processing G = P::Graphics def graphics(w = 10, h = 10) G.new w, h end def test_colorMode() g = graphics assert_equal G::RGB, g.colorMode g.colorMode G::HSB, 1 assert_equal G::HSB, g.colorMode assert_raise {g.colorMode LEFT} end def test_angleMode() g = graphics assert_equal G::RADIANS, g.angleMode g.angleMode G::DEGREES assert_equal G::DEGREES, g.angleMode assert_raise {g.angleMode LEFT} end def test_blendMode() g = graphics assert_equal G::BLEND, g.blendMode g.blendMode G::ADD assert_equal G::ADD, g.blendMode assert_raise {g.blendMode LEFT} end def test_color() g = graphics g.colorMode G::RGB, 255 c = g.color 10, 20, 30, 40 assert_equal 0x280a141e, c assert_equal [10, 20, 30, 40], [g.red(c), g.green(c), g.blue(c), g.alpha(c)] g.colorMode G::RGB, 1.0 c = g.color 0.1, 0.2, 0.3, 0.4 assert_equal 0x6619334c, c assert_in_delta 0.1, g.red(c), 1 / 256.0 assert_in_delta 0.2, g.green(c), 1 / 256.0 assert_in_delta 0.3, g.blue(c), 1 / 256.0 assert_in_delta 0.4, g.alpha(c), 1 / 256.0 end def test_lerp() g = graphics assert_equal 1.0, g.lerp(1.0, 2.0, 0.0) assert_equal 1.5, g.lerp(1.0, 2.0, 0.5) assert_equal 2.0, g.lerp(1.0, 2.0, 1.0) assert_equal 0.9, g.lerp(1.0, 2.0, -0.1) assert_equal 2.1, g.lerp(1.0, 2.0, 1.1) end def test_lerpColor() g = graphics c = -> red, green, blue {g.color red, green, blue} assert_equal c[10, 20, 30], g.lerpColor(c[10, 20, 30], c[50, 60, 70], 0.0) assert_equal c[30, 40, 50], g.lerpColor(c[10, 20, 30], c[50, 60, 70], 0.5) assert_equal c[50, 60, 70], g.lerpColor(c[10, 20, 30], c[50, 60, 70], 1.0) assert_equal c[-10, 0, 10], g.lerpColor(c[10, 20, 30], c[50, 60, 70], -0.5) assert_equal c[ 70, 80, 90], g.lerpColor(c[10, 20, 30], c[50, 60, 70], 1.5) end end# TestGraphics
Version data entries
11 entries across 11 versions & 1 rubygems