You are viewing a single comment's thread from:
RE: I made a tool that lets designers/programmers get top colors from a screenshot or design
Nice! Can you explain a little bit how you did this? I'm curious to learn how it works.
Nice! Can you explain a little bit how you did this? I'm curious to learn how it works.
Sure! The principle is very simple, it just scans the entire image and counts up the number of equal colored pixels. Then it sorts the resulting map by number of instances (descending, so most common color is at the top) and trims the list at 100 before displaying it in the UI.
The rest is a bunch of JavaScript specific stuff, like getting the blob from drag & drop result, reading bytes from the canvas buffer, using promises to split up asynchronous parts, and so on. For gleaning into that it's probably best to skim through the code, it's written in ES6 flavor and should be fairly readable!