omnipython-iconkit 0.1.0.dev3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- iconkit/__init__.py +112 -0
- iconkit/__init__.pyi +20 -0
- iconkit/_a8_24.py +404 -0
- iconkit/_a8_48.py +116 -0
- iconkit/gfx.py +89 -0
- iconkit/gfx.pyi +17 -0
- iconkit/icons_24.txt +149 -0
- iconkit/icons_48.txt +36 -0
- iconkit/lvicons.py +72 -0
- iconkit/lvicons.pyi +12 -0
- iconkit/py.typed +0 -0
- omnipython_iconkit-0.1.0.dev3.dist-info/METADATA +165 -0
- omnipython_iconkit-0.1.0.dev3.dist-info/RECORD +17 -0
- omnipython_iconkit-0.1.0.dev3.dist-info/WHEEL +5 -0
- omnipython_iconkit-0.1.0.dev3.dist-info/licenses/LICENSE +21 -0
- omnipython_iconkit-0.1.0.dev3.dist-info/licenses/LICENSE-ICONS +202 -0
- omnipython_iconkit-0.1.0.dev3.dist-info/top_level.txt +1 -0
iconkit/gfx.py
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""Draw an iconkit icon with pygraphics, or into an RGB565 buffer.
|
|
5
|
+
|
|
6
|
+
Example::
|
|
7
|
+
|
|
8
|
+
from iconkit import gfx
|
|
9
|
+
|
|
10
|
+
gfx.draw(display, "home", 10, 10, 0xFFFF)
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
import iconkit
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def draw(fb, name, x, y, color, size=24):
|
|
17
|
+
"""Blend icon *name* in *color* over what *fb* already shows at (*x*, *y*).
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
fb: A pygraphics ``FrameBuffer`` (or a display) with ``blit_alpha``.
|
|
21
|
+
name (str): A Material icon name.
|
|
22
|
+
x (int): Left edge.
|
|
23
|
+
y (int): Top edge.
|
|
24
|
+
color (int): The colour, in *fb*'s pixel format.
|
|
25
|
+
size (int): 24 or 48, or the size of a module added with `iconkit.add`.
|
|
26
|
+
|
|
27
|
+
Raises:
|
|
28
|
+
AttributeError: *fb* has no ``blit_alpha``; install a newer pygraphics.
|
|
29
|
+
ValueError: There is no such icon at that size.
|
|
30
|
+
"""
|
|
31
|
+
blit = getattr(fb, "blit_alpha", None)
|
|
32
|
+
if blit is None:
|
|
33
|
+
raise AttributeError(
|
|
34
|
+
"%s has no blit_alpha(): iconkit needs a newer pygraphics (FrameBuffer.blit_alpha). "
|
|
35
|
+
"Update pygraphics, or use iconkit.gfx.rgb565() to blend into a buffer yourself." % type(fb).__name__
|
|
36
|
+
)
|
|
37
|
+
data, w, h = iconkit.mask(name, size)
|
|
38
|
+
blit(data, x, y, w, h, color)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _split(c, what):
|
|
42
|
+
if not 0 <= c <= 0xFFFF:
|
|
43
|
+
raise ValueError("%s %r is not an RGB565 value (0 to 0xFFFF)" % (what, c))
|
|
44
|
+
return (c >> 11) << 3 | (c >> 13), ((c >> 5) & 0x3F) << 2 | ((c >> 9) & 3), (c & 0x1F) << 3 | ((c >> 2) & 7)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def rgb565(name, color, bg, size=24, buf=None):
|
|
48
|
+
"""Icon *name* in *color* blended onto a flat *bg*, as RGB565, low byte first. Swap the bytes if your panel wants the other order.
|
|
49
|
+
|
|
50
|
+
For displays with no framebuffer: send the result to the panel. Pass the
|
|
51
|
+
returned buffer back as *buf* to reuse it for another icon of the same size.
|
|
52
|
+
|
|
53
|
+
Args:
|
|
54
|
+
name (str): A Material icon name.
|
|
55
|
+
color (int): The icon colour as RGB565.
|
|
56
|
+
bg (int): The flat background colour as RGB565.
|
|
57
|
+
size (int): 24 or 48, or the size of a module added with `iconkit.add`.
|
|
58
|
+
buf (bytearray): Optional, ``size * size * 2`` bytes, to fill in place.
|
|
59
|
+
|
|
60
|
+
Returns:
|
|
61
|
+
The buffer, ``size * size * 2`` bytes.
|
|
62
|
+
|
|
63
|
+
Raises:
|
|
64
|
+
ValueError: *buf* is the wrong length, a colour is out of range, or there is no such icon.
|
|
65
|
+
"""
|
|
66
|
+
data, w, h = iconkit.mask(name, size)
|
|
67
|
+
need = w * h * 2
|
|
68
|
+
if buf is None:
|
|
69
|
+
buf = bytearray(need)
|
|
70
|
+
elif len(buf) != need:
|
|
71
|
+
raise ValueError("buf is %d bytes; a %d px icon needs %d" % (len(buf), size, need))
|
|
72
|
+
fr, fg, fb_ = _split(color, "color")
|
|
73
|
+
br, bgr, bb = _split(bg, "bg")
|
|
74
|
+
j = 0
|
|
75
|
+
for a in data:
|
|
76
|
+
if a == 255:
|
|
77
|
+
px = color
|
|
78
|
+
elif a == 0:
|
|
79
|
+
px = bg
|
|
80
|
+
else:
|
|
81
|
+
b = 255 - a
|
|
82
|
+
r = (fr * a + br * b) // 255
|
|
83
|
+
g = (fg * a + bgr * b) // 255
|
|
84
|
+
bl = (fb_ * a + bb * b) // 255
|
|
85
|
+
px = ((r >> 3) << 11) | ((g >> 2) << 5) | (bl >> 3)
|
|
86
|
+
buf[j] = px & 0xFF
|
|
87
|
+
buf[j + 1] = px >> 8
|
|
88
|
+
j += 2
|
|
89
|
+
return buf
|
iconkit/gfx.pyi
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""Draw an iconkit icon with pygraphics, or into an RGB565 buffer."""
|
|
5
|
+
|
|
6
|
+
from typing import Protocol
|
|
7
|
+
|
|
8
|
+
class _AlphaBlitter(Protocol):
|
|
9
|
+
def blit_alpha(self, data: memoryview, x: int, y: int, w: int, h: int, color: int) -> None: ...
|
|
10
|
+
|
|
11
|
+
def draw(fb: _AlphaBlitter, name: str, x: int, y: int, color: int, size: int = 24) -> None:
|
|
12
|
+
"""Blend icon `name` in `color` over what `fb` already shows at (`x`, `y`)."""
|
|
13
|
+
|
|
14
|
+
def rgb565(
|
|
15
|
+
name: str, color: int, bg: int, size: int = 24, buf: bytearray | None = None
|
|
16
|
+
) -> bytearray:
|
|
17
|
+
"""Icon `name` in `color` blended onto a flat `bg`, as RGB565, low byte first."""
|
iconkit/icons_24.txt
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# General-purpose icons, 24 px: the app tile icons first (they are also in
|
|
2
|
+
# icons_48.txt), then the rest.
|
|
3
|
+
|
|
4
|
+
# App tile icons, 48 px. Every name here is also in icons_24.txt.
|
|
5
|
+
# Current apps
|
|
6
|
+
photo_camera
|
|
7
|
+
speaker
|
|
8
|
+
cast
|
|
9
|
+
schedule
|
|
10
|
+
image_search
|
|
11
|
+
child_care
|
|
12
|
+
doorbell
|
|
13
|
+
phone_in_talk
|
|
14
|
+
camera_outdoor
|
|
15
|
+
videocam
|
|
16
|
+
video_call
|
|
17
|
+
record_voice_over
|
|
18
|
+
library_music
|
|
19
|
+
audio_file
|
|
20
|
+
settings_remote
|
|
21
|
+
security
|
|
22
|
+
queue_music
|
|
23
|
+
tune
|
|
24
|
+
instant_mix
|
|
25
|
+
piano
|
|
26
|
+
settings
|
|
27
|
+
mic
|
|
28
|
+
wb_sunny
|
|
29
|
+
# Apps to come
|
|
30
|
+
photo_library
|
|
31
|
+
calculate
|
|
32
|
+
timer
|
|
33
|
+
alarm
|
|
34
|
+
calendar_today
|
|
35
|
+
thermostat
|
|
36
|
+
folder
|
|
37
|
+
terminal
|
|
38
|
+
sports_esports
|
|
39
|
+
language
|
|
40
|
+
|
|
41
|
+
# Shell
|
|
42
|
+
home
|
|
43
|
+
close
|
|
44
|
+
arrow_back
|
|
45
|
+
more_vert
|
|
46
|
+
menu
|
|
47
|
+
check
|
|
48
|
+
done
|
|
49
|
+
add
|
|
50
|
+
remove
|
|
51
|
+
delete
|
|
52
|
+
edit
|
|
53
|
+
search
|
|
54
|
+
refresh
|
|
55
|
+
apps
|
|
56
|
+
account_circle
|
|
57
|
+
|
|
58
|
+
# Navigation
|
|
59
|
+
arrow_forward
|
|
60
|
+
arrow_upward
|
|
61
|
+
arrow_downward
|
|
62
|
+
chevron_left
|
|
63
|
+
chevron_right
|
|
64
|
+
expand_more
|
|
65
|
+
expand_less
|
|
66
|
+
sync
|
|
67
|
+
swap_horiz
|
|
68
|
+
filter_list
|
|
69
|
+
|
|
70
|
+
# Media
|
|
71
|
+
play_arrow
|
|
72
|
+
play_circle
|
|
73
|
+
pause
|
|
74
|
+
stop
|
|
75
|
+
skip_next
|
|
76
|
+
skip_previous
|
|
77
|
+
fast_forward
|
|
78
|
+
fast_rewind
|
|
79
|
+
fiber_manual_record
|
|
80
|
+
repeat
|
|
81
|
+
shuffle
|
|
82
|
+
volume_up
|
|
83
|
+
volume_down
|
|
84
|
+
volume_off
|
|
85
|
+
volume_mute
|
|
86
|
+
mic_off
|
|
87
|
+
headphones
|
|
88
|
+
music_note
|
|
89
|
+
equalizer
|
|
90
|
+
|
|
91
|
+
# Connectivity and device
|
|
92
|
+
wifi
|
|
93
|
+
wifi_off
|
|
94
|
+
network_wifi_1_bar
|
|
95
|
+
network_wifi_2_bar
|
|
96
|
+
network_wifi_3_bar
|
|
97
|
+
network_wifi
|
|
98
|
+
signal_wifi_0_bar
|
|
99
|
+
bluetooth
|
|
100
|
+
bluetooth_connected
|
|
101
|
+
bluetooth_disabled
|
|
102
|
+
battery_full
|
|
103
|
+
battery_0_bar
|
|
104
|
+
battery_1_bar
|
|
105
|
+
battery_2_bar
|
|
106
|
+
battery_3_bar
|
|
107
|
+
battery_4_bar
|
|
108
|
+
battery_5_bar
|
|
109
|
+
battery_6_bar
|
|
110
|
+
battery_charging_full
|
|
111
|
+
usb
|
|
112
|
+
sd_card
|
|
113
|
+
memory
|
|
114
|
+
sensors
|
|
115
|
+
developer_board
|
|
116
|
+
cable
|
|
117
|
+
cloud
|
|
118
|
+
cloud_off
|
|
119
|
+
share
|
|
120
|
+
|
|
121
|
+
# Files and editing
|
|
122
|
+
folder_open
|
|
123
|
+
save
|
|
124
|
+
upload
|
|
125
|
+
download
|
|
126
|
+
content_copy
|
|
127
|
+
content_cut
|
|
128
|
+
content_paste
|
|
129
|
+
undo
|
|
130
|
+
redo
|
|
131
|
+
|
|
132
|
+
# Alerts and status
|
|
133
|
+
warning
|
|
134
|
+
error
|
|
135
|
+
info
|
|
136
|
+
help
|
|
137
|
+
notifications
|
|
138
|
+
star
|
|
139
|
+
favorite
|
|
140
|
+
|
|
141
|
+
# Controls
|
|
142
|
+
keyboard
|
|
143
|
+
lock
|
|
144
|
+
lock_open
|
|
145
|
+
visibility
|
|
146
|
+
visibility_off
|
|
147
|
+
light_mode
|
|
148
|
+
dark_mode
|
|
149
|
+
power_settings_new
|
iconkit/icons_48.txt
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# App tile icons, 48 px. Every name here is also in icons_24.txt.
|
|
2
|
+
# Current apps
|
|
3
|
+
photo_camera
|
|
4
|
+
speaker
|
|
5
|
+
cast
|
|
6
|
+
schedule
|
|
7
|
+
image_search
|
|
8
|
+
child_care
|
|
9
|
+
doorbell
|
|
10
|
+
phone_in_talk
|
|
11
|
+
camera_outdoor
|
|
12
|
+
videocam
|
|
13
|
+
video_call
|
|
14
|
+
record_voice_over
|
|
15
|
+
library_music
|
|
16
|
+
audio_file
|
|
17
|
+
settings_remote
|
|
18
|
+
security
|
|
19
|
+
queue_music
|
|
20
|
+
tune
|
|
21
|
+
instant_mix
|
|
22
|
+
piano
|
|
23
|
+
settings
|
|
24
|
+
mic
|
|
25
|
+
wb_sunny
|
|
26
|
+
# Apps to come
|
|
27
|
+
photo_library
|
|
28
|
+
calculate
|
|
29
|
+
timer
|
|
30
|
+
alarm
|
|
31
|
+
calendar_today
|
|
32
|
+
thermostat
|
|
33
|
+
folder
|
|
34
|
+
terminal
|
|
35
|
+
sports_esports
|
|
36
|
+
language
|
iconkit/lvicons.py
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""Show an iconkit icon in LVGL.
|
|
5
|
+
|
|
6
|
+
LVGL draws an 8-bit alpha image in its recolor colour, so an icon is one image
|
|
7
|
+
object with the colour you want. The pixels stay where they are, in the frozen
|
|
8
|
+
module's flash.
|
|
9
|
+
|
|
10
|
+
Example::
|
|
11
|
+
|
|
12
|
+
import lvgl as lv
|
|
13
|
+
from iconkit import lvicons
|
|
14
|
+
|
|
15
|
+
lvicons.image(lv.screen_active(), "settings", size=48, color=lv.color_hex(0x40A0FF))
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
import lvgl as lv
|
|
19
|
+
|
|
20
|
+
import iconkit
|
|
21
|
+
|
|
22
|
+
# (size, name) -> the image descriptor. LVGL keeps a pointer to it, not a
|
|
23
|
+
# reference, so this dict is what keeps it alive.
|
|
24
|
+
_dsc = {}
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def dsc(name, size=24):
|
|
28
|
+
"""The ``lv.image_dsc_t`` for icon *name*, built once and kept alive.
|
|
29
|
+
|
|
30
|
+
Args:
|
|
31
|
+
name (str): A Material icon name.
|
|
32
|
+
size (int): 24 or 48, or the size of a module added with `iconkit.add`.
|
|
33
|
+
|
|
34
|
+
Raises:
|
|
35
|
+
ValueError: There is no such icon at that size.
|
|
36
|
+
"""
|
|
37
|
+
key = (size, name)
|
|
38
|
+
d = _dsc.get(key)
|
|
39
|
+
if d is None:
|
|
40
|
+
data, w, h = iconkit.mask(name, size)
|
|
41
|
+
d = lv.image_dsc_t()
|
|
42
|
+
d.header.magic = lv.IMAGE_HEADER_MAGIC
|
|
43
|
+
d.header.cf = lv.COLOR_FORMAT.A8
|
|
44
|
+
d.header.w = w
|
|
45
|
+
d.header.h = h
|
|
46
|
+
d.header.stride = w
|
|
47
|
+
d.data_size = len(data)
|
|
48
|
+
d.data = data
|
|
49
|
+
_dsc[key] = (d, data)
|
|
50
|
+
return d
|
|
51
|
+
return d[0]
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def image(parent, name, size=24, color=None):
|
|
55
|
+
"""An ``lv.image`` showing icon *name* in *color*.
|
|
56
|
+
|
|
57
|
+
Args:
|
|
58
|
+
parent: The LVGL object to put it on.
|
|
59
|
+
name (str): A Material icon name.
|
|
60
|
+
size (int): 24 or 48, or the size of a module added with `iconkit.add`.
|
|
61
|
+
color: An ``lv.color_t``; white when left out.
|
|
62
|
+
|
|
63
|
+
Returns:
|
|
64
|
+
The ``lv.image``. Call ``set_style_image_recolor`` on it to change the colour.
|
|
65
|
+
"""
|
|
66
|
+
if color is None:
|
|
67
|
+
color = lv.color_white()
|
|
68
|
+
img = lv.image(parent)
|
|
69
|
+
img.set_src(dsc(name, size))
|
|
70
|
+
img.set_style_image_recolor(color, 0)
|
|
71
|
+
img.set_style_image_recolor_opa(255, 0)
|
|
72
|
+
return img
|
iconkit/lvicons.pyi
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Brad Barnett
|
|
2
|
+
#
|
|
3
|
+
# SPDX-License-Identifier: MIT
|
|
4
|
+
"""Show an iconkit icon in LVGL."""
|
|
5
|
+
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
def dsc(name: str, size: int = 24) -> Any:
|
|
9
|
+
"""The `lv.image_dsc_t` for icon `name`, built once and kept alive."""
|
|
10
|
+
|
|
11
|
+
def image(parent: Any, name: str, size: int = 24, color: Any = None) -> Any:
|
|
12
|
+
"""An `lv.image` showing icon `name` in `color` (an `lv.color_t`; white when omitted)."""
|
iconkit/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: omnipython-iconkit
|
|
3
|
+
Version: 0.1.0.dev3
|
|
4
|
+
Summary: Material Design icons as flash-resident alpha masks, drawn in LVGL or pygraphics
|
|
5
|
+
Author: Brad Barnett
|
|
6
|
+
License-Expression: MIT AND Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/PyDevices/omnipython/tree/main/packages/iconkit
|
|
8
|
+
Project-URL: Issues, https://github.com/PyDevices/omnipython/issues
|
|
9
|
+
Keywords: icons,material,lvgl,micropython,circuitpython
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: Programming Language :: Python :: Implementation :: MicroPython
|
|
12
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
13
|
+
Requires-Python: >=3.8
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
License-File: LICENSE-ICONS
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+

|
|
20
|
+
|
|
21
|
+
# iconkit
|
|
22
|
+
|
|
23
|
+
iconkit is the part of OmniPython that gives a program Material Design icons as
|
|
24
|
+
antialiased 8-bit alpha masks. Frozen into MicroPython-compatible firmware, an
|
|
25
|
+
icon lives in flash and costs no RAM, and it draws in LVGL or in pygraphics on
|
|
26
|
+
MicroPython-compatible boards, CircuitPython-compatible boards and CPython.
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ omnipython-iconkit
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
On a board, freeze it: `include("/path/to/omnipython/packages/iconkit")` from your
|
|
33
|
+
firmware's `manifest.py`. Without freezing, the masks load into RAM when
|
|
34
|
+
imported, so freeze them on a board that is short of it.
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
import iconkit
|
|
38
|
+
|
|
39
|
+
print(len(iconkit.names(24)), "icons at 24 px,", len(iconkit.names(48)), "at 48 px")
|
|
40
|
+
|
|
41
|
+
# A mask is w * h alpha bytes, row by row. Print every other row as text.
|
|
42
|
+
data, w, h = iconkit.mask("home", 24)
|
|
43
|
+
for y in range(0, h, 2):
|
|
44
|
+
row = data[y * w:(y + 1) * w]
|
|
45
|
+
print("".join(" .:#"[a * 4 // 256] for a in row))
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```text
|
|
49
|
+
129 icons at 24 px, 33 at 48 px
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
:##:
|
|
53
|
+
########
|
|
54
|
+
############
|
|
55
|
+
.################.
|
|
56
|
+
##############
|
|
57
|
+
##### #####
|
|
58
|
+
##### #####
|
|
59
|
+
##### #####
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The picture at the top of this page is the 48 px set. Every icon in both sets is
|
|
65
|
+
on the [contact sheets](docs/reference/icons.md).
|
|
66
|
+
|
|
67
|
+
[Docs](docs/reference/icons.md) · [Examples](https://gallery.omnipython.org/pyscript/) · [Roadmap](ROADMAP.md)
|
|
68
|
+
|
|
69
|
+
OmniPython is made by [PyDevices](https://pydevices.com).
|
|
70
|
+
|
|
71
|
+
## The icons
|
|
72
|
+
|
|
73
|
+
Two sets ship, filled style, from Google's
|
|
74
|
+
[Material Design Icons](https://github.com/google/material-design-icons) (Apache
|
|
75
|
+
License 2.0, [LICENSE-ICONS](LICENSE-ICONS)):
|
|
76
|
+
|
|
77
|
+
- 24 px: 129 general-purpose icons (72.6 KB), listed in [icons_24.txt](lib/iconkit/icons_24.txt).
|
|
78
|
+
- 48 px: 33 app-tile icons (74.3 KB), listed in [icons_48.txt](lib/iconkit/icons_48.txt). All 33 are in the 24 px set too.
|
|
79
|
+
|
|
80
|
+
Names are Material's own (`home`, `wifi`, `battery_charging_full`). WiFi
|
|
81
|
+
strength comes as `network_wifi_1_bar`, `network_wifi_2_bar`,
|
|
82
|
+
`network_wifi_3_bar` and `network_wifi`.
|
|
83
|
+
|
|
84
|
+
## Draw an icon
|
|
85
|
+
|
|
86
|
+
In LVGL, an icon is an `lv.image` in the colour you give it:
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
import lvgl as lv
|
|
90
|
+
from iconkit import lvicons
|
|
91
|
+
|
|
92
|
+
lvicons.image(lv.screen_active(), "settings", size=48, color=lv.color_hex(0x40A0FF))
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
In pygraphics, `draw` blends the icon over what the framebuffer already shows.
|
|
96
|
+
It needs a pygraphics with `FrameBuffer.blit_alpha`, and raises without it:
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
from iconkit import gfx
|
|
100
|
+
|
|
101
|
+
gfx.draw(display, "home", 10, 10, 0xFFFF)
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
A display with no framebuffer can take the icon blended onto a flat background
|
|
105
|
+
as an RGB565 buffer: `gfx.rgb565("home", color, bg)`. Pass the returned buffer
|
|
106
|
+
back as `buf=` to reuse it.
|
|
107
|
+
|
|
108
|
+
`iconkit.mask("home")` gives the raw `(data, w, h)` for anything else: `data` is
|
|
109
|
+
a memoryview of `w * h` alpha bytes, row by row.
|
|
110
|
+
|
|
111
|
+
An unknown name or size raises `ValueError` and lists what exists.
|
|
112
|
+
|
|
113
|
+
## Your own icons
|
|
114
|
+
|
|
115
|
+
[tools/make_icons.py](tools/make_icons.py) builds a module in the same format from
|
|
116
|
+
any Material icon names. It needs Pillow and a Material Design Icons checkout,
|
|
117
|
+
which you name on the command line:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
python tools/make_icons.py path/to/material-design-icons --size 24 \
|
|
121
|
+
--names home,wifi,sd_card --out myicons.py
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Put `myicons.py` in your app and register it:
|
|
125
|
+
|
|
126
|
+
```python
|
|
127
|
+
import iconkit
|
|
128
|
+
import myicons
|
|
129
|
+
|
|
130
|
+
iconkit.add(myicons)
|
|
131
|
+
iconkit.mask("sd_card")
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
A name that another module of the same size already has raises `ValueError`.
|
|
135
|
+
`--names-file` takes a list with one name per line and `#` comments, and
|
|
136
|
+
`--budget 72k` fails the run when the masks outgrow a size you set.
|
|
137
|
+
|
|
138
|
+
## Fetch only the icons you need
|
|
139
|
+
|
|
140
|
+
The full repository is several gigabytes. A sparse checkout fetches just the PNGs
|
|
141
|
+
of one size:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
git clone --filter=blob:none --depth 1 --no-checkout https://github.com/google/material-design-icons.git
|
|
145
|
+
cd material-design-icons
|
|
146
|
+
git sparse-checkout set --no-cone /LICENSE '/png/*/*/materialicons/24dp/1x/'
|
|
147
|
+
git checkout
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Some newer icons, such as `instant_mix`, exist only as Material Symbols. For a
|
|
151
|
+
name with no PNG, the generator draws the filled Outlined symbol's SVG instead,
|
|
152
|
+
which needs `pip install resvg-py`. Add each one to the checkout by name:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
git sparse-checkout add '/symbols/web/instant_mix/materialsymbolsoutlined/'
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
That downloads about 125 MB (git's pack of the file listing, plus the 2,170 icons
|
|
159
|
+
at 24 px, which are 430 KB themselves). Git still writes an index of the whole
|
|
160
|
+
tree, so expect about 800 MB on disk. Each further size is one more pattern, and
|
|
161
|
+
adds 2,170 files and about 0.7 MB:
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
git sparse-checkout add '/png/*/*/materialicons/48dp/1x/'
|
|
165
|
+
```
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
iconkit/__init__.py,sha256=qv167JWOdwEbAh8Y7E84Sx2Da1PYfY0TcWxN_wAESWQ,3593
|
|
2
|
+
iconkit/__init__.pyi,sha256=QIpCE83IxW5mvWS4mcYF85wq6ndnr9S-DXHecd4vbkk,687
|
|
3
|
+
iconkit/_a8_24.py,sha256=pY4s1lvDvG2L2vQ2uny5IKIwPHJ4Y8fwEhawGyl7YU8,297351
|
|
4
|
+
iconkit/_a8_48.py,sha256=sRYIED-a8hC0o9iU3ds4Yofz_-fZZBnXzegKeC6mV9k,302398
|
|
5
|
+
iconkit/gfx.py,sha256=4soiW3o98uYHLmOlSJg-PAy8x46bsHS74d1dKNiT8Z0,3072
|
|
6
|
+
iconkit/gfx.pyi,sha256=Iw48jiUwjarFGwgRkv5gREQKurzwpgr4pAv5ojH2Gbc,680
|
|
7
|
+
iconkit/icons_24.txt,sha256=tAqmCdvAWi3k7SshPhGbrVkHTRpoBnRTEyF1NpPd9EM,1670
|
|
8
|
+
iconkit/icons_48.txt,sha256=mUXFYaVi2j33OnoLrOsmC15t2PWYVHUG0wdJkMhw7uE,440
|
|
9
|
+
iconkit/lvicons.py,sha256=SEeKzvL-8J2BQVKVtUSFMi5Iw6wO7C2QvYLGyW457qU,2004
|
|
10
|
+
iconkit/lvicons.pyi,sha256=p1rFUnzJ0OfkYBy5zUNH1L7RfUYDDmDYFbqPh7uMXlA,428
|
|
11
|
+
iconkit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
|
+
omnipython_iconkit-0.1.0.dev3.dist-info/licenses/LICENSE,sha256=Lz3BwVosdrO0zJ8ByYHOxLanmqcHRItdEp7wKfgpXQ8,1069
|
|
13
|
+
omnipython_iconkit-0.1.0.dev3.dist-info/licenses/LICENSE-ICONS,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
|
14
|
+
omnipython_iconkit-0.1.0.dev3.dist-info/METADATA,sha256=OiGgqdqv-xPDv1ROWp2GVGzUzpl-j6Xxzo4C5VY7CKU,5675
|
|
15
|
+
omnipython_iconkit-0.1.0.dev3.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
16
|
+
omnipython_iconkit-0.1.0.dev3.dist-info/top_level.txt,sha256=K_opQCdX4qDbsAGodimOVZQ4issDa3vHsln2OyDpr0Q,8
|
|
17
|
+
omnipython_iconkit-0.1.0.dev3.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Brad Barnett
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|