Fill

Set a fill before drawing a shape.

drawBot.fill(r=None, g=None, b=None, alpha=1)

Sets the fill color with a red, green, blue and alpha value. Each argument must a value float between 0 and 1.

fill(1, 0, 0, .5)
# draw a rect
rect(0, 10, 10, 100)

# only set a gray value
fill(0)
# draw a rect
rect(10, 10, 10, 100)

# only set a gray value with an alpha
fill(0, .5)
# draw a rect
rect(20, 10, 10, 100)

# set rgb with no alpha
fill(1, 0, 0)
# draw a rect
rect(30, 10, 10, 100)

# set rgb with an alpha value
fill(1, 0, 0, .5)
# draw a rect
rect(40, 10, 10, 100)
drawBot.linearGradient(startPoint=None, endPoint=None, colors=None, locations=None)

A linear gradient fill with:

  • startPoint as (x, y)
  • endPoint as (x, y)
  • colors as a list of colors, described similary as fill
  • locations of each color as a list of floats. (optionally)

Setting a gradient will ignore the fill.

# set a gradient as the fill color
linearGradient(
    (100, 100),                         # startPoint
    (200, 200),                         # endPoint
    [(1, 0, 0), (0, 0, 1), (0, 1, 0)],  # colors
    [0, .2, 1]                          # locations
    )
# draw a rectangle
rect(100, 100, 100, 100)
drawBot.radialGradient(startPoint=None, endPoint=None, colors=None, locations=None, startRadius=0, endRadius=100)

A radial gradient fill with:

  • startPoint as (x, y)
  • endPoint as (x, y)
  • colors as a list of colors, described similary as fill
  • locations of each color as a list of floats. (optionally)
  • startRadius radius around the startPoint in degrees (optionally)
  • endRadius radius around the endPoint in degrees (optionally)

Setting a gradient will ignore the fill.

# set a gradient as the fill color
radialGradient(
    (100, 100),                         # startPoint
    (200, 200),                         # endPoint
    [(1, 0, 0), (0, 0, 1), (0, 1, 0)],  # colors
    [0, .2, 1],                         # locations
    0,                                  # startRadius
    100                                 # endRadius
    )
# draw a rectangle
rect(100, 100, 100, 100)
drawBot.shadow(offset, blur=None, color=None)

Adds a shadow with an offset (x, y), blur and a color. The color argument must be a tuple similarly as fill.

# a red shadow with some blur and a offset
shadow((3, 3), 10, (1, 0, 0))

# draw a rect
rect(100, 100, 30, 30)