mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-29 12:17:14 -06:00
Clarify effects dependencies and split parameter checks
This commit is contained in:
@@ -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)]
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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> {
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user