Ejemplo n.º 1
0
def test_dot_encode_colordepth1():
    dot = Dot()
    dot.encode([1])
    assert dot.getChannels() == (1.0, 1.0, 1.0)

    dot.encode([0])
    assert dot.getChannels() == (0.0, 0.0, 0.0)
Ejemplo n.º 2
0
def test_dot_decode_colordepth2():
    dot = Dot()

    dot.decode(ColorChannels(1.0, 1.0, 1.0), 2)
    assert dot.bitList == [0, 0]

    dot.decode(ColorChannels(0.0, 1.0, 1.0), 2)
    assert dot.bitList == [1, 0]

    dot.decode(ColorChannels(1.0, 1.0, 0.0), 2)
    assert dot.bitList == [1, 1]

    dot.decode(ColorChannels(0, 63.0 / MaxColorVal, 63.0 / MaxColorVal), 4)
    assert dot.bitList == [1, 1, 0, 0]
Ejemplo n.º 3
0
def test_dot_decode_colordepth1():
    dot = Dot()

    dot.decode(ColorChannels(1.0, 1.0, 1.0), 1)
    assert dot.bitList == [1]

    dot.decode(ColorChannels(0.0, 0.0, 0.0), 1)
    assert dot.bitList == [0]

    dot.decode(
        ColorChannels(94.0 / MaxColorVal, 94.0 / MaxColorVal,
                      94.0 / MaxColorVal), 7)
    assert dot.bitList == [1, 1, 1, 1, 0, 1, 0]
Ejemplo n.º 4
0
def test_dotByte_decode():
    dotByte = DotByte()
    dot = Dot()

    c = ColorChannels(1.0, 1.0, 1.0)
    dotByte.decode([c] * Constants.ByteSize, 1)
    assert dotByte.bytesList == [0xFF]

    c = ColorChannels(1.0, 1.0, 0.0)
    dotByte.decode([c] * Constants.ByteSize, 2)
    assert dotByte.bytesList == [0xFF, 0xFF]

    c = ColorChannels(1.0, 1.0, 1.0)
    dotByte.decode([c] * Constants.ByteSize, 3)
    assert dotByte.bytesList == [0xFF, 0xFF, 0xFF]

    c = ColorChannels(1.0, 1.0 / 3.0, 0.0)
    dotByte.decode([c] * Constants.ByteSize, 6)
    assert dotByte.bytesList == [0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00]
Ejemplo n.º 5
0
def test_dot_decode_colordepth3():
    dot = Dot()

    dot.decode(ColorChannels(0, 0, 0), 3)
    assert dot.bitList == [0, 0, 0]

    dot.decode(ColorChannels(1.0, 0, 1.0), 3)
    assert dot.bitList == [1, 0, 1]

    dot.decode(ColorChannels(1.0, 1.0, 1.0), 3)
    assert dot.bitList == [1, 1, 1]

    dot.decode(ColorChannels(1.0 / 3.0, 0.0, 1.0), 6)
    assert dot.bitList == [1, 0, 0, 0, 1, 1]

    dot.decode(ColorChannels(1.0, 1.0, 1.0), 9)
    assert dot.bitList == [1, 1, 1, 1, 1, 1, 1, 1, 1]
Ejemplo n.º 6
0
def test_dot_encode_colordepth3():
    dot = Dot()

    dot.encode([0, 0, 0])
    assert dot.getChannels() == (0.0, 0.0, 0.0)

    dot.encode([1, 0, 1])
    assert dot.getChannels() == (1.0, 0.0, 1.0)

    dot.encode([1, 1, 1])
    assert dot.getChannels() == (1.0, 1.0, 1.0)

    dot.encode([1, 0, 0, 0, 1, 1])
    assert dot.getChannels() == (85.0 / MaxColorVal, 0, 1.0)

    dot.encode([1, 1, 1, 1, 1, 1, 1, 1, 1])
    assert dot.getChannels() == (1.0, 1.0, 1.0)
Ejemplo n.º 7
0
def test_dot_encode_colordepth2():
    dot = Dot()

    # White
    dot.encode([0, 0])
    assert dot.getChannels() == (1.0, 1.0, 1.0)

    # Magenta
    dot.encode([0, 1])
    assert dot.getChannels() == (1.0, 0.0, 1.0)

    # Cyan
    dot.encode([1, 0])
    assert dot.getChannels() == (0, 1.0, 1.0)

    # Yellow
    dot.encode([1, 1])
    assert dot.getChannels() == (1.0, 1.0, 0)

    dot.encode([1, 1, 0, 0])
    assert dot.getChannels() == (0, 1.0 / 3.0, 1.0 / 3.0)
Ejemplo n.º 8
0
def test_dot_encode_colordepth2():
    dot = Dot()

    dot.encode([0, 0])
    assert dot.getChannels() == (1.0, 1.0, 1.0)

    dot.encode([1, 0])
    assert dot.getChannels() == (0, 1.0, 1.0)

    dot.encode([1, 1])
    assert dot.getChannels() == (1.0, 1.0, 0)

    dot.encode([1, 1, 0, 0])
    assert dot.getChannels() == (0, 1.0 / 3.0, 1.0 / 3.0)