Py5Font.get_shape()

Get a single character as a Py5Shape object.

Examples

example picture for get_shape()
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
def setup():
    font = py5.create_font('DejaVu Sans', 32)
    chr_p = font.get_shape('p')
    chr_y = font.get_shape('y')
    chr_5 = font.get_shape('5')

    chr_p.disable_style()
    chr_y.disable_style()
    chr_5.disable_style()

    py5.fill(0)
    py5.no_stroke()

    x = 25
    py5.shape(chr_p, x, 40)
    x += chr_p.get_width()
    py5.shape(chr_y, x, 60)
    x += chr_y.get_width()
    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 Java 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 September 11, 2021 16:51:34pm UTC