banner
andrewji8

Being towards death

Heed not to the tree-rustling and leaf-lashing rain, Why not stroll along, whistle and sing under its rein. Lighter and better suited than horses are straw sandals and a bamboo staff, Who's afraid? A palm-leaf plaited cape provides enough to misty weather in life sustain. A thorny spring breeze sobers up the spirit, I feel a slight chill, The setting sun over the mountain offers greetings still. Looking back over the bleak passage survived, The return in time Shall not be affected by windswept rain or shine.
telegram
twitter
github

Python中秋賞月專用程式碼中秋節程式碼

image
程式執行截圖:程式執行所需的背景音樂請在文末下載,也可自行替換

import turtle
import time
import pygame


def drawMoon():            #繪製月亮
  turtle.penup()   #畫筆拿起
  turtle.goto(-150, 0)
  turtle.fillcolor((255, 215, 0))   #圓月的顏色
  turtle.pendown()   #畫筆放下
  turtle.begin_fill()
  turtle.circle(112)
  turtle.end_fill()  #turtle.begin_fill()  到turtle.end_fill() 顏色填充
def drawCloud():           #繪製雲朵
   turtle.penup()
   turtle.goto(-500, 200)
   turtle.fillcolor((245, 245, 245))
   turtle.pencolor((255, 255, 255))
   turtle.pensize(5)
   turtle.pendown()
   turtle.forward(250)
   def cloud(mode='right'):
      for i in range(90):
         turtle.pensize((i+1)*0.2+5)
         turtle.right(1) if mode == 'right' else turtle.left(1)
         turtle.forward(0.5)
      for i in range(90):
         turtle.pensize(90*0.2+5-0.2*(i+1))
         turtle.right(1) if mode == 'right' else turtle.left(1)
         turtle.forward(0.5)
   cloud()
   turtle.forward(100)
   cloud('left')
   turtle.forward(600)
def drawMountain():          #繪製山川
   turtle.penup()
   turtle.goto(-500, -250)
   turtle.pensize(4)
   turtle.fillcolor((36, 36, 36))
   turtle.pencolor((31, 28, 24))
   turtle.pendown()
   turtle.begin_fill()
   turtle.left(20)
   turtle.forward(400)
   turtle.right(45)
   turtle.forward(200)
   turtle.left(60)
   turtle.forward(300)
   turtle.right(70)
   turtle.forward(300)
   turtle.goto(500, -300)
   turtle.goto(-500, -300)
   turtle.end_fill()
def initTurtle():
   pygame.mixer.init()
   pygame.mixer.music.load('ZXbg.mp3')#自行添加音樂
   pygame.mixer.music.play(-1, 20.0)
   turtle.hideturtle()
   turtle.setup(1000, 600)
   turtle.title('中秋賞月')
   turtle.colormode(255)
   turtle.bgcolor((193, 210, 240))
   turtle.speed(10)
def writePoetry():
  turtle.penup()
  turtle.goto(400, -150)
  turtle.pencolor((250, 240, 230))
  # 詩句
  potery = ["\n\n\n\n\n\n", "把\n\n\n\n\n"]
  # 詩句位置(可自行設計添加), 最好2/4句五言詩
  coordinates = [(300, -150), (200, -150), (100, -150)]
  for i, p in enumerate(potery):
    turtle.write(p, align="center", font=("STXingkai", 50, "bold"))
    if (i + 1) != len(potery):
      time.sleep(2)
      turtle.goto(coordinates[i])
def main():
    initTurtle()
    drawMoon()          #繪製月亮
    drawCloud()         #繪製雲朵
    drawMountain()      #繪製山
    writePoetry()       #寫詩
    turtle.done()

if __name__ == '__main__':
    main()
載入中......
此文章數據所有權由區塊鏈加密技術和智能合約保障僅歸創作者所有。