commit a7733b5eee149a449ce145d6eb3e4c78b6e5c5a2 Author: MeowcaTheoRange Date: Sat Nov 18 14:12:42 2023 -0600 SteamTheWoz v2 diff --git a/.gitea/workflows/vercel.yaml b/.gitea/workflows/vercel.yaml new file mode 100644 index 0000000..727b98b --- /dev/null +++ b/.gitea/workflows/vercel.yaml @@ -0,0 +1,21 @@ +name: Vercel Production Deployment +env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} +on: + push: + branches: + - main +jobs: + Deploy-Production: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Install Vercel CLI + run: npm install --global vercel@latest + - name: Pull Vercel Environment Information + run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} + - name: Build Project Artifacts + run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }} + - name: Deploy Project Artifacts to Vercel + run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e985853 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.vercel diff --git a/index.html b/index.html new file mode 100644 index 0000000..13af261 --- /dev/null +++ b/index.html @@ -0,0 +1,156 @@ + + + + + + HexFlagGen + + + + + +
+<<<<<<< HEAD +

HexFlagGen

+======= +

SteamTheWoz

+>>>>>>> d5e5502 (SteamTheWoz v2) +
+

by MeowcaTheoRange

+<<<<<<< HEAD +

Make a flag out of the hexadecimal bytes of your choice.

+
+
+
+
+
+ +
+
+ +
+ +
+ + +
+
+
+

+ Hex: ... +

+ +======= +

Make a Scott The Woz thumbnail out of any Steam game.

