Add initial project files including .gitignore, VSCode settings, and turtle graphics scripts
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
import turtle
|
||||
import random
|
||||
|
||||
|
||||
# Función para dibujar un cuadrado
|
||||
def cuadrado(t, size):
|
||||
for _ in range(4): # Dibujar un cuadrado
|
||||
t.forward(size)
|
||||
t.right(90)
|
||||
|
||||
def triangulo(t, size):
|
||||
for _ in range(3): # Dibujar un cuadrado
|
||||
t.forward(size)
|
||||
t.right(120)
|
||||
|
||||
|
||||
def estrella(t, size):
|
||||
for _ in range(5): # Una estrella tiene 5 puntos
|
||||
t.forward(size)
|
||||
t.right(144) # Ángulo para formar una estrella
|
||||
|
||||
def infinito(t, size):
|
||||
for _ in range(2):
|
||||
t.circle(size, 90)
|
||||
t.circle(size // 2, 90)
|
||||
|
||||
|
||||
def flor(t, petalos, radio):
|
||||
for _ in range(petalos):
|
||||
t.circle(radio)
|
||||
t.right(360 / petalos)
|
||||
|
||||
def estrella_multipuntas(t, size, puntas):
|
||||
for _ in range(puntas):
|
||||
t.forward(size)
|
||||
t.right(180 - (180 / puntas))
|
||||
|
||||
def color_aleatorio():
|
||||
"""Genera un color RGB aleatorio."""
|
||||
r = random.randint(0, 255)
|
||||
g = random.randint(0, 255)
|
||||
b = random.randint(0, 255)
|
||||
return (r, g, b)
|
||||
|
||||
|
||||
# Función para dibujar cuadrados rotando
|
||||
def draw_rotating_squares():
|
||||
import turtle # Aseguramos importar turtle dentro de la función si se usa de forma independiente
|
||||
|
||||
# Configurar la pantalla y la tortuga
|
||||
screen = turtle.Screen()
|
||||
t = turtle.Turtle()
|
||||
|
||||
# Inicializar la longitud del lado
|
||||
length = 50 # Tamaño inicial del cuadrado
|
||||
|
||||
# Aumentar la velocidad al máximo
|
||||
t.speed('fastest')
|
||||
|
||||
# Dibujar 60 cuadrados, aumentando el tamaño y girando 5 grados después de cada uno
|
||||
for _ in range(1000):
|
||||
flor(t,6, length) # Llamar a la función para dibujar un triángulo
|
||||
t.right(10) # Girar 5 grados después de cada figura
|
||||
length += 10 # Aumentar el tamaño del triángulo
|
||||
|
||||
# Cerrar la ventana al hacer clic
|
||||
screen.exitonclick()
|
||||
|
||||
|
||||
# Ejecutar la función
|
||||
draw_rotating_squares()
|
||||
Reference in New Issue
Block a user