├── Flor.py └── flor_amarilla_v2 /Flor.py: -------------------------------------------------------------------------------- 1 | from turtle import * 2 | import colorsys 3 | import math 4 | 5 | speed(0.25) 6 | bgcolor("black") 7 | 8 | # Genera los petalos 9 | goto(0, -40) 10 | h = 0 11 | 12 | for i in range(16): 13 | for j in range(18): 14 | c= colorsys.hsv_to_rgb(0.125 , 1, 1) 15 | color(c) 16 | rt(90) 17 | circle(150-j*6, 90) 18 | lt(90) 19 | circle(150-j*6, 90) 20 | rt(180) 21 | circle(40, 24) 22 | 23 | # Genera la parte centrall de la flor 24 | color("black") 25 | shape("turtle") 26 | fillcolor("brown") 27 | phi = 137.508 * (math.pi/ 180.0) 28 | 29 | for i in range (200): 30 | r = 4 * math.sqrt(i) 31 | theta = i*phi 32 | x = r * math.cos(theta) 33 | y = r * math.sin(theta) 34 | penup() 35 | goto(x, y) 36 | setheading(i * 137.508) 37 | pendown() 38 | stamp() 39 | 40 | done() -------------------------------------------------------------------------------- /flor_amarilla_v2: -------------------------------------------------------------------------------- 1 | from turtle import * 2 | import colorsys 3 | import math 4 | import random 5 | 6 | speed(0.01) 7 | bgcolor("black") 8 | 9 | # Función para dibujar una flor 10 | def draw_flower(posx, posy): 11 | penup() 12 | goto(posx, posy) 13 | pendown() 14 | h = 0 15 | for i in range(16): 16 | for j in range(18): 17 | c= colorsys.hsv_to_rgb(0.125 , 1, 1) 18 | color(c) 19 | h += 0.005 20 | rt(90) 21 | circle(150 - j * 6, 90) 22 | lt(90) 23 | circle(150 - j * 6, 90) 24 | rt(180) 25 | circle(40, 24) 26 | # Genera la parte centrall de la flor 27 | color("black") 28 | shape("turtle") 29 | fillcolor("brown") 30 | phi = 137.508 * (math.pi/ 180.0) 31 | 32 | for i in range (200): 33 | r = 4 * math.sqrt(i) 34 | theta = i*phi 35 | x = r * math.cos(theta) 36 | y = r * math.sin(theta) 37 | posx1 = posx+x 38 | posy1 = posy+y+40 39 | penup() 40 | goto(posx1, posy1) 41 | setheading(i * 137.508) 42 | pendown() 43 | stamp() 44 | 45 | # Función para dibujar el tallo con una hoja 46 | def draw_stem_with_leaf(x, y): 47 | penup() 48 | goto(x, y) 49 | pendown() 50 | pos_leaf_y = y-200 51 | 52 | # Dibuja el tallo recto y más grande 53 | c= colorsys.hsv_to_rgb(0.29 , 1, 0.40) 54 | color(c) 55 | pensize(12) 56 | setheading(270) 57 | fd(200) 58 | 59 | # Dibuja el tallo curvo 60 | setheading(90) 61 | circle(100, -70) 62 | 63 | # Dibuja la hoja más grande 64 | penup() 65 | goto(x, pos_leaf_y) 66 | pendown() 67 | pensize(2) 68 | begin_fill() 69 | setheading(135) 70 | circle(50, 90) 71 | setheading(45) 72 | circle(50, 90) 73 | end_fill() 74 | 75 | # Restaura el color y el grosor del lápiz 76 | penup() 77 | pensize(1) 78 | color("black") 79 | 80 | # Función para generar estrellitas de forma aleatoria 81 | def draw_random_start(amount): 82 | for _ in range(amount): 83 | penup() 84 | x = random.randint(-400, 400) 85 | y = random.randint(-400, 400) 86 | goto(x, y) 87 | pendown() 88 | star_color = colorsys.hsv_to_rgb(random.random(), 1, 1) 89 | color("white") 90 | begin_fill() 91 | for _ in range(5): 92 | forward(11) 93 | right(144) 94 | end_fill() 95 | 96 | # MAIN 97 | # Dibujar los tallos 98 | draw_stem_with_leaf(0, -50) 99 | 100 | # Dibujar flor 101 | goto(0,0) 102 | setheading(0) 103 | draw_flower(0, 50) 104 | 105 | # Escribir el mensaje 106 | hideturtle() 107 | penup() 108 | goto(0, 350) 109 | pendown() 110 | color("white") # Cambia el color a blanco 111 | write("Para la niña más bonita", align="center", font=("Arial", 11, "normal")) # Cambia el fuente y tamaño del texto 112 | # penup() 113 | # goto(0, 330) 114 | # pendown() 115 | # write("mi Micky, my rey", align="center", font=("Arial", 11, "normal")) 116 | 117 | penup() 118 | goto(0, -300) 119 | pendown() 120 | write("Mi loquita <3", align="center", font=("Arial", 11, "normal")) 121 | hideturtle() 122 | 123 | # Dibuja las estrellas aleatorias 124 | draw_random_start(50) 125 | 126 | hideturtle() 127 | 128 | done() 129 | --------------------------------------------------------------------------------