-
-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathq5.pyi
More file actions
4413 lines (3230 loc) · 88.6 KB
/
Copy pathq5.pyi
File metadata and controls
4413 lines (3230 loc) · 88.6 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from typing import Any, Callable, Literal
class Image: ...
# ⭐ core
"""⭐
Welcome to q5's documentation! 🤩
First time coding? Check out the q5 Beginner's Brief.
On these Learn pages, you can experiment with editing the
interactive mini examples. Have fun! 😎

"""
def Canvas(w: float = ..., h: float = ..., opt: dict = ...) -> object:
"""⭐
Creates a canvas element, a section of the screen your program
can draw on.
Run this function to start using q5!
Note that in this example, the circle is located at position [0, 0], the origin of the canvas.
:param w: width or side lengths of the canvas
:param h: height of the canvas
:param opt: options
:returns: canvas element
Example::
Canvas(200, 100)
background('silver')
circle(0, 0, 80)
"""
...
def draw() -> None:
"""⭐
The q5 draw function is run 60 times per second by default.
Example::
def draw():
background('silver')
circle(mouseX, mouseY, 80)
"""
...
def log(message: Any) -> None:
"""⭐
Logs a message to the JavaScript console.
To view the console, open your browser's web developer tools
via the keyboard shortcut Ctrl + Shift + i or command + option + i,
then click the "Console" tab.
Use log when you're curious about what your code is doing!
:param message:
Example::
def draw():
circle(mouseX, mouseY, 80)
log('The mouse is at:', mouseX, mouseY)
"""
...
# 🧑🎨 shapes
def circle(x: float, y: float, diameter: float) -> None:
"""🧑🎨
Draws a circle.
:param x: x-coordinate
:param y: y-coordinate
:param diameter: diameter of the circle
Example::
Canvas(200, 100)
circle(0, 0, 80)
"""
...
def ellipse(x: float, y: float, width: float, height: float) -> None:
"""🧑🎨
Draws an ellipse.
:param x: x-coordinate
:param y: y-coordinate
:param width: width of the ellipse
:param height: height of the ellipse
Example::
Canvas(200, 100)
ellipse(0, 0, 160, 80)
"""
...
def rect(x: float, y: float, w: float, h: float, rounded: float = ...) -> None:
"""🧑🎨
Draws a rectangle or a rounded rectangle.
Also accepts 8 parameters to specify a
corner radius for each corner, in the order:
top-left, top-right, bottom-right, bottom-left.
:param x: x-coordinate
:param y: y-coordinate
:param w: width of the rectangle
:param h: height of the rectangle
:param rounded: radius for all corners
Example::
Canvas(200)
background(0.8)
rect(-70, -80, 40, 60)
rect(-20, -30, 40, 60, 10)
rect(30, 20, 40, 60, 20, 4, 0, 8)
"""
...
def square(x: float, y: float, size: float, rounded: float = ...) -> None:
"""🧑🎨
Draws a square or a rounded square.
Also accepts 7 parameters to specify a
corner radius for each corner, in the order:
top-left, top-right, bottom-right, bottom-left.
:param x: x-coordinate
:param y: y-coordinate
:param size: size of the sides of the square
:param rounded: radius for all corners
Example::
Canvas(200)
background(0.8)
square(-70, -70, 40)
square(-20, -20, 40, 10)
square(30, 30, 40, 20, 4, 0, 8)
"""
...
def point(x: float, y: float) -> None:
"""🧑🎨
Draws a point on the canvas.
:param x: x-coordinate
:param y: y-coordinate
Example::
Canvas(200, 100)
stroke('white')
point(-25, 0)
strokeWeight(10)
point(25, 0)
"""
...
def line(x1: float, y1: float, x2: float, y2: float) -> None:
"""🧑🎨
Draws a line on the canvas.
:param x1: x-coordinate of the first point
:param y1: y-coordinate of the first point
:param x2: x-coordinate of the second point
:param y2: y-coordinate of the second point
Example::
Canvas(200, 100)
stroke('lime')
line(-80, -30, 80, 30)
"""
...
def capsule(x1: float, y1: float, x2: float, y2: float, r: float) -> None:
"""🧑🎨
Draws a capsule.
:param x1: x-coordinate of the first point
:param y1: y-coordinate of the first point
:param x2: x-coordinate of the second point
:param y2: y-coordinate of the second point
:param r: radius of the capsule semi-circle ends
Example::
Canvas(200, 100)
background(0.8)
strokeWeight(5)
capsule(-60, -10, 60, 10, 10)
"""
...
def rectMode(mode: str) -> None:
"""🧑🎨
Set to CORNER (default), CENTER, RADIUS, or CORNERS.
Changes how the first four inputs to
rect and square are interpreted.
:param mode:
Example::
Canvas(200, 100)
background(0.8)
rectMode(CORNER)
# ( x, y, w, h)
rect(-50, -25, 100, 50)
"""
...
def ellipseMode(mode: str) -> None:
"""🧑🎨
Set to CENTER (default), RADIUS, CORNER, or CORNERS.
Changes how the first four inputs to
ellipse, circle, and arc are interpreted.
:param mode:
Example::
Canvas(200, 100)
background(0.8)
ellipseMode(CENTER)
# (x, y, w, h)
ellipse(0, 0, 100, 50)
"""
...
CORNER: Literal['corner']
"""🧑🎨
Shape alignment mode, for use in rectMode and ellipseMode.
"""
RADIUS: Literal['radius']
"""🧑🎨
Shape alignment mode, for use in rectMode and ellipseMode.
"""
CORNERS: Literal['corners']
"""🧑🎨
Shape alignment mode, for use in rectMode and ellipseMode.
"""
# 🌆 image
def loadImage(url: str) -> Image:
"""🌆
Loads an image from a URL.
By default, assets are loaded in parallel before q5 runs draw. Use await to wait for an image to load.
:param url: url of the image to load
:returns: image
Example::
Canvas(200)
logo = loadImage('/q5js_logo.avif')
def draw():
background(logo)
"""
...
def image(img: Image | object, dx: float, dy: float, dw: float = ..., dh: float = ..., sx: float = ..., sy: float = ..., sw: float = ..., sh: float = ...) -> None:
"""🌆
Draws an image or video frame to the canvas.
:param img: image or video to draw
:param dx: x position to draw the image at
:param dy: y position to draw the image at
:param dw: width of the destination image
:param dh: height of the destination image
:param sx: x position in the source to start clipping a subsection from
:param sy: y position in the source to start clipping a subsection from
:param sw: width of the subsection of the source image
:param sh: height of the subsection of the source image
Example::
Canvas(200)
logo = load('/q5js_logo.avif')
def draw():
image(logo, -100, -100, 200, 200)
"""
...
def imageMode(mode: str) -> None:
"""🌆
Set to CORNER (default), CORNERS, or CENTER.
Changes how inputs to image are interpreted.
:param mode:
Example::
Canvas(200)
logo = load('/q5js_logo.avif')
def draw():
imageMode(CORNER)
# ( img, x, y, w, h)
image(logo, -50, -50, 100, 100)
"""
...
def defaultImageScale(scale: float) -> float:
"""🌆
Sets the default image scale, which is applied to images when
they are drawn without a specified width or height.
By default it is 0.5 so images appear at their actual size
when pixel density is 2. Images will be drawn at a consistent
default size relative to the canvas regardless of pixel density.
This function must be called before images are loaded to
have an effect.
:param scale:
:returns: default image scale
"""
...
def resize(w: float, h: float) -> None:
"""🌆
Resizes the image.
:param w: new width
:param h: new height
Example::
Canvas(200)
logo = await load('/q5js_logo.avif')
logo.resize(128, 128)
image(logo, -100, -100, 200, 200)
"""
...
def trim() -> Image:
"""🌆
Returns a trimmed image, cropping out transparent pixels from the edges.
"""
...
def smooth() -> None:
"""🌆
Enables smooth rendering of images displayed larger than
their actual size. This is the default setting, so running this
function only has an effect if noSmooth has been called.
Example::
Canvas(200)
smooth()
icon = await load('/q5js_icon.png')
image(icon, -100, -100, 200, 200)
"""
...
def noSmooth() -> None:
"""🌆
Disables smooth image rendering for a pixelated look.
Example::
Canvas(200)
noSmooth()
icon = await load('/q5js_icon.png')
image(icon, -100, -100, 200, 200)
"""
...
def tint(color: str | float) -> None:
"""🌆
Applies a tint (color overlay) to the drawing.
The alpha value of the tint color determines the
strength of the tint. To change an image's opacity,
use the opacity function.
Tinting affects all subsequent images drawn. The tint
color is applied to images using the "multiply" blend mode.
Since the tinting process is performance intensive, each time
an image is tinted, q5 caches the result. image will draw the
cached tinted image unless the tint color has changed or the
image being tinted was edited.
If you need to draw an image multiple times each frame with
different tints, consider making copies of the image and tinting
each copy separately.
:param color: tint color
Example::
Canvas(200)
logo = await load('/q5js_logo.avif')
tint(1, 0, 0, 0.5)
image(logo, -100, -100, 200, 200)
"""
...
def noTint() -> None:
"""🌆
Images drawn after this function is run will not be tinted.
"""
...
def mask(img: Image) -> None:
"""🌆
Masks the image with another image.
:param img: image to use as a mask
"""
...
def copy() -> Image:
"""🌆
Returns a copy of the image.
"""
...
def inset(sx: float, sy: float, sw: float, sh: float, dx: float, dy: float, dw: float, dh: float) -> None:
"""🌆
Displays a region of the image on another region of the image.
Can be used to create a detail inset, aka a magnifying glass effect.
:param sx: x-coordinate of the source region
:param sy: y-coordinate of the source region
:param sw: width of the source region
:param sh: height of the source region
:param dx: x-coordinate of the destination region
:param dy: y-coordinate of the destination region
:param dw: width of the destination region
:param dh: height of the destination region
Example::
Canvas(200)
logo = await load('/q5js_logo.avif')
logo.inset(256, 256, 512, 512, 0, 0, 256, 256)
image(logo, -100, -100, 200, 200)
"""
...
def get(x: float, y: float, w: float = ..., h: float = ...) -> Image | list[float]:
"""🌆
Retrieves a subsection of an image or canvas as a new Q5 Image
or the color of a pixel in the image or canvas.
If only x and y are specified, this function returns the color of the pixel
at the given coordinate in [R, G, B, A] array format. If loadPixels
has never been run, it's run by this function.
If you make changes to the canvas or image, you must call loadPixels
before using this function to get current color data.
Not applicable to WebGPU canvases.
:param x:
:param y:
:param w: width of the area, default is 1
:param h: height of the area, default is 1
Example::
Canvas(200)
logo = await load('/q5js_logo.avif')
cropped = logo.get(256, 256, 512, 512)
image(cropped, -100, -100, 200, 200)
"""
...
def set(x: float, y: float, val: Any) -> None:
"""🌆
Sets a pixel's color in the image or canvas. Color mode must be RGB.
Or if a canvas or image is provided, it's drawn on top of the
destination image or canvas, ignoring its tint setting.
Run updatePixels to apply the changes.
Not applicable to WebGPU canvases.
:param x:
:param y:
:param val: color, canvas, or image
Example::
Canvas(200)
noSmooth()
c = color('lime')
img = createImage(50, 50)
def draw():
img.set(random(50), random(50), c)
img.updatePixels()
background(img)
"""
...
pixels: list[float]
"""🌆
Array of pixel color data from a canvas or image.
Empty by default, get the data by running loadPixels.
Each pixel is represented by four consecutive values in the array,
corresponding to its red, green, blue, and alpha channels.
The top left pixel's data is at the beginning of the array
and the bottom right pixel's data is at the end, going from
left to right and top to bottom.
"""
def loadPixels() -> None:
"""🌆
Loads pixel data into pixels from the canvas or image.
The example below sets some pixels' green channel
to a random value.
Not applicable to WebGPU canvases.
Example::
Canvas(200)
frameRate(5)
icon = load('/q5js_icon.png')
def draw():
icon.loadPixels()
for i in range(0, icon.pixels.length, 16):
icon.pixels[i + 1] = random(1)
icon.updatePixels()
background(icon)
"""
...
def updatePixels() -> None:
"""🌆
Applies changes in the pixels array to the canvas or image.
Not applicable to WebGPU canvases.
Example::
Canvas(200)
c = color('pink')
img = createImage(50, 50)
for x in range(0, 50, 3):
for y in range(0, 50, 3):
img.set(x, y, c)
img.updatePixels()
background(img)
"""
...
def filter(type: str, value: float = ...) -> None:
"""🌆
Applies a filter to the image.
See the documentation for q5's filter constants below for more info.
A CSS filter string can also be used.
https://developer.mozilla.org/docs/Web/CSS/filter
Not applicable to WebGPU canvases.
:param type: filter type or a CSS filter string
:param value: optional value, depends on filter type
Example::
Canvas(200)
logo = await load('/q5js_logo.avif')
logo.filter(INVERT)
image(logo, -100, -100, 200, 200)
"""
...
THRESHOLD: Literal[1]
"""🌆
Converts the image to black and white pixels depending if they are above or below a certain threshold.
"""
GRAY: Literal[2]
"""🌆
Converts the image to grayscale by setting each pixel to its luminance.
"""
OPAQUE: Literal[3]
"""🌆
Sets the alpha channel to fully opaque.
"""
INVERT: Literal[4]
"""🌆
Inverts the color of each pixel.
"""
POSTERIZE: Literal[5]
"""🌆
Limits each channel of the image to the number of colors specified as an argument.
"""
DILATE: Literal[6]
"""🌆
Increases the size of bright areas.
"""
ERODE: Literal[7]
"""🌆
Increases the size of dark areas.
"""
BLUR: Literal[8]
"""🌆
Applies a Gaussian blur to the image.
"""
def createImage(w: float, h: float, opt: Any = ...) -> Image:
"""🌆
Creates a new image.
:param w: width
:param h: height
:param opt: optional settings for the image
"""
...
def createGraphics(w: float, h: float, opt: dict = ...) -> Q5:
"""🌆
Creates a graphics buffer.
Graphics looping is disabled by default in q5 WebGPU.
See issue #104 for details.
:param w: width
:param h: height
:param opt: options
:returns: a new Q5 graphics buffer
Example::
Canvas(200)
g = createGraphics(100)
g.noLoop()
g.stroke('pink')
g.fill('red')
g.circle(50, 50, 120)
image(g, -50, -50, 100, 100)
"""
...
# 📘 text
def text(str: str, x: float, y: float, wrapWidth: float = ..., lineLimit: float = ...) -> None:
"""📘
Renders text on the canvas.
:param str: string of text to display
:param x: x-coordinate of the text's position
:param y: y-coordinate of the text's position
:param wrapWidth: maximum line width in characters
:param lineLimit: maximum number of lines
Example::
Canvas(200, 100)
background('silver')
textSize(32)
text('Hello, world!', -88, 10)
"""
...
def loadFont(url: str) -> object:
"""📘
Loads a font from a URL.
The first example below loads Robotica.
The second example loads
Pacifico from Google fonts.
By default, assets are loaded in parallel before q5 runs draw. Use await to wait for a font to load.
:param url: URL of the font to load
:returns: font
Example::
Canvas(200, 56)
await loadFont('/assets/Robotica.ttf')
fill('skyblue')
textSize(64)
text('Hello!', -98, 24)
"""
...
def textFont(fontName: str) -> None:
"""📘
Sets the current font to be used for rendering text.
By default, the font is set to the CSS font family
"sans-serif" or the last font loaded.
:param fontName: name of the font family or a FontFace object
Example::
Canvas(200, 160)
background(0.8)
textFont('serif')
text('Hello, world!', -96, 10)
"""
...
def textSize(size: float = ...) -> float | None:
"""📘
Sets or gets the current font size. If no argument is provided, returns the current font size.
:param size: size of the font in pixels
:returns: current font size when no argument is provided
Example::
def draw():
background(0.8)
textSize(abs(mouseX))
text('A', -90, 90)
"""
...
def textLeading(leading: float = ...) -> float | None:
"""📘
Sets or gets the current line height. If no argument is provided, returns the current line height.
:param leading: line height in pixels
:returns: current line height when no argument is provided
Example::
def draw():
background(0.8)
textSize(abs(mouseX))
text('A', -90, 90)
rect(-90, 90, 5, -textLeading())
"""
...
def textStyle(style: Literal['normal'] | Literal['italic'] | Literal['bold'] | Literal['bolditalic']) -> None:
"""📘
Sets the current text style.
:param style: font style
Example::
Canvas(200)
background(0.8)
textStyle(ITALIC)
textSize(32)
text('Hello, world!', -88, 6)
"""
...
def textAlign(horiz: Literal['left'] | Literal['center'] | Literal['right'], vert: Literal['top'] | Literal['middle'] | Literal['bottom'] | Literal['alphabetic'] = ...) -> None:
"""📘
Sets the horizontal and vertical alignment of text.
Alignment constants like CENTER can be used with this function.
:param horiz: horizontal alignment
:param vert: vertical alignment
Example::
Canvas(200)
background(0.8)
textSize(32)
textAlign(CENTER, CENTER)
text('Hello, world!', 0, 0)
"""
...
def textWeight(weight: float | str) -> None:
"""📘
Sets the text weight.
- 100: thin
- 200: extra-light
- 300: light
- 400: normal/regular
- 500: medium
- 600: semi-bold
- 700: bold
- 800: bolder/extra-bold
- 900: black/heavy
:param weight: font weight
Example::
Canvas(200)
background(0.8)
textSize(32)
textAlign(CENTER, CENTER)
textWeight(100)
text('Hello, world!', 0, 0)
"""
...
def textWidth(str: str) -> float:
"""📘
Calculates and returns the width of a given string of text.
:param str: string to measure
:returns: width of the text in pixels
Example::
def draw():
background(0.8)
textSize(abs(mouseX))
rect(-90, 90, textWidth('A'), -textLeading())
text('A', -90, 90)
"""
...
def textAscent(str: str) -> float:
"""📘
Calculates and returns the ascent (the distance from the baseline to the top of the highest character) of the current font.
:param str: string to measure
:returns: ascent of the text in pixels
Example::
def draw():
background(0.8)
textSize(abs(mouseX))
rect(-90, 90, textWidth('A'), -textAscent())
text('A', -90, 90)
"""
...
def textDescent(str: str) -> float:
"""📘
Calculates and returns the descent (the distance from the baseline to the bottom of the lowest character) of the current font.
:param str: string to measure
:returns: descent of the text in pixels
Example::
Canvas(200)
background(0.8)
textSize(64)
rect(-100, 0, 200, textDescent('q5'))
text('q5', -90, 0)
"""
...
def createTextImage(str: str, wrapWidth: float = ..., lineLimit: float = ...) -> Image:
"""📘
Creates an image from a string of text.
:param str: string of text
:param wrapWidth: maximum line width in characters
:param lineLimit: maximum number of lines
:returns: an image object representing the rendered text
Example::
Canvas(200)
textSize(96)
img = createTextImage('🐶')
img.filter(INVERT)
def draw():
image(img, -45, -90)
"""
...
def textImage(img: Image | str, x: float, y: float) -> None:
"""📘
Renders an image generated from text onto the canvas.
If the first parameter is a string, an image of the text will be
created and cached automatically.
The positioning of the image is affected by the current text
alignment and baseline settings.
:param img: image or text
:param x: x-coordinate where the image should be placed
:param y: y-coordinate where the image should be placed
Example::
Canvas(200)
background(0.8)
textSize(96)
textAlign(CENTER, CENTER)
textImage('🐶', 0, 0)
"""
...
def textToPoints(str: str) -> None:
"""📘
Converts a string of text to an array of points.
Samples opaque pixels in a text image made with createTextImage.
It's influenced by text settings, such as font, size, and alignment.
Uses a Z-order curve to improve spatial distribution, which preserves the shape of text better than purely random sampling.
:param str: string of text
Example::
Canvas(200)
textSize(220)
textAlign(CENTER, CENTER)
points = textToPoints('5')
for (let pt of points)
rect(pt.x, pt.y, 5, 20)
"""
...
def nf(n: float, l: float, r: float) -> str:
"""📘
Number formatter, can be used to display a number as a string with
a specified number of digits before and after the decimal point,
optionally adding padding with zeros.
:param n: number to format
:param l: minimum number of digits to appear before the decimal point; the number is padded with zeros if necessary
:param r: number of digits to appear after the decimal point