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

Mid-Autumn Festival Code for Python Moon Viewing

image
Screenshot of the program: Please download the background music required for the program at the end of the document, or replace it yourself.

import turtle
import time
import pygame


def drawMoon():            # Draw the moon
  turtle.penup()   # Lift the pen
  turtle.goto(-150, 0)
  turtle.fillcolor((255, 215, 0))   # Color of the moon
  turtle.pendown()   # Put down the pen
  turtle.begin_fill()
  turtle.circle(112)
  turtle.end_fill()  # Color filling from turtle.begin_fill() to turtle.end_fill()
def drawCloud():           # Draw the clouds
   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():          # Draw the mountains
   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')# Add your own music
   pygame.mixer.music.play(-1, 20.0)
   turtle.hideturtle()
   turtle.setup(1000, 600)
   turtle.title('Mid-Autumn Moon Appreciation')
   turtle.colormode(255)
   turtle.bgcolor((193, 210, 240))
   turtle.speed(10)
def writePoetry():
  turtle.penup()
  turtle.goto(400, -150)
  turtle.pencolor((250, 240, 230))
  # Poetry
  poetry = ["\nWhen\nwill\nthe\nbright\nmoon\nappear\n", "Raise\na\ncup\nto\nthe\nblue\nsky\n"]
  # Poetry positions (can be designed and added by yourself), preferably two out of four lines of a five-character poem
  coordinates = [(300, -150), (200, -150), (100, -150)]
  for i, p in enumerate(poetry):
    turtle.write(p, align="center", font=("STXingkai", 50, "bold"))
    if (i + 1) != len(poetry):
      time.sleep(2)
      turtle.goto(coordinates[i])
def main():
    initTurtle()
    drawMoon()          # Draw the moon
    drawCloud()         # Draw the clouds
    drawMountain()      # Draw the mountains
    writePoetry()       # Write poetry
    turtle.done()

if __name__ == '__main__':
    main()
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.