-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
206 lines (187 loc) · 6.82 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title>Área ASCII</title>
<style>
body, html {
margin: 0;
padding: 0;
font-family: 'Courier New', monospace; /* Fuente monoespaciada */
}
.container {
display: flex;
flex-direction: column;
align-items: center;
padding-top: 20px;
}
.grid {
display: grid;
grid-template-columns: repeat(16, 15px);
grid-template-rows: repeat(16, 15px);
overflow-y: visible;
border: 1px solid #0260b8; /* Borde azul */
}
.cell {
display: inline-block;
width: 15px;
height: 15px;
border: 1px solid #ffffff; /* Bordes blancos */
box-sizing: border-box;
}
#color-input-container {
margin-top: 20px;
display: flex;
align-items: center;
}
#color-sample {
width: 20px;
height: 20px;
border-radius: 40%;
margin-left: 10px;
border: 5px solid #5f5b5b;
}
input[type="text"] {
width: 150px;
padding: 10px;
margin-right: 10px;
}
input[type="text"] {
width: 150px;
padding: 10px;
margin-right: 0px;
border: none; /* Sin borde */
text-align: center; /* Texto centrado */
outline: none; /* Sin contorno al enfocar */
}
h3.hipotesis {
font-size: 6px; /* Reducido y en gris */
color: grey;
}
</style>
</head>
<body>
<div class="container">
<h1>Twitgram</h1>
<button onclick="showMessage()">Elemento saludador para usuarios que de verdad desean ser saludados</button>
<p> cambiar color con la rueda del mouse </p>
<button onclick="showMessage2()">Botón que cumple todos tus deseos</button>
<h2>Actividades</h2>
<ul id="lista-actividades"></ul>
<h3>IA could eat humans and nice pixel art</h3>
<h3>buy thats our lucky reality: IA dont wanna kill inferiors</h3>
<h3>here to feed it with pixel art</h3>
<h3>feed it, feed it fast! or ir could change mind </h3>
<div class="grid"></div>
<div id="color-input-container">
<input type="text" id="color-input" placeholder="Escribe un código de color" />
<div id="color-sample"></div>
<div><button onclick="downloadEverything()">Descargar Imagen y Datos del Grid</button></div>
</div>
</div>
<script>
function showMessage() {
alert("Hola!!");
}
function showMessage2() {
alert("NO HAY PLATA");
}
const grid = document.querySelector('.grid');
const colorInput = document.querySelector('#color-input');
const colorSample = document.querySelector('#color-sample');
const colors = new Array(64).fill().map((_, i) => `hsl(${i * 360 / 64}, 100%, 50%)`);
let currentColorIndex = 0;
function updateColorSample() {
colorSample.style.backgroundColor = colors[currentColorIndex];
colorInput.value = colors[currentColorIndex];
}
document.addEventListener('wheel', (event) => {
event.preventDefault();
currentColorIndex = (currentColorIndex + (event.deltaY < 0 ? -3 : 5) + 64) % 64;
updateColorSample();
});
grid.addEventListener('click', (event) => {
if (event.target.classList.contains('cell')) {
event.target.style.backgroundColor = colors[currentColorIndex];
}
});
colorInput.addEventListener('input', () => {
const color = colorInput.value;
if (/^#[0-9A-F]{6}$/i.test(color)) { // Validación simple de hexadecimal
colorSample.style.backgroundColor = color;
colors[currentColorIndex] = color;
}
});
const fragment = document.createDocumentFragment();
for (let i = 0; i < 16 * 16; i++) {
const cell = document.createElement('span');
cell.classList.add('cell');
fragment.appendChild(cell);
}
grid.appendChild(fragment);
updateColorSample();
function downloadEverything() {
downloadGrid(); // Llama a la función para descargar la imagen
downloadColorMatrix(); // Llama a la función para descargar la matriz de colores
}
function downloadGrid() {
const canvas = document.createElement('canvas');
canvas.width = 240; // 16 celdas * 15px cada una
canvas.height = 240;
const ctx = canvas.getContext('2d');
document.querySelectorAll('.cell').forEach((cell, index) => {
const x = (index % 16) * 15;
const y = Math.floor(index / 16) * 15;
ctx.fillStyle = cell.style.backgroundColor || '#ffffff';
ctx.fillRect(x, y, 15, 15);
});
canvas.toBlob(blob => {
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'grid.png';
a.click();
URL.revokeObjectURL(url);
});
}
function downloadEverything() {
downloadColorMatrix(); // Llama a la función para descargar la matriz de colores
downloadGrid(); // Llama a la función para descargar la imagen
}
function downloadGrid() {
const canvas = document.createElement('canvas');
canvas.width = 240; // 16 celdas * 15px cada una
canvas.height = 240;
const ctx = canvas.getContext('2d');
document.querySelectorAll('.cell').forEach((cell, index) => {
const x = (index % 16) * 15;
const y = Math.floor(index / 16) * 15;
ctx.fillStyle = cell.style.backgroundColor || '#ffffff';
ctx.fillRect(x, y, 15, 15);
});
canvas.toBlob(blob => {
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'grid.png';
a.click();
URL.revokeObjectURL(url);
});
}
function downloadColorMatrix() {
const cells = document.querySelectorAll('.cell');
let colorMatrix = [];
cells.forEach(cell => {
const rgb = getComputedStyle(cell).backgroundColor;
colorMatrix.push(rgb);
});
const blob = new Blob([colorMatrix.join('\n')], {type: 'text/plain'});
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'color-matrix.txt';
a.click();
URL.revokeObjectURL(url);
}
</script>
</body>
</html>