stroke_weight()

Sets the width of the stroke used for lines, points, and the border around shapes.

Examples

example picture for stroke_weight()
1
2
3
4
5
6
7
def setup():
    py5.stroke_weight(1)  # default
    py5.line(20, 20, 80, 20)
    py5.stroke_weight(4)  # thicker
    py5.line(20, 40, 80, 40)
    py5.stroke_weight(10)  # beastly
    py5.line(20, 70, 80, 70)

Description

Sets the width of the stroke used for lines, points, and the border around shapes. All widths are set in units of pixels.

Using point() with strokeWeight(1) or smaller may draw nothing to the screen, depending on the graphics settings of the computer. Workarounds include setting the pixel using the pixels[] or np_pixels[] arrays or drawing the point using either circle() or square().

Underlying Java method: 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