forked from adafruit/circuitpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbitmaptools_blit_boundaries.py
More file actions
75 lines (63 loc) · 1.91 KB
/
bitmaptools_blit_boundaries.py
File metadata and controls
75 lines (63 loc) · 1.91 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import displayio
import bitmaptools
src_bmp = displayio.Bitmap(10, 10, 2)
src_bmp.fill(1)
dest_bmp = displayio.Bitmap(10, 10, 2)
dest_bmp.fill(0)
# valid values, non-zero size
bitmaptools.blit(dest_bmp, src_bmp, x=0, y=0, x1=0, y1=0, x2=2, y2=2)
print("blit 1 successful")
# valid values, zero width (no effect)
bitmaptools.blit(dest_bmp, src_bmp, x=5, y=5, x1=1, y1=1, x2=1, y2=6)
print("blit 2 successful")
# valid values, zero height (no effect)
bitmaptools.blit(dest_bmp, src_bmp, x=5, y=5, x1=1, y1=1, x2=2, y2=1)
print("blit 3 successful")
try:
# invalid values, x too large
bitmaptools.blit(dest_bmp, src_bmp, x=20, y=5)
print("blit 4 successful")
except ValueError as e:
print(f"Error: {e}")
try:
# invalid values, y too large
bitmaptools.blit(dest_bmp, src_bmp, x=5, y=25)
print("blit 5 successful")
except ValueError as e:
print(f"Error: {e}")
try:
# invalid values, x2 too large
bitmaptools.blit(dest_bmp, src_bmp, x=5, y=5, x1=0, y1=0, x2=12, y2=5)
print("blit 6 successful")
except ValueError as e:
print(f"Error: {e}")
try:
# invalid values, x2 too small
bitmaptools.blit(dest_bmp, src_bmp, x=5, y=5, x1=3, y1=3, x2=0, y2=5)
print("blit 7 successful")
except ValueError as e:
print(f"Error: {e}")
try:
# invalid values, y2 too small
bitmaptools.blit(dest_bmp, src_bmp, x=5, y=5, x1=3, y1=3, x2=5, y2=0)
print("blit 8 successful")
except ValueError as e:
print(f"Error: {e}")
try:
# invalid values, y2 too large
bitmaptools.blit(dest_bmp, src_bmp, x=5, y=5, x1=3, y1=3, x2=5, y2=20)
print("blit 9 successful")
except ValueError as e:
print(f"Error: {e}")
# import board
# p = displayio.Palette(2)
# p[0] = 0xffffff
# p[1] = 0x0000ff
# dest_tg = displayio.TileGrid(bitmap=dest_bmp, pixel_shader=p)
#
# main_group = displayio.Group(scale=5)
# main_group.append(dest_tg)
#
# board.DISPLAY.root_group = main_group
# while True:
# pass