蘋果公司的標志是全球最具有辨識度的企業標志之一,它簡單而有力的設計一直深受廣大用戶的喜愛。而Python作為一門多功能語言,也可以用來畫出這個標志。
import turtle def draw_circle(color, radius, x, y): """畫圓函數""" turtle.penup() turtle.goto(x, y) turtle.pendown() turtle.fillcolor(color) turtle.begin_fill() turtle.circle(radius) turtle.end_fill() turtle.speed(2) # 畫藍色背景 draw_circle("#0071c5", 200, 0, -200) # 畫蘋果輪廓 draw_circle("#ffffff", 140, 0, 0) # 畫蘋果葉子 turtle.penup() turtle.goto(0, 140) turtle.pendown() turtle.fillcolor("#47c33e") turtle.begin_fill() turtle.left(90) turtle.circle(-140, 30) turtle.right(120) turtle.circle(-140, 30) turtle.end_fill() # 畫蘋果邊框 draw_circle("#000000", 140, 0, 0) # 畫蘋果里面的葉子 turtle.penup() turtle.goto(0, 110) turtle.pendown() turtle.fillcolor("#47c33e") turtle.begin_fill() turtle.left(90) turtle.circle(-110, 30) turtle.right(120) turtle.circle(-110, 30) turtle.end_fill() # 移動到下面畫蘋果的鉤子 turtle.penup() turtle.goto(40, -150) turtle.pendown() turtle.fillcolor("#000000") turtle.begin_fill() turtle.left(60) turtle.forward(80) turtle.right(120) turtle.forward(80) turtle.right(120) turtle.forward(80) turtle.end_fill() turtle.hideturtle() turtle.done()
運行以上代碼,就可以得到一個十分逼真的蘋果公司標志了。