GenerativePy

Python library for generative art

Canvas.stroke()

Canvas.stroke is a Canvas method that sets the stroke (or outline) Color value. All subsequent shapes drawn will be stroked with the specified colour.

Function

    Canvas.stroke(color)
Parameter Type Description
color Color The stroke color.

Example

Here is an example from the simple drawing tutorial. It draws a rectangle stroked in red, filled with blue:

from generativepy.drawing import makeImage
from generativepy.color import Color


def draw(canvas):
    canvas.stroke(Color('red'))
    canvas.strokeWeight(10)
    canvas.fill(Color('blue'))
    canvas.rect(50, 100, 300, 200)


makeImage("simple-drawing.png", draw, pixelSize=(500, 500),
          background=Color('lightgrey'))

Here is the image it creates:

See also