File: test_525_transparency.py

package info (click to toggle)
ezdxf 1.4.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 104,528 kB
  • sloc: python: 182,341; makefile: 116; lisp: 20; ansic: 4
file content (34 lines) | stat: -rw-r--r-- 739 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#  Copyright (c) 2021, Manfred Moitzi
#  License: MIT License

import pytest
from ezdxf import colors

# DXF transparency value 0x020000TT
# 0x00 = fully transparent
# 0xff = opaque


@pytest.mark.parametrize("t_int, t_float", [
    (0x02000000, 1.0),
    (0x0200007F, 0.5),
    (0x020000FF, 0.0),
    (0, 1.0),
    (127, 0.5),
    (255, 0.0),
])
def test_transparency_to_float(t_int, t_float):
    assert round(colors.transparency2float(t_int), 2) == t_float


@pytest.mark.parametrize("t_int, t_float", [
    (0x02000000, 1.0),
    (0x0200007F, 0.5),
    (0x020000FF, 0.0),
])
def test_float_to_transparency(t_int, t_float):
    assert colors.float2transparency(t_float) == t_int


if __name__ == '__main__':
    pytest.main([__file__])