Py5Shape.set_stroke_weight()

Py5Shape.set_stroke_weight()

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

Examples

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

    py5.shape(s, 0, 20)
    s.set_stroke_weight(4)
    py5.shape(s, 0, 40)
    s.set_stroke_weight(10)
    py5.shape(s, 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. Attempting to set this for individual vertices may not work, depending on the renderer used and other factors.

This method differs from Py5Shape.stroke_weight() in that it is only to be used outside the Py5Shape.begin_shape() and Py5Shape.end_shape() methods.

Underlying Processing method: PShape.setStrokeWeight

Syntax

set_stroke_weight(index: int, weight: float, /) -> None
set_stroke_weight(weight: float, /) -> None

Parameters

  • index: int - vertex index

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

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