Py5Font.get_shape()#

Get a single character as a Py5Shape object.

Examples#

example picture for get_shape()
 1def setup():
 2    font = py5.create_font('DejaVu Sans', 32)
 3    chr_p = font.get_shape('p')
 4    chr_y = font.get_shape('y')
 5    chr_5 = font.get_shape('5')
 6
 7    chr_p.disable_style()
 8    chr_y.disable_style()
 9    chr_5.disable_style()
10
11    py5.fill(0)
12    py5.no_stroke()
13
14    x = 25
15    py5.shape(chr_p, x, 40)
16    x += chr_p.get_width()
17    py5.shape(chr_y, x, 60)
18    x += chr_y.get_width()
19    py5.shape(chr_5, x, 80)

Description#

Get a single character as a Py5Shape object. Use the detail parameter to draw the shape with only straight line segments.

Calling Py5Shape.disable_style() on the returned Py5Shape object seems to be necessary for these to be drawable.

This method only works on fonts loaded with create_font().

Underlying Processing method: PFont.getShape

Syntax#

get_shape(ch: chr, /) -> Py5Shape
get_shape(ch: chr, detail: float, /) -> Py5Shape

Parameters#

  • ch: chr - single character

  • detail: float - level of shape detail

Updated on November 12, 2021 11:30:58am UTC