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()
 1def setup():
 2    s = py5.create_shape()
 3    s.begin_shape()
 4    s.stroke_weight(1)
 5    s.vertex(20, 0)
 6    s.vertex(80, 0)
 7    s.end_shape()
 8
 9    py5.shape(s, 0, 20)
10    s.set_stroke_weight(4)
11    py5.shape(s, 0, 40)
12    s.set_stroke_weight(10)
13    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