{"id":1629,"date":"2026-05-15T17:00:43","date_gmt":"2026-05-16T00:00:43","guid":{"rendered":"https:\/\/www.jimmysastra.com\/blog\/?p=1629"},"modified":"2026-07-02T16:35:12","modified_gmt":"2026-07-02T23:35:12","slug":"this-app-is-full-of-bugs","status":"publish","type":"post","link":"https:\/\/www.jimmysastra.com\/blog\/this-app-is-full-of-bugs\/","title":{"rendered":"This app is full of bugs"},"content":{"rendered":"\n<figure class=\"wp-block-video\"><video height=\"1080\" style=\"aspect-ratio: 1592 \/ 1080;\" width=\"1592\" controls src=\"https:\/\/www.jimmysastra.com\/blog\/wp-content\/uploads\/2026\/05\/Bugs-fast.mp4\"><\/video><\/figure>\n\n\n\n<p>Every press of the Tab key spans a new bug.<br>Some small and some big.<\/p>\n\n\n\n<p>Who will maintain what was once an orderly garden? <br>AI slop. Ai-yay-yay.<\/p>\n\n\n\n<p>And yet,<br>we keep on pressing Tab.<\/p>\n\n\n\n<p>Go ahead. Press that Tab key yourself: <a href=\"https:\/\/jimmysastra.com\/doodles\/bug\">https:\/\/jimmysastra.com\/doodles\/bug<\/a>.<br>You know you want to.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>The ability to upload your own bug and add it to my growing library of hexapods is coming soon.<\/p>\n\n\n\n<p>The bug body and legs are separate SVG files segmented from images of the full beetle . Segmentation to separate body, and the individual legs is done using good old-fashioned image processing. Not everything has to be a AI\/ML. The algorithm is as follows:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Find the bug<\/strong><strong><br><\/strong>Any pixel that isn\u2019t white belongs to the bug.<br><em>(HSV color thresholding)<\/em><\/li>\n\n\n\n<li><strong>Find the body<\/strong><strong><br><\/strong>Shrink the bug shape until the skinny legs disappear and only the chunky middle remains, then grow it back to size.<br><em>(Morphological opening: erosion + dilation; hole-filling patches bright reflections)<\/em><\/li>\n\n\n\n<li><strong>Find the legs<\/strong><strong><br><\/strong>Anything that\u2019s bug but not body must be a leg.<br><em>(Connected-component labeling groups leg blobs; Euclidean distance transforms create a Voronoi-style split assigning pixels to each leg)<\/em><\/li>\n\n\n\n<li><strong>Sort the legs<br><\/strong>Split them into left\/right, then front\/mid\/rear based on position.<\/li>\n\n\n\n<li><strong>Export the pieces<br><\/strong>Save each part as its own SVG.<br><em>(Moore-neighbor boundary tracing extracts outlines; Ramer\u2013Douglas\u2013Peucker simplifies points; Catmull\u2013Rom splines smooth them into curves)<\/em><\/li>\n<\/ol>\n\n\n\n<p>The bug graphics start as SVGs, which the browser would have to re-rasterize from vector paths every single frame, expensive when dozens of bugs are moving at 60fps. To avoid that, each SVG is drawn once into a hidden canvas at its display size, and every bug of the same species shares that cached bitmap. Per-frame rendering then becomes simple pixel copies wrapped in cheap transforms (translate\/rotate, plus a horizontal flip to mirror the left and right legs from a single sprite). The expensive vector work happens once at spawn, not 60 times a second per bug.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>For comments or bug reports, see <a href=\"https:\/\/news.ycombinator.com\/item?id=48098928\" data-type=\"link\" data-id=\"https:\/\/news.ycombinator.com\/item?id=48098928\">HackerNews<\/a> or <a href=\"https:\/\/www.linkedin.com\/posts\/jimmy-sastra-phd-11a0521_vibecoding-vibedoodling-activity-7463699294919811072-rD8R\">LinkedIn<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Every press of the Tab key spans a new bug.Some small and some big. Who will maintain what was once an orderly garden? AI slop. Ai-yay-yay. And yet,we keep on pressing Tab. Go ahead. Press that Tab key yourself: https:\/\/jimmysastra.com\/doodles\/bug.You know you want to. The ability to upload your own bug and add it to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-1629","post","type-post","status-publish","format-standard","hentry","category-artwork"],"_links":{"self":[{"href":"https:\/\/www.jimmysastra.com\/blog\/wp-json\/wp\/v2\/posts\/1629","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.jimmysastra.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jimmysastra.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jimmysastra.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jimmysastra.com\/blog\/wp-json\/wp\/v2\/comments?post=1629"}],"version-history":[{"count":19,"href":"https:\/\/www.jimmysastra.com\/blog\/wp-json\/wp\/v2\/posts\/1629\/revisions"}],"predecessor-version":[{"id":1659,"href":"https:\/\/www.jimmysastra.com\/blog\/wp-json\/wp\/v2\/posts\/1629\/revisions\/1659"}],"wp:attachment":[{"href":"https:\/\/www.jimmysastra.com\/blog\/wp-json\/wp\/v2\/media?parent=1629"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jimmysastra.com\/blog\/wp-json\/wp\/v2\/categories?post=1629"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jimmysastra.com\/blog\/wp-json\/wp\/v2\/tags?post=1629"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}