Anonimo5703's picture
Genera la imagen que yo ponga para el juego - Initial Deployment
f50ed6e verified
Raw History Blame Contribute Delete
24.7 kB
<!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>