-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
312 lines (288 loc) · 18.2 KB
/
Copy pathindex.html
File metadata and controls
312 lines (288 loc) · 18.2 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<title>RBX2PT-Reloaded</title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=Syne:wght@700;800&family=DM+Sans:wght@300;400;500&display=swap" rel="stylesheet">
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
--pink: #bf4197; --blue: #257fdb; --bg: #141414; --surface: #1e1e1e;
--border: #333; --text: #f0f0f0; --muted: #888; --radius: 14px;
}
body { background: var(--bg); font-family: 'DM Sans', sans-serif; color: var(--text); min-height: 100vh; }
.hero { position: relative; overflow: hidden; padding: 52px 24px 80px; text-align: center; background: linear-gradient(135deg, #1a0d14 0%, #0d1a2e 100%); }
.hero::before { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse 60% 80% at 20% 50%, rgba(191,65,151,0.18) 0%, transparent 70%), radial-gradient(ellipse 50% 70% at 80% 40%, rgba(37,127,219,0.15) 0%, transparent 70%); pointer-events: none; }
.hero-eyebrow { font-size: 0.7rem; font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase; color: var(--pink); margin-bottom: 12px; }
.hero h1 { font-family: 'Syne', sans-serif; font-size: clamp(1.8rem, 5vw, 3.2rem); font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; background: linear-gradient(100deg, #fff 30%, #bf4197 70%, #257fdb 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; margin-bottom: 14px; }
.hero-sub { font-size: 0.85rem; color: var(--muted); }
.hero-sub a { color: #7ab8f5; text-decoration: none; }
.hero-sub a:hover { text-decoration: underline; }
.main { max-width: 720px; margin: 0 auto; padding: 0 20px 60px; }
.mode-row { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: -28px; margin-bottom: 28px; position: relative; z-index: 10; }
.mode-pill { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; display: flex; align-items: center; padding: 5px; gap: 4px; box-shadow: 0 4px 24px rgba(0,0,0,0.4); }
.mode-btn { font-family: 'Syne', sans-serif; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.08em; padding: 8px 22px; border-radius: 999px; border: none; cursor: pointer; transition: background 0.2s, color 0.2s; background: transparent; color: var(--muted); }
.mode-btn.active { background: linear-gradient(90deg, var(--pink), var(--blue)); color: #fff; }
.upload-wrap { margin-bottom: 20px; }
.upload-zone { border: 1.5px dashed var(--border); border-radius: var(--radius); background: var(--surface); padding: 48px 24px; display: flex; flex-direction: column; align-items: center; gap: 10px; cursor: pointer; transition: border-color 0.2s, background 0.2s, box-shadow 0.2s; text-align: center; }
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--pink); background: rgba(191,65,151,0.06); box-shadow: 0 0 0 4px rgba(191,65,151,0.08); }
.upload-icon { width: 40px; height: 40px; color: var(--pink); opacity: 0.8; }
.upload-label { font-size: 0.95rem; font-weight: 500; color: var(--text); }
.upload-hint { font-size: 0.78rem; color: var(--muted); }
.preview-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: none; }
.preview-card.visible { display: block; }
.preview-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.preview-title { font-family: 'Syne', sans-serif; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.06em; color: var(--muted); text-transform: uppercase; }
.preview-badge { font-size: 0.7rem; font-weight: 500; padding: 3px 10px; border-radius: 999px; background: rgba(191,65,151,0.15); color: var(--pink); border: 1px solid rgba(191,65,151,0.3); }
.canvas-wrap { background-color: #444; background-image: linear-gradient(45deg, #555 25%, transparent 25%), linear-gradient(-45deg, #555 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #555 75%), linear-gradient(-45deg, transparent 75%, #555 75%); background-size: 16px 16px; background-position: 0 0, 0 8px, 8px -8px, -8px 0px; padding: 16px; display: flex; justify-content: center; }
#previewCanvas { max-width: 100%; height: auto; display: block; border-radius: 6px; transition: opacity 0.15s; }
#previewCanvas.switching { opacity: 0; }
.preview-footer { padding: 14px 18px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.preview-filename { font-size: 0.75rem; color: var(--muted); font-family: monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.btn-download { font-family: 'Syne', sans-serif; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.06em; padding: 10px 22px; border-radius: 999px; border: none; cursor: pointer; background: linear-gradient(90deg, var(--pink), var(--blue)); color: #fff; display: flex; align-items: center; gap: 8px; transition: opacity 0.15s, transform 0.15s; flex-shrink: 0; }
.btn-download:hover { opacity: 0.88; transform: translateY(-1px); }
.btn-download:active { transform: translateY(0); opacity: 1; }
.btn-download svg { width: 14px; height: 14px; }
#imageInput { display: none; }
</style>
</head>
<body>
<div class="hero">
<p class="hero-eyebrow">Clothing Converter</p>
<h1>Roblox → Polytoria</h1>
<p class="hero-sub">
Also see: <a href="pt2rbx.html">PT2RBX — Polytoria to Roblox</a>
·
<a href="pantsshirtcombiner.html">Shirt + Pants Combiner</a>
·
<a href="preview.html">3D Preview</a>
</p>
</div>
<div class="main">
<div class="mode-row">
<div class="mode-pill">
<button class="mode-btn active" id="btn-shirt">SHIRT</button>
<button class="mode-btn" id="btn-pants">PANTS</button>
</div>
</div>
<div class="upload-wrap">
<div class="upload-zone" id="uploadZone">
<svg class="upload-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round">
<path d="M12 16V4m0 0L8 8m4-4l4 4"/>
<path d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1"/>
</svg>
<span class="upload-label">Drop your Roblox template here</span>
<span class="upload-hint">or click to browse — PNG, JPG accepted</span>
</div>
</div>
<div class="preview-card" id="previewCard">
<div class="preview-header">
<span class="preview-title">Output Preview</span>
<span class="preview-badge" id="modeBadge">SHIRT</span>
</div>
<div class="canvas-wrap">
<canvas id="previewCanvas" width="1024" height="1024"></canvas>
</div>
<div class="preview-footer">
<span class="preview-filename" id="filenameDisplay">—</span>
<button class="btn-download" id="btnDownload">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<path d="M12 4v12m0 0l-4-4m4 4l4-4"/>
<path d="M4 18h16"/>
</svg>
Download
</button>
</div>
</div>
</div>
<input type="file" accept="image/*" id="imageInput">
<script>
// ── Off-screen canvases ────────────────────────────────────────────────
const sourceCanvas = document.createElement('canvas');
sourceCanvas.width = 585; sourceCanvas.height = 559;
const sourceCtx = sourceCanvas.getContext('2d', { willReadFrequently: true });
const shirtCanvas = document.createElement('canvas');
shirtCanvas.width = 1024; shirtCanvas.height = 1024;
const shirtCtx = shirtCanvas.getContext('2d', { willReadFrequently: true });
const pantsCanvas = document.createElement('canvas');
pantsCanvas.width = 1024; pantsCanvas.height = 1024;
const pantsCtx = pantsCanvas.getContext('2d', { willReadFrequently: true });
const previewCanvas = document.getElementById('previewCanvas');
const previewCtx = previewCanvas.getContext('2d');
// ── State ─────────────────────────────────────────────────────────────
let mode = 'shirt', hasImage = false;
const filenames = { shirt: '', pants: '' };
const recentSuffixes = new Set();
// ── DOM refs ──────────────────────────────────────────────────────────
const uploadZone = document.getElementById('uploadZone');
const imageInput = document.getElementById('imageInput');
const previewCard = document.getElementById('previewCard');
const btnDownload = document.getElementById('btnDownload');
const filenameDisplay = document.getElementById('filenameDisplay');
const modeBadge = document.getElementById('modeBadge');
const btnShirt = document.getElementById('btn-shirt');
const btnPants = document.getElementById('btn-pants');
// ── Mode toggle ───────────────────────────────────────────────────────
btnShirt.addEventListener('click', () => setMode('shirt'));
btnPants.addEventListener('click', () => setMode('pants'));
function setMode(m) {
if (mode === m) return;
mode = m;
btnShirt.classList.toggle('active', m === 'shirt');
btnPants.classList.toggle('active', m === 'pants');
if (hasImage) swapPreview();
}
function swapPreview() {
previewCanvas.classList.add('switching');
setTimeout(() => {
copyToPreview(mode === 'shirt' ? shirtCanvas : pantsCanvas);
modeBadge.textContent = mode === 'shirt' ? 'SHIRT' : 'PANTS';
filenameDisplay.textContent = filenames[mode];
previewCanvas.classList.remove('switching');
}, 150);
}
function copyToPreview(src) {
previewCtx.clearRect(0, 0, previewCanvas.width, previewCanvas.height);
previewCtx.drawImage(src, 0, 0);
}
// ── Filename generation ───────────────────────────────────────────────
function generateFilename(type) {
const now = new Date();
const dd = String(now.getDate()).padStart(2, '0');
const mm = String(now.getMonth() + 1).padStart(2, '0');
const yy = String(now.getFullYear()).slice(-2);
const dateStr = dd + mm + yy;
let suffix, attempts = 0;
do { suffix = String(Math.floor(100000 + Math.random() * 900000)); attempts++; }
while (recentSuffixes.has(suffix) && attempts < 100);
recentSuffixes.add(suffix);
if (recentSuffixes.size > 40) recentSuffixes.delete(recentSuffixes.values().next().value);
return `${type === 'pants' ? 'Pants' : 'Shirt'}_${dateStr}${suffix}.png`;
}
// ── Upload handling ───────────────────────────────────────────────────
uploadZone.addEventListener('click', () => imageInput.click());
uploadZone.addEventListener('dragover', (e) => { e.preventDefault(); uploadZone.classList.add('drag-over'); });
uploadZone.addEventListener('dragleave', () => uploadZone.classList.remove('drag-over'));
uploadZone.addEventListener('drop', (e) => {
e.preventDefault(); uploadZone.classList.remove('drag-over');
const file = e.dataTransfer.files[0];
if (file) processFile(file);
});
imageInput.addEventListener('change', (e) => { if (e.target.files[0]) processFile(e.target.files[0]); imageInput.value = ''; });
function processFile(file) {
const reader = new FileReader();
reader.onload = (event) => {
const img = new Image();
img.onload = () => {
sourceCtx.clearRect(0, 0, sourceCanvas.width, sourceCanvas.height);
sourceCtx.drawImage(img, 0, 0);
renderBoth();
};
img.src = event.target.result;
};
reader.readAsDataURL(file);
}
// ── Alpha check (on inner region, skipping outline border) ───────────
function regionHasPixels(srcX, srcY, srcW, srcH) {
const INSET = 4;
const x = Math.max(0, Math.floor(srcX + INSET));
const y = Math.max(0, Math.floor(srcY + INSET));
const w = Math.min(sourceCanvas.width - x, Math.ceil(srcW - INSET * 2));
const h = Math.min(sourceCanvas.height - y, Math.ceil(srcH - INSET * 2));
if (w <= 0 || h <= 0) return false;
const data = sourceCtx.getImageData(x, y, w, h).data;
for (let i = 3; i < data.length; i += 4) if (data[i] > 0) return true;
return false;
}
// ── Blit: strips the 4px Roblox outline border, scales inner art to dst,
// then bleeds 1px outward on all dst edges to close UV seam gaps. ──
const OUTLINE_INSET = 4;
const BLEED = 1;
function blitRegion(dstCtx, srcX, srcY, srcW, srcH, dstX, dstY, dstW, dstH) {
if (!regionHasPixels(srcX, srcY, srcW, srcH)) return;
// Inner content only — skip the black outline border
const iX = srcX + OUTLINE_INSET;
const iY = srcY + OUTLINE_INSET;
const iW = srcW - OUTLINE_INSET * 2;
const iH = srcH - OUTLINE_INSET * 2;
// Expand dst by 1px to bleed into UV seam gutters
const tmp = document.createElement('canvas');
tmp.width = dstW + BLEED * 2;
tmp.height = dstH + BLEED * 2;
const tmpCtx = tmp.getContext('2d');
tmpCtx.imageSmoothingEnabled = true;
tmpCtx.imageSmoothingQuality = 'high';
tmpCtx.drawImage(sourceCanvas, iX, iY, iW, iH, 0, 0, tmp.width, tmp.height);
dstCtx.drawImage(tmp, dstX - BLEED, dstY - BLEED);
}
// ── Render both outputs ───────────────────────────────────────────────
function renderBoth() {
shirtCtx.clearRect(0, 0, 1024, 1024);
pantsCtx.clearRect(0, 0, 1024, 1024);
[shirtCtx, pantsCtx].forEach(ctx => {
blitRegion(ctx, 231, 8, 128, 66, 439, 7, 146, 96); // Top cap
blitRegion(ctx, 231, 74, 128, 128, 440, 103, 144, 290); // Front
blitRegion(ctx, 165, 74, 64, 128, 351, 103, 87, 290); // Left → PT R col
blitRegion(ctx, 361, 74, 64, 128, 586, 103, 87, 290); // Right → PT L col
blitRegion(ctx, 231, 204, 128, 64, 439, 394, 146, 95); // Bottom tab
blitRegion(ctx, 427, 74, 128, 128, 439, 519, 146, 290); // Back
});
// PT Right Leg ← Roblox Left Leg
blitRegion(pantsCtx, 217, 290, 64, 63, 206, 597, 64, 64); // top cap
blitRegion(pantsCtx, 217, 355, 64, 128, 206, 661, 64, 292); // F face
blitRegion(pantsCtx, 151, 355, 64, 128, 142, 661, 64, 292); // R face
blitRegion(pantsCtx, 85, 355, 64, 128, 79, 661, 63, 292); // B face
blitRegion(pantsCtx, 19, 355, 64, 128, 14, 661, 63, 292); // L face
blitRegion(pantsCtx, 217, 485, 64, 64, 206, 953, 64, 64); // bot cap
// PT Left Leg ← Roblox Right Leg
blitRegion(pantsCtx, 308, 290, 64, 63, 754, 597, 64, 64); // top cap
blitRegion(pantsCtx, 308, 355, 64, 128, 754, 661, 64, 292); // F face
blitRegion(pantsCtx, 374, 355, 64, 128, 819, 661, 62, 292); // L face
blitRegion(pantsCtx, 440, 355, 64, 128, 882, 661, 64, 292); // B face
blitRegion(pantsCtx, 506, 355, 64, 128, 946, 661, 64, 292); // R face
blitRegion(pantsCtx, 308, 485, 64, 64, 754, 953, 64, 64); // bot cap
// PT Right Arm ← Roblox Left Arm
blitRegion(shirtCtx, 217, 289, 64, 64, 204, 7, 66, 64); // top cap
blitRegion(shirtCtx, 217, 355, 64, 128, 204, 71, 66, 290); // F face
blitRegion(shirtCtx, 151, 355, 64, 128, 138, 71, 66, 290); // R face
blitRegion(shirtCtx, 85, 355, 64, 128, 72, 71, 66, 290); // B face
blitRegion(shirtCtx, 19, 355, 64, 128, 6, 71, 65, 290); // L face
blitRegion(shirtCtx, 217, 485, 64, 64, 204, 361, 66, 64); // bot cap
// PT Left Arm ← Roblox Right Arm
blitRegion(shirtCtx, 308, 289, 64, 64, 754, 7, 66, 64); // top cap
blitRegion(shirtCtx, 308, 355, 64, 128, 754, 71, 66, 290); // F face
blitRegion(shirtCtx, 374, 355, 64, 128, 820, 71, 65, 290); // L face
blitRegion(shirtCtx, 440, 355, 64, 128, 886, 71, 66, 290); // B face
blitRegion(shirtCtx, 506, 355, 64, 128, 952, 71, 66, 290); // R face
blitRegion(shirtCtx, 308, 485, 64, 64, 754, 361, 66, 64); // bot cap
// ── Generate filenames & show preview ─────────────────────────────
filenames.shirt = generateFilename('shirt');
filenames.pants = generateFilename('pants');
hasImage = true;
copyToPreview(mode === 'shirt' ? shirtCanvas : pantsCanvas);
modeBadge.textContent = mode === 'shirt' ? 'SHIRT' : 'PANTS';
filenameDisplay.textContent = filenames[mode];
previewCard.classList.add('visible');
}
// ── Download ──────────────────────────────────────────────────────────
btnDownload.addEventListener('click', () => {
const src = mode === 'shirt' ? shirtCanvas : pantsCanvas;
const link = document.createElement('a');
link.href = src.toDataURL('image/png');
link.download = filenames[mode];
link.click();
setTimeout(() => {
shirtCtx.clearRect(0, 0, 1024, 1024);
pantsCtx.clearRect(0, 0, 1024, 1024);
sourceCtx.clearRect(0, 0, 585, 559);
previewCtx.clearRect(0, 0, 1024, 1024);
previewCard.classList.remove('visible');
filenameDisplay.textContent = '—';
filenames.shirt = ''; filenames.pants = '';
hasImage = false;
}, 300);
});
</script>
</body>
</html>