#!/usr/bin/python """ xturtle-example-suite: xtx_pentest.py Demonstrates fill - ing in conjunction with several different pen states in respect to pensize, colors, visibility etc. Also demonstrates complete undo!! (NEW!) """ from xturtle import Turtle, mainloop from time import sleep def main(): t = Turtle() t.colormode(255) t.left(90) t.speed(1) l = 210 t.penup() t.back(20) t.pendown() ## 1. triangle t.right(30) t.pensize(3) t.fill(True) for i in 1,2,3: t.pencolor("red") t.forward(l/3.) t.pencolor("green") t.forward(l/3.) t.pencolor("blue") t.forward(l/3.) t.left(120) t.fillcolor(220,220,255) t.fill(False) t.left(30) ## 2. triangle t.left(60) t.color("blue", "red") t.fill(True) t.pensize(10) for i in 1,2,3: t.forward(l) t.left(120) t.fill(False) t.left(30) ## 3. triangle t.left(60) t.penup() t.fillcolor(180,0,180) t.fill(True) for i in 1,2,3: t.forward(l) t.left(120) t.fill(False) t.pendown() t.left(30) ## Change screencolor t.getscreen().bgcolor("yellow") ## 4. triangle t.left(60) t.speed(1) t.pencolor("green") t.fillcolor("#d03000") t.fill(True) for i in 1,2,3: if i==2: t.hideturtle() t.pensize(2+3*i) t.forward(l/3.0) t.penup() t.left(60) t.forward(l/6.0) t.right(120) t.forward(l/3.0) t.left(120) t.forward(l/6.0) t.right(60) t.pendown() t.forward(l/3.0) if i==2: t.showturtle() t.left(120) t.fill(True) t.left(30) ## original heading t.left(90) t.speed(2) t.up() t.fd(l/3**0.5) sleep(0.6) for i in range(100): t.undo() return "DONE!" if __name__ == '__main__': main() #mainloop()