Article 5C1WF A python Merry Christmas card

A python Merry Christmas card

by
teckk
from LinuxQuestions.org on (#5C1WF)
A python Merry Christmas card to all at LQ.
You'll have to run it, to see the greeting card.

Code:#!/usr/bin/python
#Merry Christmas to LQ

from turtle import *
from random import randint

def create_rectangle(turtle, color, x, y, width, height):
turtle.penup()
turtle.color(color)
turtle.fillcolor(color)
turtle.goto(x, y)
turtle.pendown()
turtle.begin_fill()

turtle.forward(width)
turtle.left(90)
turtle.forward(height)
turtle.left(90)
turtle.forward(width)
turtle.left(90)
turtle.forward(height)
turtle.left(90)
turtle.end_fill()
turtle.setheading(0)

def create_circle(turtle, x, y, radius, color):
oogway.penup()
oogway.color(color)
oogway.fillcolor(color)
oogway.goto(x, y)
oogway.pendown()
oogway.begin_fill()
oogway.circle(radius)
oogway.end_fill()

BG_COLOR = "#0080ff"
oogway = Turtle()
oogway.speed(2)

screen = oogway.getscreen()
screen.bgcolor(BG_COLOR)
screen.title("Merry Christmas LQ")
screen.setup(width=.7, height=.7)

y = -100
create_rectangle(oogway, "red", -15, y-60, 30, 60)

width = 240
oogway.speed(10)
while width > 10:
width = width - 10
height = 10
x = 0 - width/2
create_rectangle(oogway, "green", x, y, width, height)
y = y + height

oogway.speed(1)
oogway.penup()
oogway.color('yellow')
oogway.goto(-20, y+10)
oogway.begin_fill()
oogway.pendown()
for i in range(5):
oogway.forward(40)
oogway.right(144)
oogway.end_fill()

tree_height = y + 40

create_circle(oogway, 230, 180, 60, "white")
create_circle(oogway, 220, 180, 60, BG_COLOR)

oogway.speed(10)
number_of_stars = randint(20,30)

for _ in range(0,number_of_stars):
x_star = randint(-(screen.window_width()//2),screen.window_width()//2)
y_star = randint(tree_height, screen.window_height()//2)
size = randint(5,20)
oogway.penup()
oogway.color('white')
oogway.goto(x_star, y_star)
oogway.begin_fill()
oogway.pendown()
for i in range(5):
oogway.forward(size)
oogway.right(144)
oogway.end_fill()

oogway.speed(1)
oogway.penup()
msg = ('Merry Christmas to all at Linuxquestion.org'
' And Wishes for a happy and healthier new year.')

oogway.goto(0, -200)
oogway.color("white")
oogway.pendown()
oogway.write(msg, move=False, align="center", font=("Arial", 15, "bold"))
oogway.hideturtle()

screen.mainloop()latest?d=yIl2AUoC8zA latest?i=jFX5YcU6G2s:XldESUmna-4:F7zBnMy latest?i=jFX5YcU6G2s:XldESUmna-4:V_sGLiP latest?d=qj6IDK7rITs latest?i=jFX5YcU6G2s:XldESUmna-4:gIN9vFwjFX5YcU6G2s
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments