Add initial project files including .gitignore, VSCode settings, and turtle graphics scripts
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
venv
|
||||||
|
env
|
||||||
|
.env
|
||||||
Vendored
+22
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"workbench.colorCustomizations": {
|
||||||
|
"activityBar.activeBackground": "#93e6fc",
|
||||||
|
"activityBar.background": "#93e6fc",
|
||||||
|
"activityBar.foreground": "#15202b",
|
||||||
|
"activityBar.inactiveForeground": "#15202b99",
|
||||||
|
"activityBarBadge.background": "#fa45d4",
|
||||||
|
"activityBarBadge.foreground": "#15202b",
|
||||||
|
"commandCenter.border": "#15202b99",
|
||||||
|
"sash.hoverBorder": "#93e6fc",
|
||||||
|
"statusBar.background": "#61dafb",
|
||||||
|
"statusBar.foreground": "#15202b",
|
||||||
|
"statusBarItem.hoverBackground": "#2fcefa",
|
||||||
|
"statusBarItem.remoteBackground": "#61dafb",
|
||||||
|
"statusBarItem.remoteForeground": "#15202b",
|
||||||
|
"titleBar.activeBackground": "#61dafb",
|
||||||
|
"titleBar.activeForeground": "#15202b",
|
||||||
|
"titleBar.inactiveBackground": "#61dafb99",
|
||||||
|
"titleBar.inactiveForeground": "#15202b99"
|
||||||
|
},
|
||||||
|
"peacock.color": "#61dafb"
|
||||||
|
}
|
||||||
@@ -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()
|
||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
import turtle
|
||||||
|
from random import randint
|
||||||
|
|
||||||
|
# Configurar la velocidad de la tortuga y ocultar el trazo inicial
|
||||||
|
t = turtle.Turtle()
|
||||||
|
t.speed('fastest') # Velocidad más rápida
|
||||||
|
|
||||||
|
# Configurar el tamaño de la pantalla
|
||||||
|
screen = turtle.Screen()
|
||||||
|
screen.setup(width=500, height=500) # Dimensiones de la pantalla
|
||||||
|
screen.bgcolor("lightblue") # Fondo claro para mejor visibilidad
|
||||||
|
|
||||||
|
def wander():
|
||||||
|
"""Movimiento aleatorio continuo dentro de un área limitada."""
|
||||||
|
while True:
|
||||||
|
t.forward(3) # Avanzar 3 unidades
|
||||||
|
|
||||||
|
# Comprobar si la tortuga alcanza los límites de la pantalla
|
||||||
|
if t.xcor() > 200 or t.xcor() < -200 or t.ycor() > 200 or t.ycor() < -200:
|
||||||
|
t.left(randint(90, 180)) # Girar un ángulo aleatorio entre 90 y 180 grados
|
||||||
|
|
||||||
|
# Ejecutar la función
|
||||||
|
wander()
|
||||||
Reference in New Issue
Block a user