Skip to content

Latest commit

 

History

History
66 lines (45 loc) · 1.34 KB

py5font_get_shape.md

File metadata and controls

66 lines (45 loc) · 1.34 KB

Py5Font.get_shape()

Get a single character as a object.

Examples

example picture for get_shape()

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 object. Use the detail parameter to draw the shape with only straight line segments.

Calling on the returned object seems to be necessary for these to be drawable.

This method only works on fonts loaded with .

Underlying Processing method: PFont.getShape

Signatures

get_shape(
    ch: chr,  # single character
    /,
) -> Py5Shape

get_shape(
    ch: chr,  # single character
    detail: float,  # level of shape detail
    /,
) -> Py5Shape

Updated on March 06, 2023 02:49:26am UTC