Last active
October 8, 2024 01:15
-
-
Save jorarmarfin/14ba27cd2eee89e90d06c23450a3c28a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "miniwin.h" | |
#include "cmath" | |
using namespace miniwin; | |
void Cabecera(const char* titulo){ | |
color(AZUL); | |
rectangulo(10,10,690,50); | |
color(VERDE); | |
texto(15,15,titulo); | |
} | |
void rotar_linea(int x, int y, int longitud, int angulo, int color_linea) { | |
color(color_linea); | |
float radianes = angulo * M_PI / 180.0; // Convertir ángulo a radianes | |
int x_fin = x + static_cast<int>(longitud * cos(radianes)); | |
int y_fin = y - static_cast<int>(longitud * sin(radianes)); // Restar porque el eje y crece hacia abajo | |
linea(x, y, x_fin, y_fin); | |
} | |
void cuadrado_color(int x, int y, int longitud, int color_cuadrado) { | |
color(color_cuadrado); | |
rectangulo_lleno(x, y - longitud, x + longitud, y); | |
} | |
void cuadrado(int x, int y, int longitud) { | |
color(ROJO); | |
linea(x, y, x + longitud, y); | |
rotar_linea(x, y, longitud, 90); | |
rotar_linea(x + longitud, y, longitud, 90); | |
linea(x, y - longitud, x + longitud, y - longitud); | |
} | |
void pentagono(int x, int y, int longitud){ | |
// 72 | |
//Cateto opuesto: 95.11 | |
// Cateto adyacente: 30.90 | |
color(VERDE); | |
linea(x, y, x + longitud, y); | |
rotar_linea(x, y, longitud, 108, VERDE); | |
rotar_linea(x + longitud, y,longitud, 72, VERDE); | |
rotar_linea(x + longitud, y,longitud, 72, VERDE); | |
rotar_linea(x + longitud + 30.90, y - 95.11,longitud, 144, VERDE); | |
rotar_linea(x - 30.90, y - 95.11,longitud, 36, VERDE); | |
} | |
void hexagono(int x, int y, int longitud){ | |
double co; | |
double ca; | |
co = 86,6; | |
ca = 50; | |
color(VERDE); | |
linea(x, y, x + longitud, y); | |
rotar_linea(x, y, longitud, 120, VERDE); | |
rotar_linea(x + longitud, y,longitud, 60, VERDE); | |
rotar_linea(x + longitud + ca, y - co,longitud, 120, VERDE); | |
rotar_linea(x - ca, y - co,longitud, 60, VERDE); | |
linea(x, y-2*co, x + longitud, y-2*co); | |
} | |
void heptagono(int x, int y, int longitud){ | |
double co; | |
double ca; | |
co = 78.1; | |
ca = 62.3; | |
double co2; | |
double ca2; | |
co2 = 97,4; | |
ca2 = 22,2; | |
color(VERDE); | |
linea(x, y, x + longitud, y); | |
rotar_linea(x, y, longitud, 128.57, VERDE); | |
rotar_linea(x + longitud, y,longitud, 51.43, VERDE); | |
rotar_linea(x + longitud + ca, y - co,longitud, 102.86, VERDE); | |
rotar_linea(x - ca, y - co,longitud, 77.14, VERDE); | |
rotar_linea(x + longitud + ca - ca2, y - co - co2,longitud, 154.2, VERDE); | |
rotar_linea(x - ca + ca2, y - co - co2,longitud, 25.7, VERDE); | |
} | |
int main(){ | |
vredimensiona(700,630); | |
Cabecera("CUBO"); | |
refresca(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment