KTurtle/Examples/da: Difference between revisions
< KTurtle
(Importing a new version from external source) |
(Importing a new version from external source) |
||
Line 16: | Line 16: | ||
[[Image:KTurtle-koch-curve.png|600px|center]] | [[Image:KTurtle-koch-curve.png|600px|center]] | ||
==Sierpinski | ==Sierpinski-trekant== | ||
Another famous fractal is the [http://en.wikipedia.org/wiki/Sierpinski_triangle Sierpinski triangle]. | Another famous fractal is the [http://en.wikipedia.org/wiki/Sierpinski_triangle Sierpinski triangle]. |
Revision as of 19:26, 3 September 2012
Home » Applications » Education » KTurtle » da
Tip
Scriptformattering er resultatet af en "HTML-eksport" af KTurtle.
Koch kurve
Dette er en fraktal kurve. Du kan finde mere information om den på Wikipedia.
Logo-script:
# Koch curve
reset
canvassize 850, 550
go 125, 350
turnright 90
learn koch $x, $t {
if $t>0 {
$t=$t-1
$x=$x/3
koch $x, $t
turnleft 60
koch $x, $t
turnright 120
koch $x, $t
turnleft 60
koch $x, $t
} else {
forward 3*$x
}
}
koch 200, 6
Resultat:
Sierpinski-trekant
Another famous fractal is the Sierpinski triangle.
Logo script:
# Sierpinski triangle
learn sierp $l {
if $l > 2 {
repeat 3 {
sierp $l/2
forward $l
turnleft 120
}
}
}
reset
canvassize 600, 533
go 50, 483
turnright 90
sierp 500
Result:
Heighway Dragon
Another famous fractal is the Heighway Dragon.
Logo script:
# Heighway dragon
reset
canvassize 500, 500
go 320, 400
turnright 90
$size = 7
learn X $depth {
if $depth>0 {
X $depth-1
turnleft 90
Y $depth-1
forward $size
}
}
learn Y $depth {
if $depth>0 {
forward $size
X $depth-1
turnright 90
Y $depth-1
}
}
pencolor 0,255,0
forward $size
X 10
turnleft 90
pencolor 255,0,0
Y 10
forward $size
go 50,450
Result: