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
451–460 of 536 posts
Re: Show HN: HN Avatars in 357 bytes
#452Re: Show HN: HN Avatars in 357 bytes
#453Reply 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
Edit: a poker face with a strange hat, not bad
Re: Show HN: HN Avatars in 357 bytes
#454For better rendering on high-DPI screens and (more subjectively) screens of people that have zoomed in because HN’s text sizes are unreasonably small, add c.style.imageRendering='pixelated'. I was going to say that the insertion of these 24 bytes allows you to save ten bytes elsewhere by halving the size of the image (making features one pixel in size, rather than two), but then you’d also have to set the doubled ima…
It's a good point, I did consider using that feature but the problem is it's not very cross browser friendly, so I stuck with simpler DIY pixel scaling. In fairness I think there is basically two different values for chrome and firefox, although I'm not sure about safari and cannot test it...
This is valuable for high-DPI and zoomed pages, to avoid bilinear or similar scaling; the matter of halving the canvas size was a red herring.
Re: Show HN: HN Avatars in 357 bytes
#455This is fun. One suggestion.. rather than creating a canvas for each user using a querySelectorAll and a loop, I'd use an IntersectionObserver and only create the canvases as they scroll into view. That way the user's device won't need to create hundreds of elements when the code runs. let observer = new IntersectionObserver( (entries) => { entries.forEach((entry, i) => { if (entry.isIntersecting) { const p = 2; cons…
Speaking performance/optimisations, interesting choice to destroy canvas when it leaves viewport and recreate it upon each re-entry. Personally I'd leave it created and stop observing the element instead, à la /* … */ if (entry.isIntersecting) { observer.unobserve(entry.target); /* … */ } Do you think (or know) that swapping observed node for canvas (potentially producing many canvases) is more expensive than keeping…
Re: Show HN: HN Avatars in 357 bytes
#456Reply 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
#457Re: Show HN: HN Avatars in 357 bytes
#458Re: Show HN: HN Avatars in 357 bytes
#459Hah! I got a really cool little icon that looks almost like the cassette tape pirate logo of Piratbyrån back in the day. I have old t-shirts with that logo. MAKE. THIS. PERMANENT! On the functional side, this really helps you see who is who in a long threaded discussion. Your eye is much quicker at following the little color icons than their names.
I do feel like HN needs avatars of some kind... just don't know if they should be customizable or fixed (like this one).
Re: Show HN: HN Avatars in 357 bytes
#460test