Vote count:
0
I'm doing some simple fractal drawings using turtle graphics in python and have encountered the situation where the turtle draws beyond the application frame. I want to be able to drag the view within the window so that I can center it over a different section of the fractal I am drawing or alternatively, Zoom in or out in order to manipulate the view.
Does Python have a module for this? I am relatively new to python as I primarily program with Java and can think of many ways to do with Java and JFrames etc. My research for a simple python implementation has been fruitless :( and I don't want to be reinventing the wheel if there is a simple solution avaliable~ all methods are appreciated though. If I have missed another thread on this site that answers my question, please comment.
here is my fractal code for anyone interested..
import turtle
t = turtle.Turtle()
t.color("white")
t.backward(450)
t.color("red")
def f2(length, depth):
if depth == 0:
t.forward(length)
else:
f2(length/2, depth -1)
t.left(135)
f2(length/8, depth -1)
t.right(90)
f2(length/8, depth -1)
t.right(90)
f2(length/8, depth -1)
t.right(90)
f2(length/8, depth -1)
t.left(135)
f2(length/2, depth -1)
f2(400, 4)
How to implement a drag feature (or zoom) in a python window application?
Aucun commentaire:
Enregistrer un commentaire