Reply here if you just want to see how your username looks like, so we avoid noise and keep that Show HN on the top. comments are really interesting
Show HN: HN Avatars in 357 bytes
131–140 of 536 posts
Re: Show HN: HN Avatars in 357 bytes
#132Reply here if you just want to see how your username looks like, so we avoid noise and keep that Show HN on the top. comments are really interesting
Re: Show HN: HN Avatars in 357 bytes
#133Reply here if you just want to see how your username looks like, so we avoid noise and keep that Show HN on the top. comments are really interesting
Re: Show HN: HN Avatars in 357 bytes
#134This was inspired by @frncsdrk's submission from earlier today [0]. The generative concepts used were inspired by and derived from dweets from @KilledByAPixel and @FireFly [1] [2] [3] The concept is to use HN usernames as the seed into a deterministic avatar generator. This generator is built from the famously simple xorshift32 PRNG, which both provides a random variable for the image generator steps, and "pseudo-has…
for (const huser of document.querySelectorAll(".hnuser")) {
const s = huser.innerText;
const p = 2;
const canvas = document.createElement("canvas");
const context = canvas.getContext("2d");
canvas.width = p * 7;
canvas.height = p * 7;
huser.parentElement.prepend(canvas);
{
const xorshift32 = (n) => {
n ^= n >> 17;
n ^= n = seedSteps; i--) {
seed = xorshift32(seed);
seed += s.charCodeAt(i - seedSteps);
}
context.fillStyle =
"#" + ((seed >> 8) & 0xffffff).toString(16).padStart(0, 6);
for (let i = seedSteps - 1; i > 0; i--) {
// continue the seed
seed = xorshift32(seed);
const X = i & 3;
const Y = i >> 2;
if (seed >>> (seedSteps + 1) > (X * X) / 3 + Y / 2) {
context.fillRect(p * 3 + p * X, p * Y, p, p);
context.fillRect(p * 3 - p * X, p * Y, p, p);
}
}
}
}Re: Show HN: HN Avatars in 357 bytes
#135Re: Show HN: HN Avatars in 357 bytes
#136Reply here if you just want to see how your username looks like, so we avoid noise and keep that Show HN on the top. comments are really interesting
Re: Show HN: HN Avatars in 357 bytes
#137Reply here if you just want to see how your username looks like, so we avoid noise and keep that Show HN on the top. comments are really interesting
Re: Show HN: HN Avatars in 357 bytes
#138Re: Show HN: HN Avatars in 357 bytes
#139Reply here if you just want to see how your username looks like, so we avoid noise and keep that Show HN on the top. comments are really interesting
Re: Show HN: HN Avatars in 357 bytes
#140Ive been a dev for over 2 decades but I still cant grok bitwise operators - anyone have a reference that may help with that?
I struggled with this as well. Now I'm a bit rusty as I haven't used it for a while, but what really helped me was to start thinking about binary numbers more as strings. It also really helps me to visualize binary operations in binary space, not hex or decimal. That's still very confusing to me. For example left shift by 1 on this 8 bit number (decimal is 32) 00100000 you just shift all the numbers to the left 01000…
Not really. Shifting by definition discards 1 bits once they pass either "edge" of the value. The wrapping you describe only happens with rotation operations. In the languages I know they don't have fancy short hand syntax like shifting does.