Unlock custom brushes, natural fill effects and intuitive hatching in p5.js
Commits on main
fix: FillPoly direction calc - match _isLeft threshold exactly (ua*eNeg<=0.01) to reject float-noise self-intersections at ua≈0
1ca168e acamposuribe committed 8 months ago
Update autoresearch.jsonl and fix fillBleed call in test/sketch.js
ef0d1ba acamposuribe committed 8 months ago
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.
da561d4 acamposuribe committed 8 months ago
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%).
889e9f7 acamposuribe committed 8 months ago
GROW_CAP skip-inserted: when even step (step=2), skip cossin+rotation for discarded inserted vertices, preserve RNG sequence. fill_ms: 28.55→26.87ms (-5.9%), total: 49.80→47.09ms (-5.4%). Separate loop body avoids JIT interference.
cb2c83f acamposuribe committed 8 months ago
angleToIdx: add [720,1080) fast path. trig_ms: 5.2→3.17ms (-39%). Benchmark sin angles go to ~1045° — now all covered by fast paths. total: 50.67→49.80ms (-1.7%).
0d7a0b0 acamposuribe committed 8 months ago
Remove single-segment fast path from angle() + dead curving() method. plot_ms: 8.0→3.83ms (-52%), total: 56.76→50.67ms (-10.7%). Fast path caused JIT deopt via extra branch on every multi-segment call.
cc12555 acamposuribe committed 8 months ago
Fresh baseline after recent feature commits. plot_ms regressed to 8ms (was 3.9ms), movepos_ms 5.76ms (was 4.35ms). Need to investigate.
d3dae48 acamposuribe committed 8 months ago
fix: black fills, border thickness, fill explorer grid view
fb3f414 acamposuribe committed 8 months ago
feat: grain slider 0-1 for default brushes in brush-maker
feedb6e acamposuribe committed 8 months ago
perf: plot.angle() single-segment fast path; stroke-level noise alpha; remove dead lineNoise code
d73830f acamposuribe committed 8 months ago
Add Playwright visual benchmark (bench_visual.html + bench_visual.mjs). Headless Chromium with real WebGL. Measures stroke/fill/hatch/mass per-operation including GPU compositing. Baseline: total_visual_ms~95ms (v_mass_ms~71ms dominant).
169aca2 acamposuribe committed 8 months ago
Fix pastel_hatching_test weight: match standalone (pen weight 1 not 3). Update autoresearch.md summary.
04a17ce acamposuribe committed 8 months ago
Separate _moveConstant() method for constant-direction moveTo (no field). Precomputes cossin once. movepos_ms: 4.8→4.35ms (-9%). No JIT interference — separate method avoids changing movePos body.
1cb3ad3 acamposuribe committed 8 months ago
Remove esm-seedrandom dependency from package.json — no longer imported after mulberry32 switch. Reduces bundle size and install footprint.
e0b26a2 acamposuribe committed 8 months ago
Box-Muller cache: store second gaussian value, return it on next call. Halves Math.sqrt/Math.log calls. gauss_ms: 2.3→1.6ms (-30%), fill_ms: 28.8→27.1ms (-6%). total: 51.6→49.6ms (-4%)
5763db3 acamposuribe committed 8 months ago
Replace prng_alea with mulberry32 PRNG (~3.7x faster). Removes esm-seedrandom dependency. fill_ms: 31.4→28.8ms (-8%), gauss_ms: 3.0→2.3ms (-23%). total: 56.1→51.6ms (-8%). Same seeding API, same visual quality.
9c41512 acamposuribe committed 8 months ago
trim(): eliminate splice() - pre-allocate with finalLen, direct copy with 2 inserted vertices. fill_ms: 32.4→31.4ms (-3%). No array shifting.
71b20af acamposuribe committed 8 months ago
_center(): no array copy needed — inline wrap with ternary j=(i+1<n?i+1:0). Eliminates [...pts] spread. trig JIT recovered. Total marginally better.
03f0de9 acamposuribe committed 8 months ago
scatter(): combine two loops into one, eliminate indices[] array allocation. fill_ms: 32.0→31.5ms (-1.6%). Simpler code.
d2c8fd8 acamposuribe committed 8 months ago
Polygon.intersect(): indexed loop instead of for...of. intersect_ms: 3.54→2.94ms (-17%). trig_ms higher due to JIT noise but intersect improvement is consistent.
88e35b2 acamposuribe committed 8 months ago
Updated autoresearch.md with final summary. Current best: total 55.7ms. All key optimizations documented.
e5b468c acamposuribe committed 8 months ago
calcIndex: amortized O(1) forward scan + binary search fallback. plot_ms: 5.5→3.8ms (-31%), movepos_ms: 5.1→4.8ms (-6%). total: 57→55.5ms (-3%)
7700170 acamposuribe committed 8 months ago
pressure() in Plot: remove redundant t bounds check (t always in [0,1) after calcIndex). plot_ms stable. total: 57.5→57.0ms (-1%)
2e1a931 acamposuribe committed 8 months ago
scanlineHatch: simplified XOR crossing check, fast 2-element swap (no sort for convex polygon). hatch_ms: 3.3→2.8ms (-16%). total: 58.4→57.5ms (-1.5%)
33709e8 acamposuribe committed 8 months ago