quantumgui 1.0.0__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.
- quantumgui/__init__.py +9 -0
- quantumgui/__main__.py +6 -0
- quantumgui/cli.py +341 -0
- quantumgui/core/__init__.py +39 -0
- quantumgui/core/animation.py +221 -0
- quantumgui/core/audit.py +323 -0
- quantumgui/core/context.py +54 -0
- quantumgui/core/data_source.py +426 -0
- quantumgui/core/draw.py +428 -0
- quantumgui/core/enterprise.py +402 -0
- quantumgui/core/enterprise_app.py +419 -0
- quantumgui/core/events.py +34 -0
- quantumgui/core/geometry.py +108 -0
- quantumgui/core/native_dialogs.py +276 -0
- quantumgui/core/pdf_report.py +390 -0
- quantumgui/core/rules.py +284 -0
- quantumgui/core/state.py +42 -0
- quantumgui/core/task_runner.py +181 -0
- quantumgui/core/widget.py +498 -0
- quantumgui/core/window.py +920 -0
- quantumgui/core/xlsx_export.py +145 -0
- quantumgui/py.typed +0 -0
- quantumgui/theme/__init__.py +32 -0
- quantumgui/theme/hct.py +191 -0
- quantumgui/theme/theme.py +93 -0
- quantumgui/theme/tokens.py +423 -0
- quantumgui/ui.py +2142 -0
- quantumgui/widgets/__init__.py +168 -0
- quantumgui/widgets/advanced.py +499 -0
- quantumgui/widgets/button.py +224 -0
- quantumgui/widgets/charts.py +625 -0
- quantumgui/widgets/charts_bi.py +528 -0
- quantumgui/widgets/charts_extra.py +430 -0
- quantumgui/widgets/charts_pro.py +568 -0
- quantumgui/widgets/checkbox.py +199 -0
- quantumgui/widgets/chip.py +219 -0
- quantumgui/widgets/containers.py +321 -0
- quantumgui/widgets/data_controls.py +487 -0
- quantumgui/widgets/data_grid.py +956 -0
- quantumgui/widgets/data_table.py +551 -0
- quantumgui/widgets/date_picker.py +407 -0
- quantumgui/widgets/display_media.py +372 -0
- quantumgui/widgets/display_pro.py +407 -0
- quantumgui/widgets/drawer.py +252 -0
- quantumgui/widgets/enterprise_controls.py +934 -0
- quantumgui/widgets/fab.py +261 -0
- quantumgui/widgets/forms_pro.py +703 -0
- quantumgui/widgets/forms_pro_media.py +587 -0
- quantumgui/widgets/inputs.py +870 -0
- quantumgui/widgets/layout_pro.py +162 -0
- quantumgui/widgets/list_view.py +307 -0
- quantumgui/widgets/masked_input.py +131 -0
- quantumgui/widgets/master_detail.py +155 -0
- quantumgui/widgets/navigation.py +382 -0
- quantumgui/widgets/overlays.py +355 -0
- quantumgui/widgets/productivity.py +500 -0
- quantumgui/widgets/productivity_boards.py +544 -0
- quantumgui/widgets/radio.py +209 -0
- quantumgui/widgets/scroll_view.py +129 -0
- quantumgui/widgets/select.py +373 -0
- quantumgui/widgets/sheets.py +249 -0
- quantumgui/widgets/slider.py +209 -0
- quantumgui/widgets/switch.py +196 -0
- quantumgui/widgets/tabs.py +175 -0
- quantumgui/widgets/text.py +101 -0
- quantumgui/widgets/text_field.py +490 -0
- quantumgui/widgets/time_picker.py +499 -0
- quantumgui-1.0.0.dist-info/METADATA +137 -0
- quantumgui-1.0.0.dist-info/RECORD +73 -0
- quantumgui-1.0.0.dist-info/WHEEL +5 -0
- quantumgui-1.0.0.dist-info/entry_points.txt +2 -0
- quantumgui-1.0.0.dist-info/licenses/LICENSE +32 -0
- quantumgui-1.0.0.dist-info/top_level.txt +1 -0
quantumgui/core/draw.py
ADDED
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
"""Skia Material Design 3 drawing primitives, typography cache, and vector icons."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import math
|
|
6
|
+
from functools import lru_cache
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
import skia
|
|
10
|
+
|
|
11
|
+
from ..theme import Color, ELEVATION_DP, ShapeToken, TextStyle, Theme
|
|
12
|
+
from .animation import RippleController
|
|
13
|
+
from .geometry import Rect
|
|
14
|
+
|
|
15
|
+
ColorSpec = Color | str
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def resolve_color(spec: ColorSpec | None, theme: Theme, fallback: Color | None = None) -> Color | None:
|
|
19
|
+
"""Resolve a Color, `#hex` string, or M3 ColorScheme token name (e.g. 'primary')."""
|
|
20
|
+
if spec is None:
|
|
21
|
+
return fallback
|
|
22
|
+
if isinstance(spec, Color):
|
|
23
|
+
return spec
|
|
24
|
+
s = str(spec).strip()
|
|
25
|
+
if s.startswith("#"):
|
|
26
|
+
return Color.from_hex(s)
|
|
27
|
+
if hasattr(theme.colors, s):
|
|
28
|
+
val = getattr(theme.colors, s)
|
|
29
|
+
if isinstance(val, Color):
|
|
30
|
+
return val
|
|
31
|
+
return Color.from_hex(s)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def make_rrect_spec(rect: Rect, spec: ShapeToken | float | tuple[float, float, float, float], theme: Theme) -> skia.RRect:
|
|
35
|
+
"""Create a Skia RRect from a ShapeToken, uniform float radius, or 4-corner `(tl, tr, br, bl)` tuple."""
|
|
36
|
+
if isinstance(spec, tuple) and len(spec) == 4:
|
|
37
|
+
max_r = min(rect.width * 0.5, rect.height * 0.5)
|
|
38
|
+
tl, tr, br, bl = (min(float(v), max_r) for v in spec)
|
|
39
|
+
rr = skia.RRect()
|
|
40
|
+
rr.setRectRadii(
|
|
41
|
+
skia.Rect.MakeXYWH(rect.x, rect.y, rect.width, rect.height),
|
|
42
|
+
[(tl, tl), (tr, tr), (br, br), (bl, bl)],
|
|
43
|
+
)
|
|
44
|
+
return rr
|
|
45
|
+
rad = theme.shape.resolve(spec)
|
|
46
|
+
return make_rrect(rect, rad)
|
|
47
|
+
|
|
48
|
+
_CUSTOM_TYPEFACES: dict[str, skia.Typeface] = {}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def register_font(path: str | Path, alias: str | None = None) -> str:
|
|
52
|
+
"""Load a `.ttf` or `.otf` font file into Skia and return its family alias."""
|
|
53
|
+
font_path = Path(path)
|
|
54
|
+
if not font_path.is_file():
|
|
55
|
+
raise FileNotFoundError(f"Font file not found: {font_path}")
|
|
56
|
+
tf = skia.Typeface.MakeFromFile(str(font_path))
|
|
57
|
+
if tf is None:
|
|
58
|
+
raise ValueError(f"Skia could not decode font file: {font_path}")
|
|
59
|
+
name = alias or tf.getFamilyName() or font_path.stem
|
|
60
|
+
_CUSTOM_TYPEFACES[name] = tf
|
|
61
|
+
get_typeface.cache_clear()
|
|
62
|
+
get_font.cache_clear()
|
|
63
|
+
return name
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
@lru_cache(maxsize=32)
|
|
67
|
+
def get_typeface(family: str, weight: int = 400) -> skia.Typeface:
|
|
68
|
+
if family in _CUSTOM_TYPEFACES:
|
|
69
|
+
return _CUSTOM_TYPEFACES[family]
|
|
70
|
+
style = skia.FontStyle(
|
|
71
|
+
int(weight),
|
|
72
|
+
skia.FontStyle.kNormal_Width,
|
|
73
|
+
skia.FontStyle.kUpright_Slant,
|
|
74
|
+
)
|
|
75
|
+
tf = skia.Typeface(family, style)
|
|
76
|
+
if tf is None:
|
|
77
|
+
tf = skia.Typeface.MakeDefault()
|
|
78
|
+
return tf
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
@lru_cache(maxsize=128)
|
|
82
|
+
def get_font(family: str, size: float, weight: int = 400) -> skia.Font:
|
|
83
|
+
tf = get_typeface(family, weight)
|
|
84
|
+
font = skia.Font(tf, float(size))
|
|
85
|
+
font.setSubpixel(True)
|
|
86
|
+
font.setEdging(skia.Font.Edging.kAntiAlias)
|
|
87
|
+
return font
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def font_for_style(family: str, style: TextStyle) -> skia.Font:
|
|
91
|
+
return get_font(family, style.size, style.weight)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def measure_text(font: skia.Font, text: str) -> float:
|
|
95
|
+
if not text:
|
|
96
|
+
return 0.0
|
|
97
|
+
return float(font.measureText(text))
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def draw_text_centered_y(
|
|
101
|
+
canvas: skia.Canvas,
|
|
102
|
+
text: str,
|
|
103
|
+
x: float,
|
|
104
|
+
center_y: float,
|
|
105
|
+
font: skia.Font,
|
|
106
|
+
color: Color,
|
|
107
|
+
) -> None:
|
|
108
|
+
if not text:
|
|
109
|
+
return
|
|
110
|
+
metrics = font.getMetrics()
|
|
111
|
+
# Vertically center cap-height / ascent-descent nicely
|
|
112
|
+
baseline = center_y - (metrics.fAscent + metrics.fDescent) * 0.5
|
|
113
|
+
paint = skia.Paint(AntiAlias=True, Color=color.to_skia())
|
|
114
|
+
canvas.drawString(text, float(x), float(baseline), font, paint)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def make_rrect(rect: Rect, radius: float) -> skia.RRect:
|
|
118
|
+
r = min(float(radius), rect.width * 0.5, rect.height * 0.5)
|
|
119
|
+
return skia.RRect.MakeRectXY(
|
|
120
|
+
skia.Rect.MakeXYWH(rect.x, rect.y, rect.width, rect.height),
|
|
121
|
+
r,
|
|
122
|
+
r,
|
|
123
|
+
)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def draw_elevation_shadow(
|
|
127
|
+
canvas: skia.Canvas,
|
|
128
|
+
rect: Rect,
|
|
129
|
+
radius: float,
|
|
130
|
+
elevation_level: int,
|
|
131
|
+
shadow_color: Color,
|
|
132
|
+
) -> None:
|
|
133
|
+
"""Draw Material Design 3 ambient + key drop shadow for elevation levels 1..5."""
|
|
134
|
+
level = max(0, min(5, int(elevation_level)))
|
|
135
|
+
if level == 0:
|
|
136
|
+
return
|
|
137
|
+
dp = ELEVATION_DP[level]
|
|
138
|
+
|
|
139
|
+
# Ambient shadow
|
|
140
|
+
ambient_rrect = make_rrect(
|
|
141
|
+
Rect(rect.x, rect.y + dp * 0.35, rect.width, rect.height),
|
|
142
|
+
radius,
|
|
143
|
+
)
|
|
144
|
+
ambient_paint = skia.Paint(
|
|
145
|
+
AntiAlias=True,
|
|
146
|
+
Color=shadow_color.with_alpha(0.10).to_skia(),
|
|
147
|
+
MaskFilter=skia.MaskFilter.MakeBlur(skia.kNormal_BlurStyle, dp * 0.9),
|
|
148
|
+
)
|
|
149
|
+
canvas.drawRRect(ambient_rrect, ambient_paint)
|
|
150
|
+
|
|
151
|
+
# Key directional shadow
|
|
152
|
+
key_rrect = make_rrect(
|
|
153
|
+
Rect(rect.x, rect.y + dp * 0.6, rect.width, rect.height),
|
|
154
|
+
radius,
|
|
155
|
+
)
|
|
156
|
+
key_paint = skia.Paint(
|
|
157
|
+
AntiAlias=True,
|
|
158
|
+
Color=shadow_color.with_alpha(0.16).to_skia(),
|
|
159
|
+
MaskFilter=skia.MaskFilter.MakeBlur(skia.kNormal_BlurStyle, dp * 0.55),
|
|
160
|
+
)
|
|
161
|
+
canvas.drawRRect(key_rrect, key_paint)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def draw_state_layer_and_ripple(
|
|
165
|
+
canvas: skia.Canvas,
|
|
166
|
+
rect: Rect,
|
|
167
|
+
radius: float,
|
|
168
|
+
layer_color: Color,
|
|
169
|
+
state_alpha: float,
|
|
170
|
+
ripple: RippleController | None,
|
|
171
|
+
now: float,
|
|
172
|
+
) -> None:
|
|
173
|
+
"""Draw M3 state layer (hover/focus/press) and clipped ink-ripple waves."""
|
|
174
|
+
if state_alpha <= 0.0 and (ripple is None or not ripple.waves):
|
|
175
|
+
return
|
|
176
|
+
|
|
177
|
+
rrect = make_rrect(rect, radius)
|
|
178
|
+
canvas.save()
|
|
179
|
+
canvas.clipRRect(rrect, doAntiAlias=True)
|
|
180
|
+
|
|
181
|
+
if state_alpha > 0.0:
|
|
182
|
+
paint = skia.Paint(
|
|
183
|
+
AntiAlias=True,
|
|
184
|
+
Color=layer_color.with_alpha(state_alpha).to_skia(),
|
|
185
|
+
)
|
|
186
|
+
canvas.drawRRect(rrect, paint)
|
|
187
|
+
|
|
188
|
+
if ripple is not None:
|
|
189
|
+
for wave in ripple.waves:
|
|
190
|
+
alpha = wave.alpha(now, base_alpha=0.14)
|
|
191
|
+
if alpha <= 0.002:
|
|
192
|
+
continue
|
|
193
|
+
r_paint = skia.Paint(
|
|
194
|
+
AntiAlias=True,
|
|
195
|
+
Color=layer_color.with_alpha(alpha).to_skia(),
|
|
196
|
+
)
|
|
197
|
+
canvas.drawCircle(
|
|
198
|
+
rect.x + wave.x,
|
|
199
|
+
rect.y + wave.y,
|
|
200
|
+
wave.radius(now),
|
|
201
|
+
r_paint,
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
canvas.restore()
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
def draw_icon(
|
|
208
|
+
canvas: skia.Canvas,
|
|
209
|
+
name: str,
|
|
210
|
+
cx: float,
|
|
211
|
+
cy: float,
|
|
212
|
+
size: float,
|
|
213
|
+
color: Color,
|
|
214
|
+
) -> None:
|
|
215
|
+
"""Draw crisp built-in Material Symbols style vector icons."""
|
|
216
|
+
s = size * 0.5
|
|
217
|
+
stroke = max(1.4, size * 0.095)
|
|
218
|
+
p = skia.Paint(
|
|
219
|
+
AntiAlias=True,
|
|
220
|
+
Color=color.to_skia(),
|
|
221
|
+
Style=skia.Paint.kStroke_Style,
|
|
222
|
+
StrokeWidth=stroke,
|
|
223
|
+
StrokeCap=skia.Paint.kRound_Cap,
|
|
224
|
+
StrokeJoin=skia.Paint.kRound_Join,
|
|
225
|
+
)
|
|
226
|
+
fill = skia.Paint(AntiAlias=True, Color=color.to_skia())
|
|
227
|
+
|
|
228
|
+
if name == "check":
|
|
229
|
+
path = skia.Path()
|
|
230
|
+
path.moveTo(cx - s * 0.58, cy + s * 0.02)
|
|
231
|
+
path.lineTo(cx - s * 0.14, cy + s * 0.46)
|
|
232
|
+
path.lineTo(cx + s * 0.60, cy - s * 0.42)
|
|
233
|
+
canvas.drawPath(path, p)
|
|
234
|
+
elif name == "close":
|
|
235
|
+
d = s * 0.5
|
|
236
|
+
canvas.drawLine(cx - d, cy - d, cx + d, cy + d, p)
|
|
237
|
+
canvas.drawLine(cx + d, cy - d, cx - d, cy + d, p)
|
|
238
|
+
elif name == "add":
|
|
239
|
+
d = s * 0.62
|
|
240
|
+
canvas.drawLine(cx - d, cy, cx + d, cy, p)
|
|
241
|
+
canvas.drawLine(cx, cy - d, cx, cy + d, p)
|
|
242
|
+
elif name == "minus":
|
|
243
|
+
d = s * 0.56
|
|
244
|
+
canvas.drawLine(cx - d, cy, cx + d, cy, p)
|
|
245
|
+
elif name == "chevron_down":
|
|
246
|
+
path = skia.Path()
|
|
247
|
+
path.moveTo(cx - s * 0.5, cy - s * 0.2)
|
|
248
|
+
path.lineTo(cx, cy + s * 0.3)
|
|
249
|
+
path.lineTo(cx + s * 0.5, cy - s * 0.2)
|
|
250
|
+
canvas.drawPath(path, p)
|
|
251
|
+
elif name == "chevron_up":
|
|
252
|
+
path = skia.Path()
|
|
253
|
+
path.moveTo(cx - s * 0.5, cy + s * 0.2)
|
|
254
|
+
path.lineTo(cx, cy - s * 0.3)
|
|
255
|
+
path.lineTo(cx + s * 0.5, cy + s * 0.2)
|
|
256
|
+
canvas.drawPath(path, p)
|
|
257
|
+
elif name == "menu":
|
|
258
|
+
for dy in (-s * 0.45, 0.0, s * 0.45):
|
|
259
|
+
canvas.drawLine(cx - s * 0.65, cy + dy, cx + s * 0.65, cy + dy, p)
|
|
260
|
+
elif name == "home":
|
|
261
|
+
path = skia.Path()
|
|
262
|
+
path.moveTo(cx - s * 0.68, cy - s * 0.05)
|
|
263
|
+
path.lineTo(cx, cy - s * 0.68)
|
|
264
|
+
path.lineTo(cx + s * 0.68, cy - s * 0.05)
|
|
265
|
+
canvas.drawPath(path, p)
|
|
266
|
+
body = skia.Path()
|
|
267
|
+
body.moveTo(cx - s * 0.48, cy - s * 0.16)
|
|
268
|
+
body.lineTo(cx - s * 0.48, cy + s * 0.62)
|
|
269
|
+
body.lineTo(cx + s * 0.48, cy + s * 0.62)
|
|
270
|
+
body.lineTo(cx + s * 0.48, cy - s * 0.16)
|
|
271
|
+
canvas.drawPath(body, p)
|
|
272
|
+
elif name == "widgets":
|
|
273
|
+
gap = s * 0.12
|
|
274
|
+
sz = s * 0.52
|
|
275
|
+
canvas.drawRoundRect(skia.Rect.MakeXYWH(cx - sz - gap, cy - sz - gap, sz, sz), 2, 2, p)
|
|
276
|
+
canvas.drawRoundRect(skia.Rect.MakeXYWH(cx + gap, cy - sz - gap, sz, sz), 2, 2, p)
|
|
277
|
+
canvas.drawRoundRect(skia.Rect.MakeXYWH(cx - sz - gap, cy + gap, sz, sz), 2, 2, p)
|
|
278
|
+
canvas.drawRoundRect(skia.Rect.MakeXYWH(cx + gap, cy + gap, sz, sz), 2, 2, p)
|
|
279
|
+
elif name == "settings":
|
|
280
|
+
canvas.drawCircle(cx, cy, s * 0.28, p)
|
|
281
|
+
canvas.drawCircle(cx, cy, s * 0.58, p)
|
|
282
|
+
elif name == "edit":
|
|
283
|
+
path = skia.Path()
|
|
284
|
+
path.moveTo(cx - s * 0.55, cy + s * 0.55)
|
|
285
|
+
path.lineTo(cx - s * 0.45, cy + s * 0.15)
|
|
286
|
+
path.lineTo(cx + s * 0.25, cy - s * 0.55)
|
|
287
|
+
path.lineTo(cx + s * 0.55, cy - s * 0.25)
|
|
288
|
+
path.lineTo(cx - s * 0.15, cy + s * 0.45)
|
|
289
|
+
path.close()
|
|
290
|
+
canvas.drawPath(path, p)
|
|
291
|
+
elif name == "info":
|
|
292
|
+
canvas.drawCircle(cx, cy, s * 0.68, p)
|
|
293
|
+
canvas.drawCircle(cx, cy - s * 0.28, s * 0.08, fill)
|
|
294
|
+
canvas.drawLine(cx, cy - s * 0.05, cx, cy + s * 0.36, p)
|
|
295
|
+
elif name == "notifications":
|
|
296
|
+
bell = skia.Path()
|
|
297
|
+
bell.moveTo(cx - s * 0.52, cy + s * 0.32)
|
|
298
|
+
bell.lineTo(cx - s * 0.42, cy - s * 0.15)
|
|
299
|
+
bell.quadTo(cx, cy - s * 0.72, cx + s * 0.42, cy - s * 0.15)
|
|
300
|
+
bell.lineTo(cx + s * 0.52, cy + s * 0.32)
|
|
301
|
+
bell.close()
|
|
302
|
+
canvas.drawPath(bell, p)
|
|
303
|
+
canvas.drawLine(cx - s * 0.16, cy + s * 0.56, cx + s * 0.16, cy + s * 0.56, p)
|
|
304
|
+
elif name == "arrow_back":
|
|
305
|
+
canvas.drawLine(cx + s * 0.6, cy, cx - s * 0.55, cy, p)
|
|
306
|
+
path = skia.Path()
|
|
307
|
+
path.moveTo(cx - s * 0.1, cy - s * 0.48)
|
|
308
|
+
path.lineTo(cx - s * 0.58, cy)
|
|
309
|
+
path.lineTo(cx - s * 0.1, cy + s * 0.48)
|
|
310
|
+
canvas.drawPath(path, p)
|
|
311
|
+
elif name == "chevron_left":
|
|
312
|
+
path = skia.Path()
|
|
313
|
+
path.moveTo(cx + s * 0.2, cy - s * 0.5)
|
|
314
|
+
path.lineTo(cx - s * 0.3, cy)
|
|
315
|
+
path.lineTo(cx + s * 0.2, cy + s * 0.5)
|
|
316
|
+
canvas.drawPath(path, p)
|
|
317
|
+
elif name == "chevron_right":
|
|
318
|
+
path = skia.Path()
|
|
319
|
+
path.moveTo(cx - s * 0.2, cy - s * 0.5)
|
|
320
|
+
path.lineTo(cx + s * 0.3, cy)
|
|
321
|
+
path.lineTo(cx - s * 0.2, cy + s * 0.5)
|
|
322
|
+
canvas.drawPath(path, p)
|
|
323
|
+
elif name == "calendar":
|
|
324
|
+
box = skia.Rect.MakeXYWH(cx - s * 0.65, cy - s * 0.52, s * 1.3, s * 1.16)
|
|
325
|
+
canvas.drawRoundRect(box, s * 0.16, s * 0.16, p)
|
|
326
|
+
canvas.drawLine(cx - s * 0.65, cy - s * 0.12, cx + s * 0.65, cy - s * 0.12, p)
|
|
327
|
+
canvas.drawLine(cx - s * 0.32, cy - s * 0.72, cx - s * 0.32, cy - s * 0.36, p)
|
|
328
|
+
canvas.drawLine(cx + s * 0.32, cy - s * 0.72, cx + s * 0.32, cy - s * 0.36, p)
|
|
329
|
+
elif name == "table":
|
|
330
|
+
box = skia.Rect.MakeXYWH(cx - s * 0.66, cy - s * 0.56, s * 1.32, s * 1.12)
|
|
331
|
+
canvas.drawRoundRect(box, s * 0.14, s * 0.14, p)
|
|
332
|
+
canvas.drawLine(cx - s * 0.66, cy - s * 0.16, cx + s * 0.66, cy - s * 0.16, p)
|
|
333
|
+
canvas.drawLine(cx - s * 0.66, cy + s * 0.22, cx + s * 0.66, cy + s * 0.22, p)
|
|
334
|
+
canvas.drawLine(cx - s * 0.12, cy - s * 0.16, cx - s * 0.12, cy + s * 0.56, p)
|
|
335
|
+
elif name == "clock":
|
|
336
|
+
canvas.drawCircle(cx, cy, s * 0.68, p)
|
|
337
|
+
canvas.drawLine(cx, cy, cx, cy - s * 0.38, p)
|
|
338
|
+
canvas.drawLine(cx, cy, cx + s * 0.28, cy + s * 0.16, p)
|
|
339
|
+
elif name == "mail":
|
|
340
|
+
r = skia.Rect.MakeXYWH(cx - s * 0.72, cy - s * 0.52, s * 1.44, s * 1.04)
|
|
341
|
+
canvas.drawRoundRect(r, s * 0.16, s * 0.16, p)
|
|
342
|
+
path = skia.Path()
|
|
343
|
+
path.moveTo(cx - s * 0.66, cy - s * 0.42)
|
|
344
|
+
path.lineTo(cx, cy + s * 0.08)
|
|
345
|
+
path.lineTo(cx + s * 0.66, cy - s * 0.42)
|
|
346
|
+
canvas.drawPath(path, p)
|
|
347
|
+
elif name == "person":
|
|
348
|
+
canvas.drawCircle(cx, cy - s * 0.32, s * 0.32, p)
|
|
349
|
+
arc = skia.Path()
|
|
350
|
+
arc.moveTo(cx - s * 0.62, cy + s * 0.62)
|
|
351
|
+
arc.quadTo(cx, cy + s * 0.06, cx + s * 0.62, cy + s * 0.62)
|
|
352
|
+
canvas.drawPath(arc, p)
|
|
353
|
+
elif name == "lock":
|
|
354
|
+
body = skia.Rect.MakeXYWH(cx - s * 0.56, cy - s * 0.05, s * 1.12, s * 0.74)
|
|
355
|
+
canvas.drawRoundRect(body, s * 0.16, s * 0.16, p)
|
|
356
|
+
shackle = skia.Path()
|
|
357
|
+
shackle.moveTo(cx - s * 0.32, cy - s * 0.05)
|
|
358
|
+
shackle.lineTo(cx - s * 0.32, cy - s * 0.36)
|
|
359
|
+
shackle.quadTo(cx, cy - s * 0.78, cx + s * 0.32, cy - s * 0.36)
|
|
360
|
+
shackle.lineTo(cx + s * 0.32, cy - s * 0.05)
|
|
361
|
+
canvas.drawPath(shackle, p)
|
|
362
|
+
elif name == "save":
|
|
363
|
+
box = skia.Rect.MakeXYWH(cx - s * 0.62, cy - s * 0.62, s * 1.24, s * 1.24)
|
|
364
|
+
canvas.drawRoundRect(box, s * 0.16, s * 0.16, p)
|
|
365
|
+
top = skia.Rect.MakeXYWH(cx - s * 0.32, cy - s * 0.62, s * 0.64, s * 0.44)
|
|
366
|
+
canvas.drawRect(top, p)
|
|
367
|
+
bot = skia.Rect.MakeXYWH(cx - s * 0.34, cy + s * 0.12, s * 0.68, s * 0.50)
|
|
368
|
+
canvas.drawRect(bot, p)
|
|
369
|
+
elif name == "search":
|
|
370
|
+
canvas.drawCircle(cx - s * 0.14, cy - s * 0.14, s * 0.48, p)
|
|
371
|
+
canvas.drawLine(cx + s * 0.22, cy + s * 0.22, cx + s * 0.66, cy + s * 0.66, p)
|
|
372
|
+
elif name == "send":
|
|
373
|
+
path = skia.Path()
|
|
374
|
+
path.moveTo(cx - s * 0.62, cy - s * 0.55)
|
|
375
|
+
path.lineTo(cx + s * 0.68, cy)
|
|
376
|
+
path.lineTo(cx - s * 0.62, cy + s * 0.55)
|
|
377
|
+
path.lineTo(cx - s * 0.36, cy)
|
|
378
|
+
path.close()
|
|
379
|
+
canvas.drawPath(path, p)
|
|
380
|
+
elif name == "palette":
|
|
381
|
+
canvas.drawCircle(cx, cy, s * 0.68, p)
|
|
382
|
+
canvas.drawCircle(cx - s * 0.25, cy - s * 0.18, s * 0.11, fill)
|
|
383
|
+
canvas.drawCircle(cx + s * 0.05, cy - s * 0.30, s * 0.11, fill)
|
|
384
|
+
canvas.drawCircle(cx + s * 0.28, cy - s * 0.05, s * 0.11, fill)
|
|
385
|
+
elif name == "dark_mode":
|
|
386
|
+
path = skia.Path()
|
|
387
|
+
path.addCircle(cx, cy, s * 0.62)
|
|
388
|
+
canvas.drawArc(
|
|
389
|
+
skia.Rect.MakeXYWH(cx - s * 0.62, cy - s * 0.62, s * 1.24, s * 1.24),
|
|
390
|
+
35,
|
|
391
|
+
235,
|
|
392
|
+
False,
|
|
393
|
+
p,
|
|
394
|
+
)
|
|
395
|
+
canvas.drawArc(
|
|
396
|
+
skia.Rect.MakeXYWH(cx - s * 0.28, cy - s * 0.62, s * 1.0, s * 1.0),
|
|
397
|
+
75,
|
|
398
|
+
150,
|
|
399
|
+
False,
|
|
400
|
+
p,
|
|
401
|
+
)
|
|
402
|
+
elif name == "light_mode":
|
|
403
|
+
canvas.drawCircle(cx, cy, s * 0.34, p)
|
|
404
|
+
for i in range(8):
|
|
405
|
+
ang = i * math.pi / 4.0
|
|
406
|
+
canvas.drawLine(
|
|
407
|
+
cx + math.cos(ang) * s * 0.52,
|
|
408
|
+
cy + math.sin(ang) * s * 0.52,
|
|
409
|
+
cx + math.cos(ang) * s * 0.74,
|
|
410
|
+
cy + math.sin(ang) * s * 0.74,
|
|
411
|
+
p,
|
|
412
|
+
)
|
|
413
|
+
elif name == "star":
|
|
414
|
+
path = skia.Path()
|
|
415
|
+
for i in range(10):
|
|
416
|
+
r = s * 0.72 if i % 2 == 0 else s * 0.32
|
|
417
|
+
ang = -math.pi / 2 + i * math.pi / 5
|
|
418
|
+
px = cx + math.cos(ang) * r
|
|
419
|
+
py = cy + math.sin(ang) * r
|
|
420
|
+
if i == 0:
|
|
421
|
+
path.moveTo(px, py)
|
|
422
|
+
else:
|
|
423
|
+
path.lineTo(px, py)
|
|
424
|
+
path.close()
|
|
425
|
+
canvas.drawPath(path, p)
|
|
426
|
+
else:
|
|
427
|
+
# Generic Material dot fallback for unknown icon names
|
|
428
|
+
canvas.drawCircle(cx, cy, s * 0.42, p)
|