Jump to content

File:Dragon curve.png

Page contents not supported in other languages.
This is a file from the Wikimedia Commons
From Wikipedia, the free encyclopedia

Original file (681 × 681 pixels, file size: 11 KB, MIME type: image/png)

Summary

Description

Spacefilling combination of four dragon curves

Created with Python and xturtle graphics module
Date 5. 11. 2006
Source Own work
Author Stefan Lew
Permission
(Reusing this file)
This image is public domain. You may use this image for any purpose, including commercial.

Source code

#
# Dragon curve
#

from xturtle import *

def fold(direction):
	if direction == 0:
		p.right(90)
	else:
		p.left(90)

def next(kette):
	kette.append(1)
	laenge = len(kette)
	for i in range(0, laenge-1):
		kette.append(kette[i])
	if kette[laenge-1+laenge/2] == 0:
		kette[laenge-1+laenge/2] = 1;
	else:
		kette[laenge-1+laenge/2] = 0;
	return kette

def zeichne(kette):
	p.tracer(100)
	p.hideturtle()
	for i in kette:
		p.forward(2)
		fold(i)
	p.forward(2)
	p.update()

def find_iteration(n):
	kette = [1]
	for i in range(1, n):
		kette = next(kette)
	return kette

def set_back():
	p.penup()
	p.goto(0,0)
	p.pendown()


it = 15

p = Pen()
zeichne(find_iteration(it))
set_back()
p.color('red')
zeichne(find_iteration(it))
set_back()
p.color('blue')
zeichne(find_iteration(it))
set_back()
p.color('green')
zeichne(find_iteration(it))
raw_input()

Licensing

Public domain I, the copyright holder of this work, release this work into the public domain. This applies worldwide.
In some countries this may not be legally possible; if so:
I grant anyone the right to use this work for any purpose, without any conditions, unless such conditions are required by law.

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

depicts

image/png

10,873 byte

681 pixel

681 pixel

b8eb76c8728ed7f649cb9557d5bec2c8b8183562

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current23:49, 4 November 2006Thumbnail for version as of 23:49, 4 November 2006681 × 681 (11 KB)Lew~commonswiki{{Information |Description=Spacefilling combination of four dragon curves Created with Python and [http://www.rg16.asn-wien.ac.at/~python/xturtle/ xturtle] graphics module |Source=own work |Date=5. 11. 2006 |Author=Stefan Lew |Permission=This image is pu
No pages on the English Wikipedia use this file (pages on other projects are not listed).

Global file usage

The following other wikis use this file: