https docs python org3 2libraryturtle html 1 Turtle
파이썬 그리기 https: //docs. python. org/3. 2/library/turtle. html 1
Turtle n References n https: //docs. python. org/3. 2/library/turtle. html from turtle import * color('red', 'yellow') begin_fill() while True: forward(200) left(170) if abs(pos()) < 1: break end_fill() done() 너무 빠르다 Delay를 찾 아보라 2
Turtle의 주요함수 n Move & Draw n n n Forward() | fd() Backward() | bk() | back() Right() | rt() Left() | lt() Goto() | setposition() Setx(), sety() Setheading() | seth() Home() Circle() Dot() Undo() Speed() 3
Turtle의 주요함수 n Turtle’s status n n n Position() | pos() Towards() Xcor(), ycor() Heading() Distance() Drawing n n n n Pendown() | pd() | down() Penup() | pu() | up() Pensize() | width() Pen() Isdown() Color() Pencolor() Fillcolor() n Filling n n Filling() Begin_fill() End_fill() Etc n n n Reset() Clear() Write() 4
Turtle의 주요함수 n Visibility n n Apperance n n Showturtle() | st() Hideturtle() | ht() Isvisible() Shape() Resizemode() Shapesize() | turtlesize() Events n n n Onclick() Onrelease() Ondrag() n Special methods n Begin_poly() n End_poly() n Get_poly() n Clone() n Getturtle() | getpen() n Getscreen() n Setundobuffer() n Undobufferentries() 5
Turtle의 주요함수 n Window control n n n Bgcolor() Bgpic() Clear() | clearscreen() Reset | resetscreen() Screensize() Animation n n Delay() Tracer() Update() Screen events n n n Listen() Onkey() | onkeyrelease() Onkeypress() Onclick() | onscreenclick() Ontimer() Mainloop() | done() n Settings n Mode() n Colormode() n Getcanvas() n Getshapes() n Register_shape() | addshape() n Window_height() n Window_width() Input n Textinput() n Numinput() 6
몸풀기 n 사각형 그리기 from turtle import * import turtle pendown() for i in range(0, 4): fd(100) rt(90) penup() turtle. pendown() for i in range(0, 4): turtle. fd(100) turtle. rt(90) turtle. penup() 7
몸풀기 n 반지름이 radius인 원 그리기 from turtle import * radius= input("반지름을 입력하세요") pendown() circle(100) radius= int(radius) penup() goto(0, radius) pendown() fillcolor("red") begin_fill() for i in range(0, 360): fd(2*3. 14*radius/360. 0) rt(1) end_fill() penup() 10
- Slides: 14