Created
August 24, 2022 11:45
-
-
Save rsbohn/e50f963680240b46fdcde134a391d9d6 to your computer and use it in GitHub Desktop.
Random Turtle Art
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SPDX-FileCopyrightText: Copyright (c) 2022 Randall Bohn (dexter) | |
# | |
# SPDX-License-Identifier: MIT | |
"Random Turtle Art" | |
import random | |
from adafruit_turtle import turtle, Color | |
colors = [Color.RED, Color.YELLOW, Color.GREEN] | |
def walk(t,n): | |
t.forward(n) | |
#t.forward(random.random()*n) | |
if random.random() < 0.5: | |
t.left(90) | |
def strand(t): | |
t.penup() | |
t.goto(0,0) | |
t.pencolor(random.choice(colors)) | |
t.pendown() | |
for _ in range(24): | |
walk(t,12) | |
def main(display=None): | |
if display is None: | |
import board | |
display = board.DISPLAY | |
t = turtle(display) | |
while True: | |
strand(t) | |
if __name__=="__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment