How to use the segno.colors.color_to_rgb function in segno

To help you get started, we’ve selected a few segno examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github heuer / segno / tests / test_cli_colorful.py View on Github external
fn = _make_tmp_png_filename()
    res = cli.main(['--quiet-zone=green', '--finder-dark=purple', '--finder-light=yellow', '--output={0}'.format(fn), 'test'])
    with open(fn, 'rb') as f:
        data = io.BytesIO(f.read())
    os.unlink(fn)
    assert 0 == res
    reader = PNGReader(file=data)
    reader.preamble()
    assert not reader.greyscale
    palette = reader.palette()
    assert 5 == len(palette)
    assert (0, 0, 0) in palette
    assert (255, 255, 255) in palette
    assert colors.color_to_rgb('green') in palette
    assert colors.color_to_rgb('purple') in palette
    assert colors.color_to_rgb('yellow') in palette
github heuer / segno / tests / test_colors.py View on Github external
def test_valid_colornames(name, expected):
    rgb = colors.color_to_rgb(name)
    assert 3 == len(rgb)
    assert expected == rgb
github heuer / segno / tests / test_colors.py View on Github external
def test_illegal2():
    with pytest.raises(ValueError):
        colors.color_to_rgb((1, 2, 3, 256))
github heuer / segno / tests / test_colors.py View on Github external
def test_valid_hexcodes_rgb(name, expected):
    rgb = colors.color_to_rgb(name)
    assert 3 == len(rgb)
    assert expected == rgb
github heuer / segno / tests / test_png_colorful.py View on Github external
def test_plte_colors():
    qr = segno.make_qr('test')
    buff = io.BytesIO()
    dark = (0, 0, 139)
    light = (255, 255, 255)
    qr.save(buff, kind='png', dark=dark, light=light, quiet_zone='green',
            finder_dark='purple', finder_light='yellow')
    buff.seek(0)
    reader = PNGReader(file=buff)
    reader.preamble()
    assert not reader.greyscale
    palette = reader.palette()
    assert 5 == len(palette)
    assert dark in palette
    assert light in palette
    assert colors.color_to_rgb('green') in palette
    assert colors.color_to_rgb('purple') in palette
    assert colors.color_to_rgb('yellow') in palette
github heuer / segno / tests / test_cli_colorful.py View on Github external
def test_plte_colors():
    fn = _make_tmp_png_filename()
    res = cli.main(['--quiet-zone=green', '--finder-dark=purple', '--finder-light=yellow', '--output={0}'.format(fn), 'test'])
    with open(fn, 'rb') as f:
        data = io.BytesIO(f.read())
    os.unlink(fn)
    assert 0 == res
    reader = PNGReader(file=data)
    reader.preamble()
    assert not reader.greyscale
    palette = reader.palette()
    assert 5 == len(palette)
    assert (0, 0, 0) in palette
    assert (255, 255, 255) in palette
    assert colors.color_to_rgb('green') in palette
    assert colors.color_to_rgb('purple') in palette
    assert colors.color_to_rgb('yellow') in palette
github heuer / segno / tests / test_colors.py View on Github external
def test_illegal3():
    with pytest.raises(ValueError):
        colors.color_to_rgb((300, 300, 300))
github heuer / segno / tests / test_colors.py View on Github external
def test_illegal5():
    with pytest.raises(ValueError):
        colors.color_to_rgb((256, 0, 0))
github heuer / segno / tests / test_colors.py View on Github external
def test_illegal():
    with pytest.raises(ValueError):
        colors.color_to_rgb('unknown')