GenerativePy

Python library for generative art

Canvas.fill()

Canvas.fill is a Canvas method that sets the fill Color value. All subsequent shapes drawn will be filled with the specified colour.

Function

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

Example

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

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