Unlock custom brushes, natural fill effects and intuitive hatching in p5.js
Remove dead code: orphaned core/mask.js, unused MassState helpers and imports
acamposuribeabba0b746a3e
diff --git a/src/core/mask.js b/src/core/mask.jsdeleted file mode 100644index fd47370..0000000--- a/src/core/mask.js+++ /dev/null@@ -1,91 +0,0 @@-import { Mix } from "./color.js";--const ctx = Mix.ctx;--function strokePadding(ctx, matrix) {- const lineWidth = ctx.lineWidth || 0;- if (lineWidth <= 0) return 1;-- return (- 1 +- (lineWidth * Math.max(Math.hypot(matrix.a, matrix.c), Math.hypot(matrix.b, matrix.d))) /- 2- );-}--// =============================================================================-// Section: Draw shapes to Mask Buffers-// =============================================================================--/**- * Draws a polygon to the mask using the provided vertices.- * @param {Array<{x: number, y: number}>} vertices - Array of vertex coordinates.- */-export function drawPolygon(vertices) {- const matrix = ctx.getTransform();- // Cache the current 2D transform once so the hot loop can stay numeric and- // avoid repeated property reads while we build bounds.- const a = matrix.a;- const b = matrix.b;- const c = matrix.c;- const d = matrix.d;- const e = matrix.e;- const f = matrix.f;- let minX = Infinity,- minY = Infinity,- maxX = -Infinity,- maxY = -Infinity;-- ctx.beginPath();-- // Seed both the path and the transformed bounds from the first vertex so the- // loop below only needs to append line segments.- const first = vertices[0];- let tx = a * first.x + c * first.y + e;- let ty = b * first.x + d * first.y + f;- minX = maxX = tx;- minY = maxY = ty;-- ctx.moveTo(first.x, first.y);-- for (let i = 1; i < vertices.length; i++) {- const v = vertices[i];-- // Track the transformed bounds in canvas space while we build the path so- // dirty-rect bookkeeping does not need a second pass over the vertices.- tx = a * v.x + c * v.y + e;- ty = b * v.x + d * v.y + f;- minX = Math.min(minX, tx);- minY = Math.min(minY, ty);- maxX = Math.max(maxX, tx);- maxY = Math.max(maxY, ty);-- ctx.lineTo(v.x, v.y);- }-- ctx.closePath();-- // Expand by stroke width so the later composite pass copies enough pixels- // even when the polygon border extends outside the raw vertex bounds.- const padding = strokePadding(ctx, matrix);- Mix.markDirtyRect(Mix.mask, {- minX: minX - padding,- minY: minY - padding,- maxX: maxX + padding,- maxY: maxY + padding,- });-}---const PI2 = Math.PI * 2;--/**- * Draws a circle to the mask.- * @param {number} x - X-coordinate of the circle's center.- * @param {number} y - Y-coordinate of the circle's center.- * @param {number} d - Diameter of the circle.- */-export function circle(x, y, radius) {- ctx.moveTo(x + radius, y);- ctx.arc(x, y, radius, 0, PI2);-}diff --git a/src/fill/fill.js b/src/fill/fill.jsindex 85d3d6e..7304724 100644--- a/src/fill/fill.js+++ b/src/fill/fill.js@@ -26,8 +26,6 @@ import {randInt,gaussian,rotate,- cos,- sin,cossin,_onSeed,} from "../core/utils.js";diff --git a/src/hatch/mass.js b/src/hatch/mass.jsindex e6ff71e..908fccf 100644--- a/src/hatch/mass.js+++ b/src/hatch/mass.js@@ -23,22 +23,6 @@ State.mass = {options: {},};-/**- * Returns a shallow copy of the current mass state.- * @returns {object}- */-export function MassState() {- return { ...State.mass };-}--/**- * Restores a previously saved mass state.- * @param {object} state- */-export function MassSetState(state) {- State.mass = { ...state };-}-/*** Enables massing mode with a brush, color, and optional configuration.*diff --git a/src/stroke/stroke.js b/src/stroke/stroke.jsindex 8c4d187..d95f72f 100644--- a/src/stroke/stroke.js+++ b/src/stroke/stroke.js@@ -12,7 +12,7 @@*/// Core imports-import { Cwidth, Cheight, Renderer, isCanvasReady } from "../core/target.js";+import { Cwidth, Cheight, isCanvasReady } from "../core/target.js";import {Mix,State,