File size: 24,657 Bytes
f50ed6e | 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 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 | <!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FR Legends Livery Generator</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.canvas-container {
position: relative;
width: 100%;
max-width: 500px;
margin: 0 auto;
background-color: #1a1a1a;
border-radius: 8px;
overflow: hidden;
}
#previewCanvas {
width: 100%;
height: auto;
display: block;
}
.car-overlay {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
opacity: 0.3;
}
.code-display {
font-family: 'Courier New', monospace;
background-color: #2d2d2d;
color: #f8f8f8;
padding: 15px;
border-radius: 6px;
max-height: 200px;
overflow-y: auto;
white-space: pre-wrap;
word-wrap: break-word;
}
.shape-preview {
width: 30px;
height: 30px;
display: inline-block;
margin-right: 5px;
border: 1px solid #555;
}
@keyframes pulse {
0% { transform: scale(1); }
50% { transform: scale(1.05); }
100% { transform: scale(1); }
}
.processing {
animation: pulse 1.5s infinite;
}
</style>
</head>
<body class="bg-gray-900 text-white min-h-screen">
<div class="container mx-auto px-4 py-8">
<header class="text-center mb-8">
<h1 class="text-4xl font-bold text-purple-400 mb-2">FR Legends Livery Generator</h1>
<p class="text-gray-300">Convierte cualquier imagen en un diseño para FR Legends usando solo círculos y cuadrados</p>
</header>
<div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
<!-- Panel izquierdo - Subir imagen y controles -->
<div class="bg-gray-800 p-6 rounded-xl shadow-lg">
<h2 class="text-2xl font-semibold text-purple-300 mb-4">Configuración del diseño</h2>
<div class="mb-6">
<label class="block text-gray-300 mb-2">Sube tu imagen</label>
<div class="border-2 border-dashed border-gray-600 rounded-lg p-8 text-center hover:border-purple-500 transition-colors cursor-pointer" id="dropZone">
<input type="file" id="imageInput" accept="image/*" class="hidden">
<div class="flex flex-col items-center justify-center">
<i class="fas fa-cloud-upload-alt text-4xl text-purple-400 mb-2"></i>
<p class="text-gray-400">Arrastra y suelta una imagen o haz clic para seleccionar</p>
<p class="text-xs text-gray-500 mt-2">Formatos soportados: JPG, PNG, GIF</p>
</div>
</div>
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-6">
<div>
<label class="block text-gray-300 mb-2">Nivel de detalle</label>
<select id="detailLevel" class="w-full bg-gray-700 border border-gray-600 rounded-md px-3 py-2 text-white focus:outline-none focus:ring-2 focus:ring-purple-500">
<option value="low">Bajo (100 formas)</option>
<option value="medium" selected>Medio (300 formas)</option>
<option value="high">Alto (500 formas)</option>
<option value="extreme">Extremo (1000 formas)</option>
</select>
</div>
<div>
<label class="block text-gray-300 mb-2">Tipo de formas</label>
<select id="shapeType" class="w-full bg-gray-700 border border-gray-600 rounded-md px-3 py-2 text-white focus:outline-none focus:ring-2 focus:ring-purple-500">
<option value="circles">Solo círculos</option>
<option value="squares">Solo cuadrados</option>
<option value="mixed" selected>Mezclados</option>
</select>
</div>
</div>
<div class="mb-6">
<label class="block text-gray-300 mb-2">Tamaño máximo de formas</label>
<input type="range" id="shapeSize" min="1" max="100" value="50" class="w-full h-2 bg-gray-700 rounded-lg appearance-none cursor-pointer">
<div class="flex justify-between text-xs text-gray-400 mt-1">
<span>Pequeño</span>
<span>Grande</span>
</div>
</div>
<div class="flex flex-wrap gap-2 mb-6">
<div class="flex items-center">
<input type="checkbox" id="mirrorDesign" class="mr-2" checked>
<label for="mirrorDesign" class="text-gray-300">Espejar diseño (para ambos lados del coche)</label>
</div>
<div class="flex items-center">
<input type="checkbox" id="optimizeColors" class="mr-2" checked>
<label for="optimizeColors" class="text-gray-300">Optimizar colores (limitar a paleta FR Legends)</label>
</div>
</div>
<button id="generateBtn" class="w-full bg-purple-600 hover:bg-purple-700 text-white font-bold py-3 px-4 rounded-lg transition-colors flex items-center justify-center">
<i class="fas fa-magic mr-2"></i> Generar Livery Code
</button>
</div>
<!-- Panel derecho - Vista previa y código -->
<div class="bg-gray-800 p-6 rounded-xl shadow-lg">
<h2 class="text-2xl font-semibold text-purple-300 mb-4">Vista previa y código</h2>
<div class="mb-6">
<div class="flex justify-between items-center mb-2">
<label class="text-gray-300">Vista previa del diseño</label>
<div class="text-sm text-gray-400" id="shapeCount">0 formas</div>
</div>
<div class="canvas-container">
<canvas id="previewCanvas" width="500" height="250"></canvas>
<img src="https://i.imgur.com/JQ9w7fC.png" class="car-overlay" alt="Car outline">
</div>
</div>
<div class="mb-4">
<label class="block text-gray-300 mb-2">Código generado</label>
<div class="code-display" id="generatedCode">
Sube una imagen y haz clic en "Generar Livery Code" para crear tu diseño.
</div>
</div>
<div class="flex flex-wrap gap-2">
<button id="copyCodeBtn" class="bg-gray-700 hover:bg-gray-600 text-white py-2 px-4 rounded-md transition-colors flex items-center">
<i class="fas fa-copy mr-2"></i> Copiar código
</button>
<button id="downloadBtn" class="bg-gray-700 hover:bg-gray-600 text-white py-2 px-4 rounded-md transition-colors flex items-center">
<i class="fas fa-download mr-2"></i> Descargar imagen
</button>
<button id="shareBtn" class="bg-gray-700 hover:bg-gray-600 text-white py-2 px-4 rounded-md transition-colors flex items-center">
<i class="fas fa-share-alt mr-2"></i> Compartir
</button>
</div>
<div class="mt-6">
<h3 class="text-lg font-medium text-purple-300 mb-2">Cómo usar este código en FR Legends:</h3>
<ol class="list-decimal list-inside text-gray-300 text-sm space-y-1">
<li>Abre FR Legends y ve al editor de liveries</li>
<li>Selecciona "Importar código"</li>
<li>Pega el código generado</li>
<li>Ajusta la posición si es necesario</li>
</ol>
</div>
</div>
</div>
<div class="mt-12 bg-gray-800 p-6 rounded-xl shadow-lg">
<h2 class="text-2xl font-semibold text-purple-300 mb-4">Ejemplos de diseños</h2>
<div class="grid grid-cols-2 md:grid-cols-4 gap-4">
<div class="cursor-pointer" onclick="loadExample('example1')">
<img src="https://i.imgur.com/JQ9w7fC.png" class="w-full h-auto rounded-md border-2 border-gray-700 hover:border-purple-500 transition-colors" alt="Example 1">
<p class="text-center text-gray-300 mt-2">Diseño simple</p>
</div>
<div class="cursor-pointer" onclick="loadExample('example2')">
<img src="https://i.imgur.com/JQ9w7fC.png" class="w-full h-auto rounded-md border-2 border-gray-700 hover:border-purple-500 transition-colors" alt="Example 2">
<p class="text-center text-gray-300 mt-2">Patrón geométrico</p>
</div>
<div class="cursor-pointer" onclick="loadExample('example3')">
<img src="https://i.imgur.com/JQ9w7fC.png" class="w-full h-auto rounded-md border-2 border-gray-700 hover:border-purple-500 transition-colors" alt="Example 3">
<p class="text-center text-gray-300 mt-2">Retrato</p>
</div>
<div class="cursor-pointer" onclick="loadExample('example4')">
<img src="https://i.imgur.com/JQ9w7fC.png" class="w-full h-auto rounded-md border-2 border-gray-700 hover:border-purple-500 transition-colors" alt="Example 4">
<p class="text-center text-gray-300 mt-2">Logo de equipo</p>
</div>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Elementos del DOM
const dropZone = document.getElementById('dropZone');
const imageInput = document.getElementById('imageInput');
const previewCanvas = document.getElementById('previewCanvas');
const ctx = previewCanvas.getContext('2d');
const generateBtn = document.getElementById('generateBtn');
const copyCodeBtn = document.getElementById('copyCodeBtn');
const downloadBtn = document.getElementById('downloadBtn');
const shareBtn = document.getElementById('shareBtn');
const generatedCode = document.getElementById('generatedCode');
const shapeCount = document.getElementById('shapeCount');
// Variables de estado
let uploadedImage = null;
let generatedLiveryCode = '';
// Configurar zona de arrastre
dropZone.addEventListener('click', () => imageInput.click());
imageInput.addEventListener('change', handleFileSelect);
['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
dropZone.addEventListener(eventName, preventDefaults, false);
});
function preventDefaults(e) {
e.preventDefault();
e.stopPropagation();
}
['dragenter', 'dragover'].forEach(eventName => {
dropZone.addEventListener(eventName, highlight, false);
});
['dragleave', 'drop'].forEach(eventName => {
dropZone.addEventListener(eventName, unhighlight, false);
});
function highlight() {
dropZone.classList.add('border-purple-500');
dropZone.classList.remove('border-gray-600');
}
function unhighlight() {
dropZone.classList.remove('border-purple-500');
dropZone.classList.add('border-gray-600');
}
dropZone.addEventListener('drop', handleDrop, false);
function handleDrop(e) {
const dt = e.dataTransfer;
const files = dt.files;
if (files.length) {
handleFiles(files);
}
}
function handleFileSelect(e) {
const files = e.target.files;
if (files.length) {
handleFiles(files);
}
}
function handleFiles(files) {
const file = files[0];
if (!file.type.match('image.*')) {
alert('Por favor, sube solo archivos de imagen.');
return;
}
const reader = new FileReader();
reader.onload = function(e) {
const img = new Image();
img.onload = function() {
uploadedImage = img;
drawPreviewImage();
};
img.src = e.target.result;
};
reader.readAsDataURL(file);
}
function drawPreviewImage() {
if (!uploadedImage) return;
const canvas = previewCanvas;
const ctx = canvas.getContext('2d');
// Limpiar canvas
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Dibujar la imagen escalada para que quepa en el canvas
const ratio = Math.min(canvas.width / uploadedImage.width, canvas.height / uploadedImage.height);
const width = uploadedImage.width * ratio;
const height = uploadedImage.height * ratio;
const x = (canvas.width - width) / 2;
const y = (canvas.height - height) / 2;
ctx.drawImage(uploadedImage, x, y, width, height);
}
// Generar código de livery
generateBtn.addEventListener('click', generateLiveryCode);
function generateLiveryCode() {
if (!uploadedImage) {
alert('Por favor, sube una imagen primero.');
return;
}
generateBtn.classList.add('processing');
generateBtn.innerHTML = '<i class="fas fa-spinner fa-spin mr-2"></i> Procesando...';
generatedCode.textContent = 'Generando código, por favor espera...';
// Obtener configuraciones
const detailLevel = document.getElementById('detailLevel').value;
const shapeType = document.getElementById('shapeType').value;
const shapeSize = parseInt(document.getElementById('shapeSize').value);
const mirrorDesign = document.getElementById('mirrorDesign').checked;
const optimizeColors = document.getElementById('optimizeColors').checked;
// Procesar la imagen en un worker para no bloquear la UI
const worker = new Worker('imageProcessor.js');
worker.onmessage = function(e) {
const { code, numShapes } = e.data;
generatedLiveryCode = code;
generatedCode.textContent = code;
shapeCount.textContent = `${numShapes} formas`;
drawShapePreviewFromCode(code);
generateBtn.classList.remove('processing');
generateBtn.innerHTML = '<i class="fas fa-magic mr-2"></i> Generar Livery Code';
};
// Preparar datos para el worker
const canvas = document.createElement('canvas');
canvas.width = uploadedImage.width;
canvas.height = uploadedImage.height;
const ctx = canvas.getContext('2d');
ctx.drawImage(uploadedImage, 0, 0);
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height).data;
worker.postMessage({
imageData,
width: canvas.width,
height: canvas.height,
detailLevel,
shapeType,
shapeSize,
mirrorDesign,
optimizeColors
});
}
function getShapeCount(level) {
switch(level) {
case 'low': return 100;
case 'medium': return 300;
case 'high': return 500;
case 'extreme': return 1000;
default: return 300;
}
}
function drawShapePreviewFromCode(code) {
const canvas = previewCanvas;
const ctx = canvas.getContext('2d');
ctx.clearRect(0, 0, canvas.width, canvas.height);
const lines = code.split('\n').filter(line =>
line.startsWith('circle,') || line.startsWith('square,')
);
lines.forEach(line => {
const [shape, x, y, width, height, rotation, color] = line.split(',');
const scaleX = canvas.width / 100;
const scaleY = canvas.height / 100;
ctx.save();
ctx.translate(parseFloat(x) * scaleX, parseFloat(y) * scaleY);
ctx.rotate(parseFloat(rotation) * Math.PI / 180);
ctx.fillStyle = `#${color}`;
if (shape === 'circle') {
const radius = parseFloat(width) * scaleX / 2;
ctx.beginPath();
ctx.arc(0, 0, radius, 0, Math.PI * 2);
ctx.fill();
} else {
ctx.fillRect(
-parseFloat(width) * scaleX / 2,
-parseFloat(height) * scaleY / 2,
parseFloat(width) * scaleX,
parseFloat(height) * scaleY
);
}
ctx.restore();
});
}
function drawShapePreview(count, shapeType, size) {
const canvas = previewCanvas;
const ctx = canvas.getContext('2d');
// Limpiar canvas
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Dibujar formas aleatorias
for (let i = 0; i < count; i++) {
const x = Math.random() * canvas.width;
const y = Math.random() * canvas.height;
const width = 5 + Math.random() * (size / 2);
const height = shapeType === 'circles' ? width : 5 + Math.random() * (size / 2);
const rotation = Math.random() * 360;
const color = `#${Math.floor(Math.random() * 16777215).toString(16).padStart(6, '0')}`;
const shape = shapeType === 'mixed' ?
(Math.random() > 0.5 ? 'circle' : 'square') :
(shapeType === 'circles' ? 'circle' : 'square');
ctx.save();
ctx.translate(x, y);
ctx.rotate(rotation * Math.PI / 180);
ctx.fillStyle = color;
if (shape === 'circle') {
ctx.beginPath();
ctx.arc(0, 0, width / 2, 0, Math.PI * 2);
ctx.fill();
} else {
ctx.fillRect(-width / 2, -height / 2, width, height);
}
ctx.restore();
}
}
// Copiar código al portapapeles
copyCodeBtn.addEventListener('click', function() {
if (!generatedLiveryCode) {
alert('No hay código para copiar. Genera un diseño primero.');
return;
}
navigator.clipboard.writeText(generatedLiveryCode).then(() => {
const originalText = copyCodeBtn.innerHTML;
copyCodeBtn.innerHTML = '<i class="fas fa-check mr-2"></i> ¡Copiado!';
setTimeout(() => {
copyCodeBtn.innerHTML = originalText;
}, 2000);
}).catch(err => {
console.error('Error al copiar: ', err);
alert('No se pudo copiar el código. Inténtalo de nuevo.');
});
});
// Descargar imagen
downloadBtn.addEventListener('click', function() {
if (!uploadedImage) {
alert('No hay imagen para descargar. Sube una imagen primero.');
return;
}
const link = document.createElement('a');
link.download = 'fr-legends-livery.png';
link.href = previewCanvas.toDataURL('image/png');
link.click();
});
// Compartir
shareBtn.addEventListener('click', function() {
if (!generatedLiveryCode) {
alert('No hay diseño para compartir. Genera un diseño primero.');
return;
}
if (navigator.share) {
navigator.share({
title: 'Mi diseño para FR Legends',
text: 'Mira este diseño que creé con el FR Legends Livery Generator',
url: window.location.href
}).catch(err => {
console.log('Error al compartir:', err);
});
} else {
alert('La función de compartir no está disponible en tu navegador. Copia el código manualmente.');
}
});
// Cargar ejemplos
window.loadExample = function(exampleId) {
// En una aplicación real, esto cargaría imágenes de ejemplo
alert('En una aplicación real, esto cargaría un ejemplo de diseño.');
};
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=Anonimo5703/https-enzostvs-deepsite-hf-space-projects-new" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html> |