Dibujar una Flor con Python

Contenido:

Dibujar una Flor con Python y Turtle

En este post, encontrarás el Código para dibujar una Flor Amarilla con Python, este dibujo se lo realiza con el módulo de gráficos Turtle, este módulo es una forma popular de presentar la programación a los niños. Para obtener mas información sobre el módulo Turtle, da clic aquí.

flor python turtle
Figura 1: Flor Amarilla dibujada con Turtle de Python.

Sketch en Python

import turtle
turtle.pensize(5)

turtle.title("Flor Amarilla")
turtle.bgcolor("black")

def point(x,y):
    turtle.penup()
    turtle.goto(x,y)
    turtle.pendown()

turtle.pencolor("red")
turtle.fillcolor("yellow")

point(24, 280)
turtle.begin_fill()
turtle.seth(120)
turtle.circle(30,120)
turtle.end_fill()

point(0, 275)
turtle.begin_fill()
turtle.seth(135)
turtle.circle(50,65)
turtle.circle(10,75)
turtle.forward(20)
turtle.end_fill()

point(-48, 255)
turtle.begin_fill()
turtle.seth(45)
turtle.circle(-110,55)
turtle.circle(-15,75)
turtle.seth(250)
turtle.forward(20)
turtle.end_fill()

point(-70, 200)
turtle.begin_fill()
turtle.goto(-70, 227.5)
turtle.seth(130)
turtle.circle(50,55)
turtle.circle(15,75)
turtle.seth(290)
turtle.forward(10)
turtle.end_fill()

point(60, 200)
turtle.begin_fill()
turtle.goto(60, 227.5)
turtle.seth(50)
turtle.circle(-50,55)
turtle.circle(-15,75)
turtle.seth(250)
turtle.forward(10)
turtle.end_fill()

point(12, 210)
turtle.begin_fill()
turtle.goto(12, 245)
turtle.seth(135)
turtle.circle(110,55)
turtle.circle(8,100)
turtle.seth(275)
turtle.circle(50,40)
turtle.seth(300)
turtle.circle(-30,45)
turtle.seth(270)
turtle.forward(30)
turtle.end_fill()

point(-53, 100)
turtle.begin_fill()
turtle.goto(-53, 200)
turtle.seth(60)
turtle.circle(-160,55)
turtle.circle(-12,60)
turtle.seth(260)
turtle.circle(-50,30)
turtle.seth(255)
turtle.circle(60,45)
turtle.end_fill()

point(0, 100)
turtle.begin_fill()
turtle.seth(90)
turtle.circle(130,65)
turtle.seth(158)
turtle.forward(52)
turtle.seth(230)
turtle.circle(10,90)
turtle.seth(310)
turtle.circle(-140,25)
turtle.seth(270)
turtle.circle(100,85)
turtle.end_fill()

point(-10, 100)
turtle.begin_fill()
turtle.seth(90)
turtle.circle(-130,65)
turtle.seth(22)
turtle.forward(52)
turtle.seth(310)
turtle.circle(-10,90)
turtle.seth(230)
turtle.circle(140,25)
turtle.seth(270)
turtle.circle(-100,85)
turtle.end_fill()

turtle.pencolor("darkgreen")
turtle.fillcolor("green")

point(15, -5)
turtle.begin_fill()
turtle.seth(70)
turtle.circle(-90,60)
turtle.seth(300)
turtle.forward(10)
turtle.seth(20)
turtle.forward(35)
turtle.seth(280)
turtle.forward(10)
turtle.seth(0)
turtle.forward(25)
turtle.seth(258)
turtle.forward(25)
turtle.seth(325)
turtle.forward(10)
turtle.seth(240)
turtle.forward(25)
turtle.seth(325)
turtle.forward(10)
turtle.seth(250)
turtle.circle(-85,110)
turtle.end_fill()

point(15, -35)
turtle.seth(40)
turtle.circle(-210,25)
turtle.seth(21)
turtle.circle(140,26)

point(10, 70)
turtle.begin_fill()
turtle.seth(10)
turtle.circle(90,70)
turtle.seth(215)
turtle.forward(60)
turtle.seth(135)
turtle.forward(50)
turtle.seth(225)
turtle.forward(50)
turtle.seth(145)
turtle.forward(65)
turtle.seth(280)
turtle.circle(90,70)
turtle.seth(290)
turtle.circle(-320,50)
turtle.seth(310)
turtle.forward(22)
turtle.seth(56)
turtle.circle(320,53)
turtle.end_fill()

# Descomenta las siguientes lineas si quieres agregar texto
#turtle.pencolor("white")
#point(0, -280)
#turtle.write("PARA TI", False, "center",("arial",30,"bold italic"))

turtle.hideturtle()
turtle.mainloop()

Deja un comentario