반응형
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
import turtle
import random
 
turtle = turtle.Turtle()
turtle.shape("turtle")
turtle.speed(0)
 
= 0
= 0
 
#사각형 그리는 변수
rectX = x-20    #사각형 시작 x좌표값
rectY = y       #사각형 시작 y좌표값
rectWidth = 40  #사각형 가로 넓이
rectHeight = 80 #사각형 세로 길이
 
triSide = rectWidth + 40 #삼각형 한 변 길이
 
def drawRectangle(t, color , x, y, width, height) :
        t.fillcolor(color)
        t.penup()
        t.goto(x, y)
        t.pendown()
        t.begin_fill()
 
        for i in range(2) : 
                t.forward(width)
                t.right(90)
                t.forward(height)
                t.right(90)
        t.end_fill()
 
def drawTriangle(t, color, x, y, side) :
        t.fillcolor(color)
        t.penup()
        t.goto(x, y)
        t.pendown()
        t.begin_fill()
 
        t.forward(side)
        t.left(120)
        t.forward(side)
        t.left(120)
        t.forward(side)
 
        t.end_fill()
        
 
        
 
drawRectangle(turtle, "brown", rectX, rectY, rectWidth, rectHeight)
drawTriangle(turtle, "green", rectX-20, y, triSide)
 
cs


반응형

+ Recent posts