-
Notifications
You must be signed in to change notification settings - Fork 7
/
turtle2Dlandscacpe.py
89 lines (74 loc) · 2.58 KB
/
turtle2Dlandscacpe.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
"""
This is a small programm to procedurally generate Landscape views, with help of the tkinter Turtle library.
Copyright (C) 2015 Roman Riesen
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from turtle import *
from tkinter import *
from random import *
print("INITIALISED")
speed(0)
minVersatz=-50
maxVersatz=50
ht()
def r(pseudoH,step):
if(step!=0):
return (randint(minVersatz,maxVersatz)/(step*pseudoH))
else: return (randint(minVersatz,maxVersatz)/(pseudoH))
def mountainChain(startingPoints,pseudoH,length,printPosX,printPosY,color,steps):
pencolor(color)
fillcolor(color)
begin_fill()
step=1
points=startingPoints
for m in range (0,steps):
for i in range (len(points)-1,0,-1):
points.insert(i,(points[i-1]+points[i])/2+r(pseudoH,step))
step+=1
for x in range (len(points)):
try:
points[x]=(points[x-2]+2*points[x-1]+
4*points[x]+2*points[x+1]
+points[x+2])/10
except:
IndexError
pu()
goto(printPosX,printPosY)
x,y=xcor(),ycor()
pd()
for n in range(0,len(points)):
goto((length)/(len(points)-1)*n+x,y+points[n])
x,y=xcor(),ycor()
goto(x,-500)
goto(printPosX,-500)
goto(printPosX,printPosY)
end_fill()
#orange (0.9999,0.6,0.0)
backgroundColor=(0.9999,0.6,0.0)
fillcolor(backgroundColor)
pencolor(backgroundColor)
begin_fill()
goto(500,1000)
goto(-500,1000)
goto(-500,-1000)
goto(500,-1000)
goto(500,1000)
end_fill()
mountainChain([0,0], 1.5, 1000,-500, -25,(0.9,0.9,0.9), 8)
mountainChain([0,0], 2, 1000,-500, -75, (0.8,0.8,0.8), 7)
mountainChain([0,0], 3, 1000,-500,-125,(0.5,0.6,0.5), 7)
mountainChain([0,0], 4, 1000,-500,-150,(0.3,0.5,0.3), 7)
mountainChain([0,0], 5, 1000,-500,-175,(0.1,0.3,0.15), 7)
ts = getscreen()
ts.getcanvas().postscript(file="mountains.eps")
done()
print("FINISHED")