3 ms·
(I'm the author of the polyfill, though note that all this code is pieced together from existing other libs with irrelevant parts removed; none of the good idea
by skrebbel 2y ago
(I'm the author of the polyfill, though note that all this code is pieced together from existing other libs with irrelevant parts removed; none of the good ideas are mine)
Just randomly sharing, the part of the trick I like the most is that it renders the emojis scaled down to a 1x1 canvas, so it renders just a single pixel. That makes checking stuff like "am i not accidentally reading in the transparent area of the glyph" and stuff like that no problem, because the whole emoji is blurred down to a single pixel.
The author's example is a bit weird in this regard, it does the same trick (set the canvas width and height to 1), and then it still loops through all 1 pixels and discards any transparent ones.