Skip to content

Unlock custom brushes, natural fill effects and intuitive hatching in p5.js

Update autoresearch.jsonl and fix fillBleed call in test/sketch.js

acamposuribeef0d1bacfd50
diff --git a/autoresearch.jsonl b/autoresearch.jsonl
index e4853ae..e1c716e 100644
--- a/autoresearch.jsonl
+++ b/autoresearch.jsonl
@@ -43,3 +43,4 @@
{"run":42,"commit":"889e9f7","metric":44.397,"metrics":{"trig_ms":3.127,"gauss_ms":1.636,"plot_ms":3.841,"hatch_ms":2.794,"intersect_ms":2.933,"intersect_lines_ms":1.731,"movepos_ms":4.392,"fill_ms":23.942,"total_visual_ms":90.7,"v_stroke_ms":5.3,"v_fill_ms":8.1,"v_hatch_ms":8.9,"v_mass_ms":68.4},"status":"keep","description":"skipInserted: skip ALL array writes, return tr_v/tr_m/tr_dir directly (grow result = trimmed polygon when step=2). Only consume RNG calls. fill_ms: 26.87→23.94ms (-10.9%), total: 47.09→44.40ms (-5.7%).","timestamp":1774121300896,"segment":0,"confidence":1.3435588261370672,"asi":{"hypothesis":"With GROW_CAP step=2, grow() result is exactly the trimmed polygon (all inserted vertices discarded). Skip array writes + GROW_CAP downsampling, return new FillPoly(tr_v, tr_m, ...) directly. RNG sequence preserved by consuming rr() calls."}}
{"run":43,"commit":"889e9f7","metric":44.85,"metrics":{"trig_ms":3.147,"gauss_ms":1.649,"plot_ms":3.822,"hatch_ms":2.811,"intersect_ms":2.876,"intersect_lines_ms":1.755,"movepos_ms":4.312,"fill_ms":24.477,"total_visual_ms":90.8,"v_stroke_ms":5.2,"v_fill_ms":8.2,"v_hatch_ms":8.3,"v_mass_ms":69.1},"status":"discard","description":"Simplify skipInserted RNG loop: remove gPool/g2Pool array lookups, just call rr() directly. fill_ms: 23.81→24.48ms WORSE. V8 likely keeps gPool warm via access pattern. Reverting.","timestamp":1774121475850,"segment":0,"confidence":1.298098338187424,"asi":{"hypothesis":"bare rr() calls cheaper than rr() + array lookup","rollback_reason":"fill_ms worse — gPool array access may warm memory or JIT favors original pattern","next_action_hint":"try reducing trim() allocations, or look at scatter() optimization, or try different angle in erase()"}}
{"run":44,"commit":"889e9f7","metric":44.696,"metrics":{"trig_ms":3.127,"gauss_ms":1.649,"plot_ms":3.892,"hatch_ms":2.955,"intersect_ms":3.007,"intersect_lines_ms":1.767,"movepos_ms":4.204,"fill_ms":24.093,"total_visual_ms":92,"v_stroke_ms":5.6,"v_fill_ms":9.1,"v_hatch_ms":9,"v_mass_ms":68.3},"status":"discard","description":"gaussian(): use cossin() to avoid double angleToIdx. gauss_ms unchanged (1.65ms), total 44.70 vs 44.07ms — noise. No benefit. Reverting.","timestamp":1774121560789,"segment":0,"confidence":1.2721625251846866,"asi":{"hypothesis":"cossin() in gaussian() saves one angleToIdx call per full computation","rollback_reason":"gauss_ms unchanged, fill/hatch slightly higher — within noise floor. V8 may already optimize the two separate calls.","next_action_hint":"try trim() scratch array reuse to avoid allocations, or look at unused FillPoly properties"}}
+{"run":45,"commit":"da561d4","metric":44.741,"metrics":{"trig_ms":3.13,"gauss_ms":1.654,"plot_ms":3.642,"hatch_ms":2.935,"intersect_ms":3.121,"intersect_lines_ms":1.769,"movepos_ms":4.096,"fill_ms":24.395,"total_visual_ms":92.5,"v_stroke_ms":5.3,"v_fill_ms":9,"v_hatch_ms":9.2,"v_mass_ms":69},"status":"keep","description":"Correctness fix: FillPoly direction calc (ub>=1 half-open + ua<0 direct check) fixes vertex double-count bug. Dead code: plot.js removes dead a1/p1===undefined checks, dead bounds clamp; hatch.js removes dead YcosA/YsinA aliases. Metric stable ~44.7ms within noise.","timestamp":1774123500123,"segment":0,"confidence":1.24724279835391,"asi":{"hypothesis":"correctness + dead code removal, no perf change expected","note":"first benchmark run showed JIT cold-start spike to 50ms, second run stable at 44.7ms = same as prior best 44.4ms within noise"}}
diff --git a/test/sketch.js b/test/sketch.js
index becf919..3df6e68 100644
--- a/test/sketch.js
+++ b/test/sketch.js
@@ -516,7 +516,7 @@ async function setup() {
function fillRow(label, color, opacity, bleed, dir, texture, border) {
brush.noStroke();
brush.fill(color, opacity);
- brush.fillBleed(bleed, dir);
+ brush.fillBleed(bleed);
brush.fillTexture(texture, border);
rowLabel(label);
const ry = currentY + (FILL_ROW_H - FRECT_H) / 2;