520 lines
24 KiB
Plaintext
520 lines
24 KiB
Plaintext
@page "/admin/spritesheets/edit"
|
||
@model SpriteSheets.EditModel
|
||
@{
|
||
ViewData["Title"] = Model.Sheet.Id > 0 ? $"Edit: {Model.Sheet.Name}" : "New Sprite Sheet";
|
||
var isNew = Model.Sheet.Id == 0;
|
||
}
|
||
|
||
<div class="space-y-6">
|
||
<div class="flex items-center justify-between">
|
||
<div>
|
||
<a href="/admin/spritesheets" class="text-gray-400 hover:text-white text-sm">← Back to Sprite Sheets</a>
|
||
<h1 class="text-3xl font-bold text-white mt-2">@ViewData["Title"]</h1>
|
||
</div>
|
||
@if (!isNew)
|
||
{
|
||
<form method="post" asp-page-handler="Duplicate">
|
||
@Html.AntiForgeryToken()
|
||
<input type="hidden" name="id" value="@Model.Sheet.Id" />
|
||
<button type="submit" class="btn btn-secondary">Duplicate</button>
|
||
</form>
|
||
}
|
||
</div>
|
||
|
||
@if (!string.IsNullOrEmpty(Model.Message))
|
||
{
|
||
<div class="p-4 rounded-lg @(Model.IsError ? "bg-red-900/50 border border-red-700 text-red-300" : "bg-green-900/50 border border-green-700 text-green-300")">
|
||
@Model.Message
|
||
</div>
|
||
}
|
||
@if (TempData["Error"] != null)
|
||
{
|
||
<div class="p-4 rounded-lg bg-red-900/50 border border-red-700 text-red-300">
|
||
@TempData["Error"]
|
||
</div>
|
||
}
|
||
|
||
<form method="post" class="space-y-6">
|
||
@Html.AntiForgeryToken()
|
||
<input type="hidden" asp-for="Sheet.Id" />
|
||
<input type="hidden" asp-for="Sheet.CreatedAt" />
|
||
|
||
<!-- Basic Info -->
|
||
<div class="card p-6">
|
||
<h2 class="text-lg font-semibold text-white mb-4">Sprite Sheet Info</h2>
|
||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
|
||
<div class="lg:col-span-2">
|
||
<label class="label">Name</label>
|
||
<input type="text" asp-for="Sheet.Name" class="input" required placeholder="e.g., Skeleton Walk" />
|
||
</div>
|
||
<div class="lg:col-span-2">
|
||
<label class="label">CDN Path</label>
|
||
<div class="flex gap-2">
|
||
<input type="text" asp-for="Sheet.CdnPath" class="input flex-1" required placeholder="textures/mobs/skeleton.png" />
|
||
<button type="button" onclick="showCdnBrowser()" class="btn btn-secondary">Browse</button>
|
||
</div>
|
||
</div>
|
||
<div>
|
||
<label class="label">Sheet Width (px)</label>
|
||
<input type="number" asp-for="Sheet.SheetWidth" class="input" min="1" />
|
||
</div>
|
||
<div>
|
||
<label class="label">Sheet Height (px)</label>
|
||
<input type="number" asp-for="Sheet.SheetHeight" class="input" min="1" />
|
||
</div>
|
||
<div>
|
||
<label class="label">Frame Width (px)</label>
|
||
<input type="number" asp-for="Sheet.FrameWidth" class="input" min="1" />
|
||
</div>
|
||
<div>
|
||
<label class="label">Frame Height (px)</label>
|
||
<input type="number" asp-for="Sheet.FrameHeight" class="input" min="1" />
|
||
</div>
|
||
<div class="flex items-center gap-2 pt-6">
|
||
<input type="checkbox" asp-for="Sheet.IsEnabled" class="w-4 h-4" />
|
||
<label asp-for="Sheet.IsEnabled" class="text-gray-300">Enabled</label>
|
||
</div>
|
||
</div>
|
||
|
||
@* @if (!string.IsNullOrEmpty(Model.Sheet.CdnPath))
|
||
{
|
||
<div class="mt-4 p-4 bg-gray-800 rounded-lg">
|
||
<p class="text-sm text-gray-400 mb-2">Preview (Sheet: @Model.Sheet.SheetWidth x @Model.Sheet.SheetHeight, Frame: @Model.Sheet.FrameWidth x @Model.Sheet.FrameHeight = @Model.Sheet.TotalFrames frames)</p>
|
||
<img src="@Model.CdnBaseUrl/@Model.Sheet.CdnPath" alt="Sprite sheet preview" class="max-h-64 object-contain" style="image-rendering: pixelated;" />
|
||
</div>
|
||
} *@
|
||
@if (!string.IsNullOrEmpty(Model.Sheet.CdnPath))
|
||
{
|
||
<div class="mt-4 grid grid-cols-1 lg:grid-cols-2 gap-4">
|
||
<!-- Preview pane -->
|
||
<div class="p-4 bg-gray-800 rounded-lg">
|
||
<div class="flex items-center justify-between mb-2">
|
||
<p class="text-sm text-gray-400">
|
||
Preview (Sheet: @Model.Sheet.SheetWidth x @Model.Sheet.SheetHeight,
|
||
Frame: @Model.Sheet.FrameWidth x @Model.Sheet.FrameHeight = @Model.Sheet.TotalFrames frames)
|
||
</p>
|
||
|
||
<div class="flex items-center gap-2">
|
||
<label class="text-xs text-gray-400">Zoom</label>
|
||
<input id="sheetZoom" type="range" min="1" max="10" value="3" class="w-28" />
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Hidden image source -->
|
||
<img id="sheetImg"
|
||
src="@Model.CdnBaseUrl/@Model.Sheet.CdnPath"
|
||
alt="Sprite sheet"
|
||
class="hidden"
|
||
style="image-rendering: pixelated;" />
|
||
|
||
<!-- Canvas preview -->
|
||
<div class="overflow-auto rounded border border-gray-700 bg-gray-900">
|
||
<canvas id="sheetCanvas" class="block"></canvas>
|
||
</div>
|
||
|
||
<div class="mt-2 text-xs text-gray-400 flex items-center justify-between">
|
||
<span>Click a cell to copy its frame index.</span>
|
||
<span id="sheetMeta"></span>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Optional: selection / debug pane -->
|
||
<div class="p-4 bg-gray-800 rounded-lg">
|
||
<h3 class="text-sm font-semibold text-white mb-2">Selected Frame</h3>
|
||
<div class="text-sm text-gray-300 space-y-2">
|
||
<div>Frame Index: <span id="selFrameIdx" class="font-mono text-white">-</span></div>
|
||
<div>Row/Col: <span id="selFrameRC" class="font-mono text-white">-</span></div>
|
||
<div>Pixel: <span id="selFramePx" class="font-mono text-white">-</span></div>
|
||
</div>
|
||
|
||
<div class="mt-4">
|
||
<h3 class="text-sm font-semibold text-white mb-2">Quick Insert</h3>
|
||
<p class="text-xs text-gray-400 mb-2">
|
||
This just copies; you can paste into any “Frames” sequence.
|
||
(If you want auto-insert into the last-focused frame input, we can do that too.)
|
||
</p>
|
||
<input id="copyBuffer" class="input font-mono" readonly value="" placeholder="Click a frame..." />
|
||
</div>
|
||
</div>
|
||
</div>
|
||
}
|
||
|
||
</div>
|
||
|
||
<div class="flex gap-4">
|
||
<button type="submit" class="btn btn-primary">Save Sprite Sheet</button>
|
||
<a href="/admin/spritesheets" class="btn btn-secondary">Cancel</a>
|
||
</div>
|
||
</form>
|
||
|
||
<!-- Animations Section (only for existing sheets) -->
|
||
@if (!isNew)
|
||
{
|
||
<div class="card">
|
||
<div class="p-4 border-b border-gray-700 flex items-center justify-between">
|
||
<h2 class="text-lg font-semibold text-white">Animations (@Model.Animations.Count)</h2>
|
||
<button type="button" onclick="showAddAnimModal()" class="btn btn-sm btn-primary">+ Add Animation</button>
|
||
</div>
|
||
<div class="p-4">
|
||
@if (Model.Animations.Count > 0)
|
||
{
|
||
<div class="space-y-3">
|
||
@foreach (var anim in Model.Animations)
|
||
{
|
||
<div class="bg-gray-800 rounded-lg p-4">
|
||
<form method="post" asp-page-handler="UpdateAnimation" class="grid grid-cols-2 md:grid-cols-4 lg:grid-cols-8 gap-3 items-end">
|
||
@Html.AntiForgeryToken()
|
||
<input type="hidden" name="animId" value="@anim.Id" />
|
||
<input type="hidden" name="sheetId" value="@Model.Sheet.Id" />
|
||
|
||
<div>
|
||
<label class="label text-xs">Key</label>
|
||
<input type="text" name="key" value="@anim.Key" class="input input-sm" required />
|
||
</div>
|
||
<div>
|
||
<label class="label text-xs">Name</label>
|
||
<input type="text" name="name" value="@anim.Name" class="input input-sm" />
|
||
</div>
|
||
<div class="lg:col-span-2">
|
||
<label class="label text-xs">Frames (comma-separated)</label>
|
||
<input type="text" name="frameSequence" value="@anim.FrameSequence" class="input input-sm font-mono" required />
|
||
</div>
|
||
<div>
|
||
<label class="label text-xs">FPS</label>
|
||
<input type="number" name="fps" value="@anim.Fps" class="input input-sm" step="0.1" min="0.1" />
|
||
</div>
|
||
<div class="flex items-center gap-4 pt-5">
|
||
<label class="flex items-center gap-1 text-xs text-gray-300">
|
||
<input type="checkbox" name="loop" value="true" checked="@anim.Loop" class="w-3 h-3" />
|
||
Loop
|
||
</label>
|
||
<label class="flex items-center gap-1 text-xs text-gray-300">
|
||
<input type="checkbox" name="flipX" value="true" checked="@anim.FlipX" class="w-3 h-3" />
|
||
FlipX
|
||
</label>
|
||
<label class="flex items-center gap-1 text-xs text-gray-300">
|
||
<input type="checkbox" name="flipY" value="true" checked="@anim.FlipY" class="w-3 h-3" />
|
||
FlipY
|
||
</label>
|
||
<label class="flex items-center gap-1 text-xs text-gray-300">
|
||
<input type="checkbox" name="isEnabled" value="true" checked="@anim.IsEnabled" class="w-3 h-3" />
|
||
On
|
||
</label>
|
||
</div>
|
||
<div class="flex gap-1">
|
||
<button type="submit" class="btn btn-sm btn-secondary flex-1">Save</button>
|
||
<button type="button" onclick="deleteAnim(@anim.Id)" class="btn btn-sm btn-danger">X</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
}
|
||
</div>
|
||
}
|
||
else
|
||
{
|
||
<p class="text-gray-400 text-center py-4">No animations defined. Add animations to use this sprite sheet.</p>
|
||
}
|
||
|
||
<!-- Frame Reference -->
|
||
@* <div class="mt-4 p-4 bg-gray-900 rounded-lg">
|
||
<p class="text-sm text-gray-400 mb-2">Frame Reference (frames are numbered 0 to @(Model.Sheet.TotalFrames - 1), left-to-right, top-to-bottom)</p>
|
||
<div class="grid gap-1" style="grid-template-columns: repeat(@Model.Sheet.Columns, minmax(0, 1fr)); max-width: fit-content;">
|
||
@for (int i = 0; i < Model.Sheet.TotalFrames; i++)
|
||
{
|
||
<div class="w-8 h-8 bg-gray-700 rounded text-xs flex items-center justify-center text-gray-300">@i</div>
|
||
}
|
||
</div>
|
||
</div> *@
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Add Animation Modal -->
|
||
<div id="addAnimModal" class="fixed inset-0 bg-black/50 z-50 hidden items-center justify-center">
|
||
<div class="bg-gray-900 rounded-xl shadow-xl p-6 w-full max-w-lg mx-4 border border-gray-700">
|
||
<h3 class="text-lg font-semibold text-white mb-4">Add Animation</h3>
|
||
<form method="post" asp-page-handler="AddAnimation">
|
||
@Html.AntiForgeryToken()
|
||
<input type="hidden" name="sheetId" value="@Model.Sheet.Id" />
|
||
|
||
<div class="space-y-4">
|
||
<div class="grid grid-cols-2 gap-4">
|
||
<div>
|
||
<label class="label">Key (e.g., walk_down)</label>
|
||
<input type="text" name="key" class="input" required placeholder="idle_down" />
|
||
</div>
|
||
<div>
|
||
<label class="label">Name (optional)</label>
|
||
<input type="text" name="name" class="input" placeholder="Idle Down" />
|
||
</div>
|
||
</div>
|
||
<div>
|
||
<label class="label">Frame Sequence (comma-separated)</label>
|
||
<input type="text" name="frameSequence" class="input font-mono" required placeholder="0,1,2,3" />
|
||
<p class="text-xs text-gray-500 mt-1">e.g., "0,1,2,3" or "4,5,6,7,6,5" for ping-pong</p>
|
||
</div>
|
||
<div class="grid grid-cols-2 gap-4">
|
||
<div>
|
||
<label class="label">FPS</label>
|
||
<input type="number" name="fps" value="8" class="input" step="0.1" min="0.1" />
|
||
</div>
|
||
<div class="flex items-center gap-4 pt-6">
|
||
<label class="flex items-center gap-2 text-gray-300">
|
||
<input type="checkbox" name="loop" value="true" checked class="w-4 h-4" />
|
||
Loop
|
||
</label>
|
||
<label class="flex items-center gap-2 text-gray-300">
|
||
<input type="checkbox" name="flipX" value="true" class="w-4 h-4" />
|
||
Flip X
|
||
</label>
|
||
<label class="flex items-center gap-2 text-gray-300">
|
||
<input type="checkbox" name="flipY" value="true" class="w-4 h-4" />
|
||
Flip Y
|
||
</label>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="flex justify-end gap-3 pt-4">
|
||
<button type="button" onclick="closeAddAnimModal()" class="btn btn-secondary">Cancel</button>
|
||
<button type="submit" class="btn btn-primary">Add Animation</button>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
|
||
<!-- Delete Animation Form (hidden) -->
|
||
<form id="deleteAnimForm" method="post" asp-page-handler="DeleteAnimation" class="hidden">
|
||
@Html.AntiForgeryToken()
|
||
<input type="hidden" name="animId" id="deleteAnimId" value="" />
|
||
<input type="hidden" name="sheetId" value="@Model.Sheet.Id" />
|
||
</form>
|
||
}
|
||
|
||
<!-- CDN Browser Modal -->
|
||
<div id="cdnBrowserModal" class="fixed inset-0 bg-black/50 z-50 hidden items-center justify-center">
|
||
<div class="bg-gray-900 rounded-xl shadow-xl p-6 w-full max-w-2xl mx-4 border border-gray-700 max-h-[80vh] overflow-hidden flex flex-col">
|
||
<h3 class="text-lg font-semibold text-white mb-4">Select Image from CDN</h3>
|
||
<div class="flex-1 overflow-y-auto grid grid-cols-2 md:grid-cols-3 gap-3">
|
||
@foreach (var asset in Model.CdnImages)
|
||
{
|
||
<button type="button" onclick="selectCdnImage('@asset.DownloadPath')" class="p-2 bg-gray-800 rounded-lg hover:bg-gray-700 text-left">
|
||
<img src="@Model.CdnBaseUrl/@asset.DownloadPath" alt="@asset.FilePath" class="w-full h-20 object-contain mb-1" style="image-rendering: pixelated;" />
|
||
<p class="text-xs text-gray-400 truncate">@asset.FilePath</p>
|
||
</button>
|
||
}
|
||
</div>
|
||
<div class="flex justify-end pt-4">
|
||
<button type="button" onclick="closeCdnBrowser()" class="btn btn-secondary">Cancel</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
@section Scripts {
|
||
<script>
|
||
function showAddAnimModal() {
|
||
document.getElementById('addAnimModal').classList.remove('hidden');
|
||
document.getElementById('addAnimModal').classList.add('flex');
|
||
}
|
||
function closeAddAnimModal() {
|
||
document.getElementById('addAnimModal').classList.add('hidden');
|
||
document.getElementById('addAnimModal').classList.remove('flex');
|
||
}
|
||
function deleteAnim(id) {
|
||
if (confirm('Delete this animation?')) {
|
||
document.getElementById('deleteAnimId').value = id;
|
||
document.getElementById('deleteAnimForm').submit();
|
||
}
|
||
}
|
||
function showCdnBrowser() {
|
||
document.getElementById('cdnBrowserModal').classList.remove('hidden');
|
||
document.getElementById('cdnBrowserModal').classList.add('flex');
|
||
}
|
||
function closeCdnBrowser() {
|
||
document.getElementById('cdnBrowserModal').classList.add('hidden');
|
||
document.getElementById('cdnBrowserModal').classList.remove('flex');
|
||
}
|
||
function selectCdnImage(path) {
|
||
document.getElementById('Sheet_CdnPath').value = path;
|
||
closeCdnBrowser();
|
||
}
|
||
document.addEventListener('keydown', e => {
|
||
if (e.key === 'Escape') {
|
||
closeAddAnimModal();
|
||
closeCdnBrowser();
|
||
}
|
||
});
|
||
</script>
|
||
<script>
|
||
(() => {
|
||
const img = document.getElementById('sheetImg');
|
||
const canvas = document.getElementById('sheetCanvas');
|
||
const ctx = canvas.getContext('2d');
|
||
|
||
const zoomEl = document.getElementById('sheetZoom');
|
||
const metaEl = document.getElementById('sheetMeta');
|
||
|
||
const selFrameIdxEl = document.getElementById('selFrameIdx');
|
||
const selFrameRCEl = document.getElementById('selFrameRC');
|
||
const selFramePxEl = document.getElementById('selFramePx');
|
||
const copyBufferEl = document.getElementById('copyBuffer');
|
||
|
||
// Read from your inputs so preview updates before save
|
||
const getNum = (id, fallback) => {
|
||
const el = document.getElementById(id);
|
||
const v = el ? parseInt(el.value, 10) : NaN;
|
||
return Number.isFinite(v) && v > 0 ? v : fallback;
|
||
};
|
||
|
||
function getSheetConfig() {
|
||
const sheetW = getNum('Sheet_SheetWidth', img.naturalWidth || 1);
|
||
const sheetH = getNum('Sheet_SheetHeight', img.naturalHeight || 1);
|
||
const frameW = getNum('Sheet_FrameWidth', 64);
|
||
const frameH = getNum('Sheet_FrameHeight', 64);
|
||
|
||
const cols = Math.max(1, Math.floor(sheetW / frameW));
|
||
const rows = Math.max(1, Math.floor(sheetH / frameH));
|
||
const total = cols * rows;
|
||
|
||
return { sheetW, sheetH, frameW, frameH, cols, rows, total };
|
||
}
|
||
|
||
function draw() {
|
||
if (!img || !img.complete || img.naturalWidth === 0) return;
|
||
|
||
const zoom = parseInt(zoomEl?.value || '3', 10);
|
||
const { sheetW, sheetH, frameW, frameH, cols, rows, total } = getSheetConfig();
|
||
|
||
// Canvas pixel size = scaled (so it stays crisp)
|
||
canvas.width = sheetW * zoom;
|
||
canvas.height = sheetH * zoom;
|
||
|
||
// Crisp scaling
|
||
ctx.imageSmoothingEnabled = false;
|
||
|
||
// Draw sprite sheet scaled
|
||
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||
ctx.drawImage(img, 0, 0, sheetW * zoom, sheetH * zoom);
|
||
|
||
// Grid lines
|
||
ctx.lineWidth = 1;
|
||
ctx.strokeStyle = 'rgba(255,255,255,0.18)';
|
||
|
||
for (let c = 0; c <= cols; c++) {
|
||
const x = c * frameW * zoom + 0.5;
|
||
ctx.beginPath();
|
||
ctx.moveTo(x, 0);
|
||
ctx.lineTo(x, rows * frameH * zoom);
|
||
ctx.stroke();
|
||
}
|
||
|
||
for (let r = 0; r <= rows; r++) {
|
||
const y = r * frameH * zoom + 0.5;
|
||
ctx.beginPath();
|
||
ctx.moveTo(0, y);
|
||
ctx.lineTo(cols * frameW * zoom, y);
|
||
ctx.stroke();
|
||
}
|
||
|
||
// Frame numbers
|
||
// Draw a subtle shadow box + text so it reads on any background
|
||
ctx.font = `${Math.max(10, 10 * zoom)}px ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace`;
|
||
ctx.textBaseline = 'top';
|
||
|
||
for (let r = 0; r < rows; r++) {
|
||
for (let c = 0; c < cols; c++) {
|
||
const idx = r * cols + c;
|
||
|
||
const px = c * frameW * zoom;
|
||
const py = r * frameH * zoom;
|
||
|
||
// background pill
|
||
const pad = 2 * zoom;
|
||
const label = String(idx);
|
||
const metrics = ctx.measureText(label);
|
||
const boxW = metrics.width + pad * 2;
|
||
const boxH = (12 * zoom) + pad * 2;
|
||
|
||
ctx.fillStyle = 'rgba(0,0,0,0.45)';
|
||
ctx.fillRect(px + 2, py + 2, boxW, boxH);
|
||
|
||
// text
|
||
ctx.fillStyle = 'rgba(255,255,255,0.90)';
|
||
ctx.fillText(label, px + 2 + pad, py + 2 + pad);
|
||
}
|
||
}
|
||
|
||
if (metaEl) {
|
||
metaEl.textContent = `${cols} × ${rows} = ${total} frames`;
|
||
}
|
||
}
|
||
|
||
function canvasToFrameIndex(evt) {
|
||
const zoom = parseInt(zoomEl?.value || '3', 10);
|
||
const { frameW, frameH, cols, rows } = getSheetConfig();
|
||
|
||
const rect = canvas.getBoundingClientRect();
|
||
const x = Math.floor((evt.clientX - rect.left) / zoom);
|
||
const y = Math.floor((evt.clientY - rect.top) / zoom);
|
||
|
||
const col = Math.floor(x / frameW);
|
||
const row = Math.floor(y / frameH);
|
||
|
||
if (col < 0 || col >= cols || row < 0 || row >= rows) return null;
|
||
|
||
const idx = row * cols + col;
|
||
return { idx, row, col, x, y };
|
||
}
|
||
|
||
function onClick(evt) {
|
||
const hit = canvasToFrameIndex(evt);
|
||
if (!hit) return;
|
||
|
||
selFrameIdxEl && (selFrameIdxEl.textContent = hit.idx);
|
||
selFrameRCEl && (selFrameRCEl.textContent = `${hit.row},${hit.col}`);
|
||
selFramePxEl && (selFramePxEl.textContent = `${hit.x},${hit.y}`);
|
||
|
||
if (copyBufferEl) copyBufferEl.value = hit.idx;
|
||
|
||
// Copy to clipboard (best-effort)
|
||
if (navigator.clipboard?.writeText) {
|
||
navigator.clipboard.writeText(String(hit.idx)).catch(() => {});
|
||
}
|
||
}
|
||
|
||
// Hook redraw to changes in relevant inputs
|
||
const watchIds = [
|
||
'Sheet_SheetWidth', 'Sheet_SheetHeight',
|
||
'Sheet_FrameWidth', 'Sheet_FrameHeight',
|
||
'Sheet_CdnPath'
|
||
];
|
||
|
||
function hookRedraw() {
|
||
watchIds.forEach(id => {
|
||
const el = document.getElementById(id);
|
||
if (!el) return;
|
||
el.addEventListener('input', () => {
|
||
// If CDN path changes, update img src and redraw on load
|
||
if (id === 'Sheet_CdnPath') {
|
||
// your CDN base is server-side; we won’t rebuild URL here.
|
||
// Prefer: only redraw after postback OR implement a client-side base variable.
|
||
// For now: just redraw grid w/ existing img.
|
||
}
|
||
draw();
|
||
});
|
||
});
|
||
|
||
zoomEl?.addEventListener('input', draw);
|
||
canvas?.addEventListener('click', onClick);
|
||
}
|
||
|
||
if (!img || !canvas || !ctx) return;
|
||
|
||
img.addEventListener('load', draw);
|
||
if (img.complete) draw();
|
||
hookRedraw();
|
||
})();
|
||
</script>
|
||
|
||
}
|