diff --git a/looks.html b/looks.html index f53c736..6b834ab 100644 --- a/looks.html +++ b/looks.html @@ -49,6 +49,10 @@
+

Or use your own picture of them

+ A picture you made or a photograph you hold the rights to. A side-by-side (two looks in one picture) is split into its halves and both are used. The reference sheets are drawn from it at once (about $0.27). +
+
@@ -136,10 +140,10 @@ : (lc.error ? lc.error : (items.length ? items.length + " candidates, drawn " + new Date(lc.made_at).toLocaleString() : "")); $("grid").innerHTML = items.map(function (it, i) { var chosen = lc.chosen === i; - return '
Candidate ' + (i + 1) + '' + (chosen ? ' — cast' : '') + return '
Candidate ' + (i + 1) + '' + (it.supplied ? ' — your own picture' + (it.note ? ' (' + esc(it.note) + ')' : '') + '' : '') + (chosen ? ' — cast' : '') + '
' + (it.urls || []).map(function (u, k) { return '
' + (u ? '' : '
not drawn
') - + '
' + esc((looks[k] || {}).name || ("Look " + (k + 1))) + '
'; }).join("") + + '
' + esc(it.supplied ? (u ? "as supplied" : "") : ((looks[k] || {}).name || ("Look " + (k + 1)))) + '
'; }).join("") + '
' + 'Draws the head, front, side and back sheets from this face (about $' + (4 * PER_PICTURE).toFixed(2) + ').
' @@ -159,6 +163,22 @@ return true; } $("save").addEventListener("click", saveWho); + $("own").addEventListener("change", async function () { + var file = $("own").files[0]; + if (!file) return; + if (!/^image\//.test(file.type)) { msg("Please choose an image file."); $("own").value = ""; return; } + $("ownstate").textContent = "preparing…"; + var img; + try { img = await resizeImage(file, 2400, 0.92); } + catch (err) { $("ownstate").textContent = ""; msg(err.message || "Could not read that picture."); $("own").value = ""; return; } + if (!(await saveWho())) return; + $("ownstate").textContent = "uploading…"; + var r = await api("cast_from_picture", { draft_id: DID, character_id: CID, data_b64: img.b64, note: file.name }); + $("own").value = ""; $("ownstate").textContent = ""; + if (!r.ok) { msg(r.error || "That upload did not work."); return; } + msg("Your picture is candidate " + (r.index + 1) + (r.pieces > 1 ? " (split in " + r.pieces + ")" : "") + "; drawing the reference sheets from it (about $" + r.usd + ").", "ok"); + load(); + }); $("draw").addEventListener("click", async function () { var looks = readLooks(); if (!looks.length) { msg("Say what they wear in at least one look."); return; }