Draw 8 of Diamond using Python
__author__ = "Ahmedur Rahman Shovon"
__license__ = "GPL"
__version__ = "1.0.1"
__maintainer__ = "Ahmedur Rahman Shovon"
import turtle
def draw(x_position, y_position, font, value):
turtle.up()
turtle.goto(x_position, y_position)
turtle.write(value,font=font)
turtle.down()
turtle.hideturtle()
canvas_width = 405
canvas_height = 490
turtle.setup(canvas_width, canvas_height, 0, 0)
font_color = 'red'
turtle.color(font_color)
turtle.title("8 of diamond by arsho")
diamond_size = 100
small_diamond_size = 35
number_size = 40
diamond_font = ("Comic Sans MS", diamond_size, "normal")
small_diamond_font = ("Comic Sans MS", small_diamond_size, "normal")
number_font = ("Comic Sans MS", number_size, "normal")
card_value = "8"
diamond_value = "\u2666"
x_position_left = -170
x_position_middle = -60
x_position_right = 50
y_position = -210
y_distance = 70
top_8_x_position = -190
top_8_y_position = 180
bottom_8_x_position = 150
bottom_8_y_position = -240
top_diamond_x_position = -193
top_diamond_y_position = 135
bottom_diamond_x_position = 145
bottom_diamond_y_position = -190
# Draw top 8
draw(top_8_x_position, top_8_y_position, number_font, card_value)
# Draw top diamond
draw(top_diamond_x_position, top_diamond_y_position, small_diamond_font, diamond_value)
# Draw bottom 8
draw(bottom_8_x_position, bottom_8_y_position, number_font, card_value)
# Draw bottom diamond
draw(bottom_diamond_x_position, bottom_diamond_y_position, small_diamond_font, diamond_value)
for i in range(5):
if i%2==0:
# Draw two diamonds
draw(x_position_left, y_position, diamond_font, diamond_value)
draw(x_position_right, y_position, diamond_font, diamond_value)
else:
# Draw two diamonds
draw(x_position_middle, y_position, diamond_font, diamond_value)
y_position += y_distance
Output:
Advertisement