mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-14 06:31:41 +00:00
Commands that need an object id read it with `id_param`, which returns
None for a value that is not a non-negative integer, so `{"id": "5"}` or
`{"id": -1}` was refused with "missing id". They now read it with
`object_param`, which refuses such a value with "`id` must be a whole
number", naming the key. This covers `document.node`, the `path.*` anchor
and handle commands, the `text.*` range and path commands, the mesh,
envelope and slice point commands, `layer.target`, `layer.move`,
`node.move`, `select.magicWand`, and the `source`, `target`, `group` and
`path` keys of `appearance.transfer`, `appearance.copyFrom`, the
`livePaint.*` commands and `text.createInPath`.
The optional `group` of `livePaint.fill` and `parent` of `node.move` are
refused the same way when given. Before, a malformed `parent` moved the
object to the top level and a malformed `group` fell back to the
selection.
36 lines
1.2 KiB
Rust
36 lines
1.2 KiB
Rust
//! Commands backing the drawing tools (pencil, curvature, anchor tools, scissors, knife, eraser,
|
|
//! blob brush, smooth, path eraser, join).
|
|
|
|
use std::collections::BTreeSet;
|
|
use std::sync::Arc;
|
|
|
|
use kurbo::{CubicBez, ParamCurve, ParamCurveNearest};
|
|
use serde_json::{Value, json};
|
|
use vectorcraft_color::{Color, Paint};
|
|
use vectorcraft_doc::{AngleProfile, Appearance, Document, Node, NodeId, NodeKind, PressureProfile, Selection};
|
|
use vectorcraft_geom::hit::fill_contains;
|
|
use vectorcraft_geom::{Anchor, AnchorKind, BezPath, FillRule, PathData, Point, Rect, SubPath, Vec2};
|
|
use vectorcraft_pathops as po;
|
|
use vectorcraft_pathops::{BoolOp, Cap, Join, SimplifyOptions};
|
|
use vectorcraft_tools::draw2::{eraser_area, eraser_tip};
|
|
|
|
use super::create::{add_look, insert_look};
|
|
use super::newart::NewArt;
|
|
use super::pathops::{Beside, remove_each};
|
|
use super::{
|
|
CommandSpec, Result, Session, bad, check_numbers, cmd, f64_or, has_anchors, has_doc, has_selection, index, number_or, object_param, ok,
|
|
str_param, switch_or,
|
|
};
|
|
use crate::EngineError;
|
|
|
|
mod anchors;
|
|
mod commands;
|
|
mod common;
|
|
mod cut;
|
|
mod freehand;
|
|
mod smooth;
|
|
|
|
pub use commands::specs;
|
|
pub(super) use common::{ids_json, replace_with_pieces, usize_opt};
|
|
pub(super) use cut::{components, erase_outline};
|