Spaces:
Sleeping
Sleeping
File size: 7,623 Bytes
ade108c | 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 | <!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Resultado del Panorama</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
.panorama-container {
position: relative;
width: 100%;
max-height: 70vh;
overflow: hidden;
margin-bottom: 20px;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
.panorama-image {
width: 100%;
height: auto;
display: block;
}
.action-buttons {
margin-top: 20px;
display: flex;
gap: 10px;
justify-content: center;
}
</style>
</head>
<body class="bg-light">
<div class="container py-5">
<h1 class="text-center mb-4">¡Tu Panorama está Listo!</h1>
{% with messages = get_flashed_messages() %}
{% if messages %}
{% for message in messages %}
<div class="alert alert-info alert-dismissible fade show" role="alert">
{{ message }}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
{% endfor %}
{% endif %}
{% endwith %}
<div class="card">
<div class="card-body">
<div class="panorama-container">
<img src="{{ url_for('static', filename=result_image) }}"
class="panorama-image"
alt="Panorama generado">
</div>
<div class="action-buttons">
<a href="{{ url_for('download_file', filename=filename) }}"
class="btn btn-primary">
<i class="bi bi-download"></i> Descargar Panorama
</a>
<button type="button" class="btn btn-info" onclick="openViewer()">
<i class="bi bi-eye"></i> Vista Cilíndrica
</button>
<form action="{{ url_for('share_panorama') }}" method="post" style="display: inline;">
<input type="hidden" name="result_path" value="{{ result_image }}">
<button type="submit" class="btn btn-success">
<i class="bi bi-share"></i> Compartir con la Comunidad
</button>
</form>
<a href="{{ url_for('index') }}" class="btn btn-outline-secondary">
<i class="bi bi-plus-circle"></i> Crear Otro Panorama
</a>
</div>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script>
function openViewer() {
// Crear modal para vista cilíndrica
const modal = document.createElement('div');
modal.className = 'modal fade';
modal.setAttribute('tabindex', '-1');
modal.setAttribute('role', 'dialog');
modal.setAttribute('aria-hidden', 'true');
modal.innerHTML = `
<div class="modal-dialog modal-xl">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Vista Panorámica Cilíndrica</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal"></button>
</div>
<div class="modal-body p-0">
<div id="panoramaViewer" style="height: 500px; width: 100%;"></div>
</div>
</div>
</div>
`;
document.body.appendChild(modal);
const modalInstance = new bootstrap.Modal(modal);
// Cargar el visor panorámico después de que el modal se muestre completamente
modal.addEventListener('shown.bs.modal', function() {
loadPanoramaViewer();
});
modalInstance.show();
modal.addEventListener('hidden.bs.modal', function () {
document.body.removeChild(modal);
});
}
function loadPanoramaViewer() {
const viewer = document.getElementById('panoramaViewer');
const imageUrl = '{{ url_for("static", filename=result_image) }}';
// Crear canvas para el visor panorámico
const canvas = document.createElement('canvas');
canvas.width = viewer.offsetWidth;
canvas.height = viewer.offsetHeight;
canvas.style.cursor = 'grab';
viewer.appendChild(canvas);
const ctx = canvas.getContext('2d');
const img = new Image();
let isDragging = false;
let lastX = 0;
let offsetX = 0;
img.onload = function() {
drawPanorama();
};
function drawPanorama() {
ctx.clearRect(0, 0, canvas.width, canvas.height);
// Calcular escala para ajustar la imagen al canvas
const scale = canvas.height / img.height;
const scaledWidth = img.width * scale;
// Dibujar la imagen con offset para simular rotación
ctx.drawImage(img, offsetX, 0, scaledWidth, canvas.height);
// Si la imagen no cubre todo el ancho, repetir
if (scaledWidth + offsetX < canvas.width) {
ctx.drawImage(img, offsetX + scaledWidth, 0, scaledWidth, canvas.height);
}
if (offsetX > 0) {
ctx.drawImage(img, offsetX - scaledWidth, 0, scaledWidth, canvas.height);
}
}
// Eventos de mouse para arrastrar
canvas.addEventListener('mousedown', (e) => {
isDragging = true;
lastX = e.clientX;
canvas.style.cursor = 'grabbing';
});
canvas.addEventListener('mousemove', (e) => {
if (isDragging) {
const deltaX = e.clientX - lastX;
offsetX += deltaX;
// Mantener el offset en un rango válido
const scale = canvas.height / img.height;
const scaledWidth = img.width * scale;
if (offsetX > scaledWidth) offsetX -= scaledWidth;
if (offsetX < -scaledWidth) offsetX += scaledWidth;
drawPanorama();
lastX = e.clientX;
}
});
canvas.addEventListener('mouseup', () => {
isDragging = false;
canvas.style.cursor = 'grab';
});
canvas.addEventListener('mouseleave', () => {
isDragging = false;
canvas.style.cursor = 'grab';
});
img.src = imageUrl;
}
</script>
</body>
</html> |