Stroke#
Contains context managers which change how the turtle draws lines. A context manager alters the way in which a code block is executed.
- class superturtle.stroke.dashes(spacing=20)[source]#
A context manager which causes a code block to draw with dashes.
- Parameters:
spacing (int) – (Optional) The length of each dash and space in pixels. Defaults to 20.
from superturtle.stroke import dashes with dashes(): for side in range(4): forward(100) right(90)
- class superturtle.stroke.dots(spacing=10)[source]#
A context manager which causes a code block to draw with dots.
- Parameters:
spacing (int) – (Optional) The space between each dot in pixels. Defaults to 10.
from turtle import forward, right from superturtle.stroke import dots with dots(): for side in range(5): forward(100) right(360/5)
- class superturtle.stroke.rainbow(spacing=10, colors=None)[source]#
A context manager which causes a code block to draw in rainbow colors.
- Parameters:
spacing (int) – (Optional) The length of each color segment. Defaults to 10.
colors (list) – (Optional) A sequence of color names (any valid inputs to turtle.setcolor). By default, uses a rainbow.
from turtle import forward from superturtle.stroke import rainbow with rainbow(colors=["black", "grey", "white"]): forward(60)