sclass G22ShapeCollectorPanel { settable G22Utils g22utils; new MouseInComponentMonitor mouseMonitor; PicturesByMD5 pics; BufferedImage inputImage; byte[] qoiData; S qoiMD5; JMaxSpeedAnimation anim; JCheckBox cbOn = jcheckbox("On", true); JCheckBox cbFreezeOnHover = jcheckbox("Freeze on hover", true); JSpinner colorsSpinner = jListSpinner(dropFirst(firstNCubes(16))); JSpinner blurSpinner = jSpinner(0, 0, 99); JLabel lblStats = rightAlignedLabel(); void init { if (pics != null) ret; pics = new PicturesByMD5(g22utils.projectFile("Images")); pics.extension(".qoi"); looselyBindLiveValueToCheckBox(g22utils.liveProjectVar("Freeze on hover"), cbFreezeOnHover); looselyBindLiveValueToSpinner(g22utils.liveProjectVar("colors"), colorsSpinner); looselyBindLiveValueToSpinner(g22utils.liveProjectVar("blur"), blurSpinner); } void saveImage() { pics.put(qoiMD5, qoiData); } BufferedImage nextInputImage() { ret shootLeftScreenHalf(); } BufferedImage nextFrame() { if (!isChecked(cbOn) || isChecked(cbFreezeOnHover) && mouseMonitor!) { sleepSeconds(0.1); null; } inputImage = nextInputImage(); qoiData = g22utils.timeFunction("QOI compress", -> toQOI (inputImage)); qoiMD5 = md5(qoiData); va rwrangler = new G22DataWrangler; wrangler.timings(g22utils.functionTimings()); wrangler.inputImage(inputImage); wrangler.colors(intFromSpinner(colorsSpinner)); wrangler.blur(intFromSpinner(blurSpinner)); wrangler.stepUntilStage(wrangler.regionsStage); g22utils.setTransientProjectVar("Last wrangler", wrangler); setText(lblStats, commaCombine( anim.fps(), nRegions(wrangler.regions), "QOI: " + str_toK(qoiSize), "Hash: " + takeFirst(3, qoiMD5), "Saved: " + yesNo_short(pics.has(qoiMD5)) ); ret toBufferedImage(wrangler.posterizedImage()); } cachedVisualize { anim = new JMaxSpeedAnimation; anim.renderFrame(l0 nextFrame); mouseMonitor.init(anim.imageSurface()); ret northAndCenterWithMargins( jCenteredSection(" Visual Controls ", vstackWithSpacing( jcenteredline(cbOn, cbFreezeOnHover), jcenteredline( jCenteredSection("Colors", colorsSpinner), jCenteredSection("Blur", blurSpinner) ))), centerAndSouthWithMargin( jCenteredSection(" What I See ", anim), centerAndEastWithMargin(lblStats, jThreadedButton("Save image", l0 save))) ); } }