+
+
+
+ +
+ +
+
+
+ + + ( + )
+ + +
+
+
+ +>>>>>>> d5e5502 (SteamTheWoz v2) +
+ + + diff --git a/public/woz0.png b/public/woz0.png new file mode 100644 index 0000000..124690b Binary files /dev/null and b/public/woz0.png differ diff --git a/public/woz1.png b/public/woz1.png new file mode 100644 index 0000000..b7e2849 Binary files /dev/null and b/public/woz1.png differ diff --git a/public/woz2.png b/public/woz2.png new file mode 100644 index 0000000..5dde1b0 Binary files /dev/null and b/public/woz2.png differ diff --git a/public/woz3.png b/public/woz3.png new file mode 100644 index 0000000..1fb567e Binary files /dev/null and b/public/woz3.png differ diff --git a/public/woz4.png b/public/woz4.png new file mode 100644 index 0000000..0911dbe Binary files /dev/null and b/public/woz4.png differ diff --git a/public/woz5.png b/public/woz5.png new file mode 100644 index 0000000..f2ebe73 Binary files /dev/null and b/public/woz5.png differ diff --git a/public/woz6.png b/public/woz6.png new file mode 100644 index 0000000..b2dbd7b Binary files /dev/null and b/public/woz6.png differ diff --git a/public/woz7.png b/public/woz7.png new file mode 100644 index 0000000..7e29f70 Binary files /dev/null and b/public/woz7.png differ diff --git a/public/woz8.png b/public/woz8.png new file mode 100644 index 0000000..6b311bf Binary files /dev/null and b/public/woz8.png differ diff --git a/public/woz9.png b/public/woz9.png new file mode 100644 index 0000000..a8a253b Binary files /dev/null and b/public/woz9.png differ diff --git a/public/wozstash.png b/public/wozstash.png new file mode 100644 index 0000000..4d91e4f Binary files /dev/null and b/public/wozstash.png differ diff --git a/scripts/index.js b/scripts/index.js new file mode 100644 index 0000000..2839481 --- /dev/null +++ b/scripts/index.js @@ -0,0 +1,192 @@ +const canvas = document.getElementById("canvas"); +const data = document.getElementById("data"); +const generateButton = document.getElementById("generateButton"); +const hexdisplay = document.getElementById("hexdisplay"); + +<<<<<<< HEAD +const size_width = document.getElementById("size_width"); +const size_height = document.getElementById("size_height"); +const flag_type = document.getElementById("flag_type"); +======= +const steam_game = document.getElementById("steam_game"); +const scott_index = document.getElementById("scott_index"); +const stash = document.getElementById("stash"); +const align = document.getElementById("align"); +>>>>>>> d5e5502 (SteamTheWoz v2) + +const root = document.querySelector(":root"); + +const ctx = canvas.getContext("2d"); + +<<<<<<< HEAD +function getData() { + data.value = data.value.toUpperCase().replace(/[^0-9A-F]*/g, ""); + + var hexValue = data.value.match(/.{1,2}/g).map((x) => x.padStart(2, "0")); + + hexdisplay.innerHTML = hexValue.join(" "); + + createFlag( + hexValue.join("").match(/.{1,6}/g), + size_width.value, + size_height.value, + flag_type.value + ); + var ac = averageColors(hexValue); + console.log(ac); + root.style.setProperty( + "--background-color", + arrayToColor(darkenColor(ac, 70)) + ); + root.style.setProperty("--color", arrayToColor(lightenColor(ac, 70))); + root.style.setProperty("--accent-color", arrayToColor(ac)); + root.style.setProperty( + "--accent-color-fg", + arrayToColor(lightenColor(ac, 90)) + ); +} +generateButton.addEventListener("click", getData); + +function averageColors(hex) { + var averageSet = [[], [], []]; + hex.forEach((number, index) => { + averageSet[index % 3].push(parseInt(number, 16)); + }); + return averageSet.map((array) => + Math.floor(array.reduce((a, b) => a + b) / array.length) + ); +} + +function createFlag(hex, w, h, type) { + canvas.width = w; + canvas.height = h; + + // Initialize stuff + + var width = ctx.canvas.width; + var height = ctx.canvas.height; + var textHeight = 24; + ctx.font = `${textHeight}px "Lexend Deca"`; + + ctx.clearRect(0, 0, width, height); + + console.log(hex); + + var hexColors = []; + var excessHex = ""; + + hex.forEach((compound) => { + if (compound.length < 6) excessHex = compound; + else hexColors.push(compound); + }); + + var rectWidth = width / hexColors.length; + var rectHeight = height / hexColors.length; + for (color in hexColors) { + ctx.fillStyle = "#" + hexColors[color]; + if (type === "horiz") ctx.fillRect(rectWidth * color, 0, rectWidth, height); + else if (type === "vert") + ctx.fillRect(0, rectHeight * color, width, rectHeight); + } + if (excessHex.length > 0) { + var text = "+ " + excessHex.match(/.{1,2}/g).join(" "); + var textWidth = ctx.measureText(text).width; + ctx.strokeStyle = "black"; + ctx.lineWidth = 4; + ctx.fillStyle = "white"; + ctx.strokeText(text, width - (textWidth + 8), height - textHeight / 2); + ctx.fillText(text, width - (textWidth + 8), height - textHeight / 2); + } +} + +const clamp = (n, mi, ma) => Math.max(mi, Math.min(n, ma)); + +function lightenColor(color, mult) { + return [ + clamp(color[0] + (mult / 100) * (255 - color[0]), 0, 255), + clamp(color[1] + (mult / 100) * (255 - color[1]), 0, 255), + clamp(color[2] + (mult / 100) * (255 - color[2]), 0, 255), + ]; +} +function darkenColor(color, mult) { + return [ + clamp(color[0] - (mult / 100) * color[0], 0, 255), + clamp(color[1] - (mult / 100) * color[1], 0, 255), + clamp(color[2] - (mult / 100) * color[2], 0, 255), + ]; +} + +function arrayToColor(color) { + return ( + "#" + color.map((x) => Math.floor(x).toString(16).padStart(2, "0")).join("") + ); +} +======= +async function loadImage(url) { + return new Promise((r) => { + let img = new Image(); + img.onload = () => r(img); + img.src = url; + }); +} + +async function getScott() { + var gameID = steam_game.value; + var scottID = scott_index.value; + var alignment = align.value; + + const ctx = canvas.getContext("2d"); + + var hero = await loadImage( + `https://cdn.cloudflare.steamstatic.com/steam/apps/${gameID}/library_hero.jpg` + ).catch(() => "404"); + var scott = await loadImage( + stash.checked ? `public/wozstash.png` : `public/woz${scottID}.png` + ).catch(() => "404"); + var logo = await loadImage( + `https://cdn.cloudflare.steamstatic.com/steam/apps/${gameID}/logo.png` + ).catch(() => "404"); + + if (scott === "404") { + console.log("Scott error: " + scottID); + return `Scott ID ${scottID} does not exist.`; + } + if (hero === "404" || logo === "404") { + console.log("404 error: " + gameID); + return `Steam ID ${gameID} does not have logo, hero image, or does not exist.`; + } + var xalign; + switch (alignment) { + case "left": + xalign = 0; + break; + case "right": + xalign = -950; + break; + default: + xalign = -505; + break; + } + console.log("Generating: " + gameID); + ctx.drawImage(hero, xalign, 0, 2229, 720); + ctx.drawImage(scott, 0, 0, 1280, 720); + + const newHeight = 800 / (logo.width / logo.height); + ctx.fillStyle = "#000"; + ctx.shadowColor = "#000"; + ctx.shadowBlur = 16; + + if (stash.checked) + ctx.drawImage( + logo, + 400, + Math.min(560 - newHeight / 2, 669 - newHeight), + 800, + newHeight + ); + else + ctx.drawImage(logo, 64, Math.max(240 - newHeight / 2, 32), 800, newHeight); +} + +generateButton.addEventListener("click", getScott); +>>>>>>> d5e5502 (SteamTheWoz v2)