Py5Shape.stroke_weight()

Sets the width of the stroke used for lines and points in a Py5Shape object.

Examples

example picture for stroke_weight()
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
def make_line(weight):
    s = py5.create_shape()
    s.begin_shape()
    s.stroke_weight(weight)
    s.vertex(20, 0)
    s.vertex(80, 0)
    s.end_shape()
    return s


def setup():
    py5.shape(make_line(1), 0, 20) # default
    py5.shape(make_line(4), 0, 40)
    py5.shape(make_line(10), 0, 70)

Description

Sets the width of the stroke used for lines and points in a Py5Shape object. All widths are set in units of pixels.

This method can only be used within a Py5Shape.begin_shape() and Py5Shape.end_shape() pair.

Underlying Java method: PShape.strokeWeight

Syntax

stroke_weight(weight: float, /) -> None

Parameters

  • weight: float - the weight (in pixels) of the stroke

Updated on September 11, 2021 16:51:34pm UTC