merge conflicts, because we didn't have enough of those

This commit is contained in:
MeowcaTheoRange 2023-11-18 14:29:53 -06:00
parent a7733b5eee
commit 2a67dbfdd0
2 changed files with 9 additions and 176 deletions

View file

@ -3,7 +3,7 @@
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>HexFlagGen</title>
<title>WozSteamGem</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="https://cdn.abtmtr.link/cdn/css/normal.css" />
<style>
@ -12,30 +12,22 @@
:root {
--base-scale: 16px;
--background-color: hsl(0, 0%, 15%);
--color: hsl(0, 0%, 85%);
--accent-color: #808080;
--accent-color-fg: hsl(0, 0%, 95%);
--background-color: hsl(232, 95%, 15%);
--color: hsl(232, 95%, 85%);
--accent-color: #3a55fa;
--accent-color-fg: hsl(232, 95%, 95%);
--font-family: "Lexend Deca";
--document-width: 40em;
}
* {
<<<<<<< HEAD
transition: background-color 0.125s, color 0.125s;
=======
transition: background-color 0.125s, color 0.125s, opacity 0.125s;
>>>>>>> d5e5502 (SteamTheWoz v2)
}
</style>
</head>
<body>
<section>
<<<<<<< HEAD
<h1>HexFlagGen</h1>
=======
<h1>SteamTheWoz</h1>
>>>>>>> d5e5502 (SteamTheWoz v2)
<h1>WozSteamGem</h1>
<label for="size_width"
><input
type="number"
@ -56,52 +48,6 @@
Base style
</label>
<p>by <a href="https://abtmtr.link/">MeowcaTheoRange</a></p>
<<<<<<< HEAD
<p>Make a flag out of the hexadecimal bytes of your choice.</p>
</section>
<hr />
<section>
<label for="data">Generator string</label><br />
<input
type="text"
id="data"
value="5BCEFAF5A9B8FFFFFFF5A9B85BCEFABA53"
style="width: 100%"
/><br />
<button id="generateButton">Generate!</button>
</section>
<section>
<input
type="number"
id="size_width"
style="width: 8ch"
min="0"
max="3000"
value="300"
/>
<label for="size_width">Width (px)</label><br />
<input
type="number"
id="size_height"
style="width: 8ch"
min="0"
max="3000"
value="200"
/>
<label for="size_height">Height (px)</label><br />
<select id="flag_type">
<option value="horiz">Horizontal</option>
<option value="vert" selected>Vertical</option>
</select>
<label for="flag_type">Flag type</label>
</section>
<hr />
<section>
<p>
Hex: <code><span id="hexdisplay">...</span></code>
</p>
<canvas id="canvas" width="300" height="200"></canvas>
=======
<p>Make a Scott The Woz thumbnail out of any Steam game.</p>
</section>
<hr />
@ -127,8 +73,7 @@
value="0"
/>
<label for="scott_index">Scott Index</label>
<small
>(
<small>
<label for="stash" class="checkbox">
<input
type="checkbox"
@ -136,8 +81,8 @@
onchange="scott_index.disabled = event.target.checked"
/>
<span class="checkbox">O</span>
Scott's Stash </label
>)</small
Scott's Stash
</label></small
><br />
<select id="align">
<option value="left">Left</option>
@ -149,7 +94,6 @@
<hr />
<section>
<canvas id="canvas" width="1280" height="720"></canvas>
>>>>>>> d5e5502 (SteamTheWoz v2)
</section>
<script src="scripts/index.js"></script>
</body>

View file

@ -3,125 +3,15 @@ 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();
@ -189,4 +79,3 @@ async function getScott() {
}
generateButton.addEventListener("click", getScott);
>>>>>>> d5e5502 (SteamTheWoz v2)