{"id":1629,"date":"2026-05-12T22:56:43","date_gmt":"2026-05-13T05:56:43","guid":{"rendered":"https:\/\/www.jimmysastra.com\/blog\/?p=1629"},"modified":"2026-05-13T14:02:40","modified_gmt":"2026-05-13T21:02:40","slug":"an-app-full-of-bugs","status":"publish","type":"post","link":"https:\/\/www.jimmysastra.com\/blog\/an-app-full-of-bugs\/","title":{"rendered":"An app full of bugs"},"content":{"rendered":"\n<p>They say vibe coding is prone to generating bugs.\u00a0So I thought it would be the perfect way to generate an app full of bugs.<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"1080\" style=\"aspect-ratio: 1920 \/ 1080;\" width=\"1920\" controls src=\"https:\/\/www.jimmysastra.com\/blog\/wp-content\/uploads\/2026\/05\/Bug.mp4\"><\/video><\/figure>\n\n\n\n<figure class=\"wp-block-pullquote\"><blockquote><p>Try it for yourself<\/p><cite><a href=\"https:\/\/jimmysastra.com\/doodles\/bug\"><strong>https:\/\/jimmysastra.com\/doodles\/bug<\/strong><\/a><\/cite><\/blockquote><\/figure>\n\n\n\n<p>The ability to upload your own bug and add it to my growing library of hexapods is coming soon.<br><br>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 bitmap 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","protected":false},"excerpt":{"rendered":"<p>They say vibe coding is prone to generating bugs.\u00a0So I thought it would be the perfect way to generate an app full of bugs. Try it for yourself https:\/\/jimmysastra.com\/doodles\/bug The ability to upload your own bug and add it to my growing library of hexapods is coming soon. The bug body and legs are separate [&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":8,"href":"https:\/\/www.jimmysastra.com\/blog\/wp-json\/wp\/v2\/posts\/1629\/revisions"}],"predecessor-version":[{"id":1642,"href":"https:\/\/www.jimmysastra.com\/blog\/wp-json\/wp\/v2\/posts\/1629\/revisions\/1642"}],"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}]}}