Skip to content

VectorCraft: An open-source, vector art tool written by scratch in pure Rust

Clarify effects dependencies and split parameter checks

Dylan M. Taylore1bc6b235cf9
diff --git a/crates/effects/src/catalog.rs b/crates/effects/src/catalog.rs
index 14fd90c13..5ad48a1ed 100644
--- a/crates/effects/src/catalog.rs
+++ b/crates/effects/src/catalog.rs
@@ -1,4 +1,4 @@
-use super::*;
+use super::{CROP_MARKS, EXTRUDE, INFLATE, PATHFINDER_EFFECTS, RASTERIZE, REVOLVE, ROTATE, TRAP, Value, json, trap};
/// Catalogue entry for one effect.
#[derive(Clone, Debug, PartialEq)]
diff --git a/crates/effects/src/distort.rs b/crates/effects/src/distort.rs
index b7430e0c7..5b0c14c62 100644
--- a/crates/effects/src/distort.rs
+++ b/crates/effects/src/distort.rs
@@ -4,7 +4,7 @@ use serde_json::Value;
use vectorcraft_geom::kurbo::ParamCurveArclen;
use vectorcraft_geom::{Affine, Anchor, ParamCurve, PathData, Point, Rect, SubPath, Vec2};
-use crate::util::*;
+use crate::util::{catmull_rom, fit_piece, flag, map_nonlinear_within, mean_size, noise, normal_at, num, pieces, seed, seg_cubic, smooth_points};
fn diag(b: Rect) -> f64 {
b.width().hypot(b.height()).max(1e-6)
diff --git a/crates/effects/src/geometry.rs b/crates/effects/src/geometry.rs
index 7d25d1955..a4cb2e1d8 100644
--- a/crates/effects/src/geometry.rs
+++ b/crates/effects/src/geometry.rs
@@ -1,5 +1,8 @@
use super::params::{is_geometry, merged_params};
-use super::*;
+use super::{
+ Appearance, AppearanceItem, BezPath, Effect, FillRule, Node, NodeKind, PathData, Rect, StrokeLayer, Value, WarpStyle, distort, stroke, stylize,
+ util, warp,
+};
/// Context the geometry effects may need from the object's appearance.
#[derive(Clone, Copy, Debug, Default, PartialEq)]
@@ -167,7 +170,7 @@ fn builds_within(id: &str) -> bool {
/// [`apply_one`] whose result may pass `max` when the effect doesn't build within it.
fn apply_unchecked(id: &str, p: &Value, path: &PathData, b: Rect, ctx: &GeomContext, max: usize) -> PathData {
- use util::*;
+ use util::{join, num};
if let Some(plugin) = vectorcraft_plugins::effect::plugin_id(id) {
let paints = vectorcraft_plugins::effect::Paints { appearance: ctx.appearance, item: ctx.item };
return vectorcraft_plugins::effect::apply(plugin, p, path, b, ctx.rule, paints).unwrap_or_else(|| path.clone());
diff --git a/crates/effects/src/params.rs b/crates/effects/src/params.rs
index dc54e8b51..d64ac7b78 100644
--- a/crates/effects/src/params.rs
+++ b/crates/effects/src/params.rs
@@ -1,5 +1,5 @@
use super::catalog::{catalog_index, plugin_info};
-use super::*;
+use super::{CROP_MARKS, Effect, Map, Node, PIXEL_EFFECTS, RASTERIZE, Value, is_adjustment, is_pathfinder, is_three_d, json, util};
/// Dialog defaults for `id` (`None` for unknown effects).
pub fn default_params(id: &str) -> Option<Value> {
diff --git a/crates/effects/src/pixel/tests.rs b/crates/effects/src/pixel/tests.rs
index fc3497ae6..ef4d9d7ab 100644
--- a/crates/effects/src/pixel/tests.rs
+++ b/crates/effects/src/pixel/tests.rs
@@ -1755,6 +1755,10 @@ fn brush_strokes_params_take_defaults_and_stay_in_range() {
fx("brushStrokes.sumiE", json!({"strokeWidth": 2, "strokePressure": 16, "contrast": -1})),
PixelFx::SumiE { width: 3.0, pressure: 15.0, contrast: 0.0 }
);
+ brush_strokes_outsets();
+}
+
+fn brush_strokes_outsets() {
// Outsets: the strokes and the shifts reach out of the object as far as into it; Accented
// Edges and Sumi-e keep the object's shape.
let b = Rect::new(0.0, 0.0, 100.0, 50.0);
@@ -2561,6 +2565,10 @@ fn artistic_params_take_defaults_and_stay_in_range() {
fx("artistic.plasticWrap", json!({"highlightStrength": -1, "detail": 99, "smoothness": 0})),
PixelFx::PlasticWrap { highlight: 0.0, detail: 15.0, smoothness: 1.0 }
);
+ artistic_outsets_and_docs();
+}
+
+fn artistic_outsets_and_docs() {
for id in [
"artistic.coloredPencil",
"artistic.cutout",
diff --git a/crates/effects/src/raster.rs b/crates/effects/src/raster.rs
index 79ad9c25e..f8590bbb2 100644
--- a/crates/effects/src/raster.rs
+++ b/crates/effects/src/raster.rs
@@ -9,7 +9,7 @@ use vectorcraft_geom::{Point, Rect};
use crate::merged_params;
use crate::pixel::{self, PixelFx, PixelSpace};
-use crate::util::*;
+use crate::util::{flag, num, text};
/// Effect › Rasterize's id.
pub const RASTERIZE: &str = "rasterize";
diff --git a/crates/effects/src/stylize.rs b/crates/effects/src/stylize.rs
index 98bf2dd67..f7dd503d2 100644
--- a/crates/effects/src/stylize.rs
+++ b/crates/effects/src/stylize.rs
@@ -5,7 +5,7 @@ use vectorcraft_geom::kurbo;
use vectorcraft_geom::shapes::{self, KAPPA};
use vectorcraft_geom::{Affine, Anchor, PathData, Point, Rect, SubPath, corners};
-use crate::util::*;
+use crate::util::{catmull_rom, flag, noise, num, seed};
/// Convert to Shape (rectangle / rounded rectangle / ellipse) around the bounds.
pub fn convert_to_shape(id: &str, b: Rect, p: &Value) -> PathData {
diff --git a/crates/effects/src/warp.rs b/crates/effects/src/warp.rs
index f3b7efea9..fb0279ede 100644
--- a/crates/effects/src/warp.rs
+++ b/crates/effects/src/warp.rs
@@ -6,7 +6,7 @@
use serde_json::Value;
use vectorcraft_geom::{PathData, Point, Rect};
-use crate::util::*;
+use crate::util::{map_nonlinear_within, num, text};
pub use vectorcraft_doc::live::{WarpStyle, warp_point};