Comment

Comment by kragen

the summary is that they preprocess the image to partition it into a disjoint set of fillable regions, but i feel like this maybe has to be redone whenever you mutate the image

maybe other optimization approaches would yield a flood-fill algorithm that just runs fast enough in js; wasm can surely do it

like i feel like you can probably loop over the pixels in a scan line until you encounter an obstacle at several tens of megapixels per second

as the dumbest possible test of js perf, this code (admittedly not accessing an imagedata object) gets about 250 million iterations per second on my 2.6 gigahertz palmtop in firefox

    function tri(n) { let x = 0, y = n; while(y--) x += y; return x } 
    s = new Date(); console.log(tri(10_000_000)); console.log(new Date() - s)
parent kragen 3 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton