ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • [ํ„ฐํ‹€ ๊ทธ๋ž˜ํ”ฝ] ๊ธฐ๋ณธ ํ•จ์ˆ˜
    ๋กœ๋ด‡๊ต์œก/2ํšŒ์ฐจ_ํŒŒ์ด์ฌ 2022. 1. 11. 19:09

     

    ํ•จ์ˆ˜ ์„ค๋ช… ์‚ฌ์šฉ ์˜ˆ
    forward(๊ฑฐ๋ฆฌ) / fd(๊ฑฐ๋ฆฌ) ๊ฑฐ๋ถ์ด๊ฐ€ ์•ž์œผ๋กœ ์ด๋™ turtle.forward(100)
    backward(๊ฑฐ๋ฆฌ) / back(๊ฑฐ๋ฆฌ) ๊ฑฐ๋ถ์ด๊ฐ€ ๋’ค๋กœ ์ด๋™ turtle.backward(100)
    left(๊ฐ๋„) / lt(๊ฐ๋„) ๊ฑฐ๋ถ์ด๊ฐ€ ์™ผ์ชฝ์œผ๋กœ ํšŒ์ „ turtle.left(90)
    right(๊ฐ๋„) / rt(๊ฐ๋„) ๊ฑฐ๋ถ์ด๊ฐ€ ์˜ค๋ฅธ์ชฝ์œผ๋กœ ํšŒ์ „ turtle.right(90)
    circle(๋ฐ˜์ง€๋ฆ„) ํ˜„์žฌ์œ„์น˜์—์„œ ์›์„ ๊ทธ๋ฆผ turtle.circle(50)
    circle(๋ฐ˜์ง€๋ฆ„, extend๊ฐ๋„, steps์ •๋ฐ€๋„) ์› ๊ทธ๋ฆฌ๊ธฐ ์˜ต์…˜ turtle.circle(50, 180)
    turtle.circle(50, steps=5)
    pendown() / down() ํŽœ ๋‚ด๋ฆฌ๊ธฐ turtle.pendown()
    penup() / up() ํŽœ ์˜ฌ๋ฆฌ๊ธฐ turtle.penup()
    shape('๋ชจ์–‘') ๊ฑฐ๋ถ์ด ๋ชจ์–‘์„ ๋ฐ”๊ฟˆ
    (circle, square, triangle, arrow, turtle)
    turtle.shape('turtle')
    width(๊ตต๊ธฐ) ํŽœ ๊ตต๊ธฐ turtle.width(5)
    color('์ƒ‰์ด๋ฆ„') ํŽœ ์ƒ‰ ์ง€์ • turtle.color('red')
    fill_color('์ƒ‰์ด๋ฆ„') ๋„ํ˜• ๋‚ด๋ถ€๋ฅผ ์ƒ‰์น ํ•  ์ƒ‰ ์ง€์ • turtle.fill_color('blue')
    bgcolor('์ƒ‰์ด๋ฆ„') ๋ฐฐ๊ฒฝ ์ƒ‰ ์ง€์ • turtle.bgcolor('black')
    begin_fill() ๋„ํ˜• ๋‚ด๋ถ€ ์ƒ‰์น  ์‹œ์ž‘ turtle.begin_fill()
    end_fill() ๋„ํ˜• ๋‚ด๋ถ€ ์ƒ‰์น  ๋ turtle.end_fill()
    clear() ํ™”๋ฉด์„ ์ง€์›€ turtle.clear()
    reset() ํ™”๋ฉด์„ ์ง€์šฐ๊ณ  ์ดˆ๊ธฐ ์ƒํƒœ๋กœ ๋ณ€๊ฒฝ turtle.reset()
    home() ๊ฑฐ๋ถ์ด์˜ ์œ„์น˜์™€ ๋ฐฉํ–ฅ์„ ์ฒ˜์Œ ์ƒํƒœ๋กœ ๋ณ€๊ฒฝ (ํ™”๋ฉด ๊ฐ€์šด๋ฐ, ์˜ค๋ฅธ์ชฝ(0๋„)๋ฅผ ๋ฐ”๋ผ๋ด„) turtle.home()
    speed(0~10) ์†๋„๋ฅผ ๋ฐ”๊ฟˆ turtle.speed(1)   #๊ฐ€์žฅ ๋Š๋ฆฐ ์†๋„
    turtle.speed(10)  # ๋น ๋ฅธ ์†๋„
    turtle.speed(0)   #์ตœ๊ณ  ์†๋„
    showturtle() / st() ๊ฑฐ๋ถ์ด๋ฅผ ํ™”๋ฉด์— ํ‘œ์‹œ turtle.showturtle()
    hideturtle() /ht() ๊ฑฐ๋ถ์ด๋ฅผ ํ™”๋ฉด์—์„œ ์ˆจ๊น€ turtle.hideturtle()
    pos() / position() ๊ฑฐ๋ถ์ด์˜ ํ˜„์žฌ ์œ„์น˜ turtle.pos()
    xcor(), ycor() ๊ฑฐ๋ถ์ด์˜ x๋‚˜ y์ขŒํ‘œ๋ฅผ ๊ตฌํ•จ xa = turtle.xcor()
    goto(x,y) / setpos(x,y) ๊ฑฐ๋ถ์ด ํŠน์ •์œ„์น˜๋กœ ์ด๋™ turtle.goto(100,50)
    setx(x), sety(y) ๊ฑฐ๋ถ์ด์˜ x๋‚˜ y์ขŒํ‘œ๋ฅผ ์ง€์ •ํ•œ ์œ„์น˜๋กœ ์ด๋™ turtle.sety(100)
    setheading(๊ฐ๋„) ๊ฑฐ๋ถ์ด๊ฐ€ ๋ฐ”๋ผ๋ณด๋Š” ๋ฐฉํ–ฅ์„ ์ง€์ • turtle.setheading(90)
    heading() ๊ฑฐ๋ถ์ด๊ฐ€ ํ˜„์žฌ ๋ฐ”๋ผ๋ณด๋Š” ๊ฐ๋„ ang = turtle.heading()
    towards(x,y) ํ˜„์žฌ ๊ฑฐ๋ถ์ด๊ฐ€ ์žˆ๋Š” ์œ„์น˜์—์„œ ํŠน์ • ์œ„์น˜๊นŒ์ง€ ๋ฐ”๋ผ๋ณด๋Š” ๊ฐ๋„๋ฅผ ๊ตฌํ•จ ang = turtle.towards(10,10)
    title('์ฐฝ์ด๋ฆ„') ๊ฑฐ๋ถ์ด ๊ทธ๋ž˜ํ”ฝ ์ฐฝ์˜ ์ด๋ฆ„์„ ์ง€์ • turtle.title('๊ฑฐ๋ถ์ด')
    write('๋ฌธ์ž์—ด') ํ˜„์žฌ ๊ฑฐ๋ถ์ด ์œ„์น˜์— ๋ฌธ์ž ์ถœ๋ ฅ turtle.write('๊ฑฐ๋ถ์ด')
    distance(x,y) ํ˜„์žฌ ๊ฑฐ๋ถ์ด ์œ„์น˜์—์„œ ํŠน์ • ์œ„์น˜๊นŒ์ง€ ๊ฑฐ๋ฆฌ dis = turtle.distance(100,100)
    onkeypress(ํ•จ์ˆ˜,'ํ‚ค ์ด๋ฆ„') ํ‚ค๋ณด๋“œ๋ฅผ ๋ˆŒ๋ €์„ ๋•Œ ํ•จ์ˆ˜๋ฅผ ์‹คํ–‰ turtle.onkeypress(ํ•จ์ˆ˜์ด๋ฆ„,'Up')
    onscreenclick(ํ•จ์ˆ˜) ๋งˆ์šฐ์Šค ๋ฒ„ํŠผ์„ ๋ˆŒ๋ €์„ ๋•Œ ํ•จ์ˆ˜๋ฅผ ์‹คํ–‰ turtle.onscreenclick(ํ•จ์ˆ˜์ด๋ฆ„)
    ontimer(ํ•จ์ˆ˜,์‹œ๊ฐ„) ์ผ์ •ํ•œ ์‹œ๊ฐ„์ด ์ง€๋‚œ ๋’ค ํ•จ์ˆ˜๋ฅผ ์‹คํ–‰ turtle.ontimer(ํ•จ์ˆ˜์ด๋ฆ„,1000)
    #1000๋ฐ€๋ฆฌ์ดˆ(1์ดˆ) ํ›„์— ํ•จ์ˆ˜ ์‹คํ–‰
    listen() ์‚ฌ์šฉ์ž์˜ ์ž…๋ ฅ ์ด๋ฒคํŠธ๋ฅผ ๊ฐ์ง€ turtle.listen()

    ๋Œ“๊ธ€

Designed by Tistory.