From 5b2efaf8ab4431cae62210151299628b3a180c2c Mon Sep 17 00:00:00 2001 From: Cody Date: Mon, 13 Apr 2026 01:14:22 -0400 Subject: [PATCH] =?UTF-8?q?refactor(core):=20tighten=20public=20API=20?= =?UTF-8?q?=E2=80=94=20demote=20unused=20pub=20items=20to=20pub(crate)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Demotes items in draw-core that are not referenced by any workspace consumer (draw-cli, draw-app, draw-webapp, draw-wasm, draw-py), integration tests, or examples: geometry.rs: ARROWHEAD_LENGTH, ARROWHEAD_ANGLE, HACHURE_LINE_WIDTH (constants) normalize_bounds, compute_arrowhead, generate_hachure_lines ArrowheadPoints, HachureLine (helper structs + fields) point.rs: Bounds::from_points (used internally by hit_test/element only) Intentionally kept pub despite being unused internally: Point::distance_to and Bounds::intersects — these are natural public-surface helpers on already-public structs; the compiler dead-code lint is satisfied by their cfg(test) call sites and we'd rather keep a reasonable geometry vocabulary available to external consumers than drop useful primitives. Intentionally kept pub because they are used externally: geometry::ConnectionPoint, connection_points, find_nearest_snap_point (draw-wasm) storage::storage_dir (draw-webapp) all DEFAULT_* style constants (re-exported by draw-cli) No behavior change; API-surface tightening only. Co-Authored-By: Claude Opus 4.6 (1M context) --- crates/draw-core/src/geometry.rs | 36 ++++++++++++++++---------------- crates/draw-core/src/point.rs | 2 +- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/crates/draw-core/src/geometry.rs b/crates/draw-core/src/geometry.rs index b70f514..cdec6c1 100644 --- a/crates/draw-core/src/geometry.rs +++ b/crates/draw-core/src/geometry.rs @@ -1,35 +1,35 @@ //! Shared geometry helpers used by both the pixel renderer and SVG export. /// Arrowhead geometry constants. -pub const ARROWHEAD_LENGTH: f64 = 14.0; -pub const ARROWHEAD_ANGLE: f64 = 0.45; +pub(crate) const ARROWHEAD_LENGTH: f64 = 14.0; +pub(crate) const ARROWHEAD_ANGLE: f64 = 0.45; /// Hachure fill line width. -pub const HACHURE_LINE_WIDTH: f64 = 1.5; +pub(crate) const HACHURE_LINE_WIDTH: f64 = 1.5; /// Normalize a bounding box that may have negative width/height. /// Returns `(x, y, abs_width, abs_height)` with the top-left corner. -pub fn normalize_bounds(x: f64, y: f64, w: f64, h: f64) -> (f64, f64, f64, f64) { +pub(crate) fn normalize_bounds(x: f64, y: f64, w: f64, h: f64) -> (f64, f64, f64, f64) { let nx = if w < 0.0 { x + w } else { x }; let ny = if h < 0.0 { y + h } else { y }; (nx, ny, w.abs(), h.abs()) } /// The three vertices of an arrowhead triangle. -pub struct ArrowheadPoints { - pub tip_x: f64, - pub tip_y: f64, - pub left_x: f64, - pub left_y: f64, - pub right_x: f64, - pub right_y: f64, +pub(crate) struct ArrowheadPoints { + pub(crate) tip_x: f64, + pub(crate) tip_y: f64, + pub(crate) left_x: f64, + pub(crate) left_y: f64, + pub(crate) right_x: f64, + pub(crate) right_y: f64, } /// Compute arrowhead triangle vertices. /// /// `tip` is the point of the arrow, `from` is the point it points away from. /// `length` and `spread` control the size and opening angle. -pub fn compute_arrowhead( +pub(crate) fn compute_arrowhead( tip_x: f64, tip_y: f64, from_x: f64, @@ -49,11 +49,11 @@ pub fn compute_arrowhead( } /// A single hachure line segment. -pub struct HachureLine { - pub x1: f64, - pub y1: f64, - pub x2: f64, - pub y2: f64, +pub(crate) struct HachureLine { + pub(crate) x1: f64, + pub(crate) y1: f64, + pub(crate) x2: f64, + pub(crate) y2: f64, } /// Generate parallel hachure lines rotated around the center of a bounding box. @@ -61,7 +61,7 @@ pub struct HachureLine { /// Lines span from `-diag` to `+diag` so they fully cover the shape before /// clipping. `gap` is the spacing between lines and `angle` is the rotation /// in radians. -pub fn generate_hachure_lines( +pub(crate) fn generate_hachure_lines( cx: f64, cy: f64, width: f64, diff --git a/crates/draw-core/src/point.rs b/crates/draw-core/src/point.rs index 866b70d..49faf9f 100644 --- a/crates/draw-core/src/point.rs +++ b/crates/draw-core/src/point.rs @@ -48,7 +48,7 @@ impl Bounds { && self.y + self.height > other.y } - pub fn from_points(points: &[Point]) -> Option { + pub(crate) fn from_points(points: &[Point]) -> Option { if points.is_empty() { return None; }