-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
54 lines (46 loc) · 1.23 KB
/
example.py
File metadata and controls
54 lines (46 loc) · 1.23 KB
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
import turtle
import math
# deklarasi untuk menggambar persegi panjang
def drawRectangle(t, width, height, color):
t.fillcolor(color)
t.begin_fill()
t.forward(width)
t.left(90)
t.forward(height)
t.left(90)
t.forward(width)
t.left(90)
t.forward(height)
t.left(90)
t.end_fill()
# deklarasi untuk menggambar segitiga
def drawRectangle(t, width, height, color):
t.fillcolor(color)
t.begin_fill()
t.forward(width)
t.left(90)
t.forward(height)
t.left(90)
t.forward(width)
t.left(90)
t.forward(height)
t.left(90)
t.end_fill()
# deklarasi mengatur latar belakang
screen = turtle.Screen ( )
screen.bgcolor("blue")
# deklarasi turtle object
tip = turtle.Turtle ( )
tip.color ("white")
tip.shape ("turtle")
tip.speed (2)
# deklarasi dasar pohon
tip.penup()
tip.goto(-30, -270) # MENGATUR POSISI BATANG POHON (-)kekiri (+)kekanan # mengatur posisi pohon keatas(+) kebawah(-)
tip.pendown()
drawRectangle(tip, 60, 130, "brown")# lebar dan tinggi pohon
# deklarasi puncak pohon
tip.penup()
tip.goto(-30, -270) # MENGATUR POSISI BATANG POHON (-)kekiri (+)kekanan # mengatur posisi pohon keatas(+) kebawah(-)
tip.pendown()
drawRectangle(tip, 200, 200, "green")# lebar dan tinggi pohon