柯基是一種短腿小狗,非??蓯?。我們可以使用Python來畫一只柯基。
# 導入必要的庫 import turtle # 畫柯基的頭 def draw_head(): turtle.penup() turtle.goto(0, 100) turtle.pendown() turtle.circle(50) # 畫柯基的身體 def draw_body(): turtle.penup() turtle.goto(0, 0) turtle.pendown() turtle.circle(100) # 畫柯基的腿 def draw_legs(): turtle.penup() turtle.goto(-70, -70) turtle.pendown() turtle.circle(30) turtle.penup() turtle.goto(70, -70) turtle.pendown() turtle.circle(30) # 畫柯基的尾巴 def draw_tail(): turtle.penup() turtle.goto(0, -100) turtle.pendown() turtle.right(45) turtle.forward(70) turtle.right(180) turtle.forward(70) # 畫柯基的眼睛和鼻子 def draw_face(): turtle.penup() turtle.goto(-20, 140) turtle.pendown() turtle.dot(30) turtle.penup() turtle.goto(20, 140) turtle.pendown() turtle.dot(30) turtle.penup() turtle.goto(0, 120) turtle.dot(20) # 主函數 def main(): turtle.speed(0) draw_head() draw_body() draw_legs() draw_tail() draw_face() turtle.done() # 執行主函數 main()
以上代碼可以通過Python Turtle庫繪制出一只柯基的圖像。