mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-19 12:38:18 +00:00
Path Precision Tools: Add Bounding Circle keeps curves close past its split budget
Once a shape has used its 1,048,576 splits at any depth, Add Bounding Circle still splits each further curve into up to 8 pieces, from a second budget of 7,340,032 splits shared among the shapes as the first one is. Only after both are used up does a curve count whole by its control points' hull cut down to its bounding box. Before, every curve past the first budget counted whole, which can make the circle around a circle about 14% larger; with the 8 pieces the fit stays less than 0.3% larger. - The comment on the shared budget no longer claims that the shape around one object is independent of the other objects selected. - shapes::enclosing_circle and convex_hull move below the star helpers. - The "Each" label mapping in the dialog form sits after "Flip Cols". - docs/mcp.md and docs/target-app-parity.md describe both budgets and the size of the fit before the 0.01 pt is added.
This commit is contained in:
@@ -88,9 +88,8 @@ fn add(s: &mut Session, p: &Value, kind: Kind) -> Result<Value> {
|
||||
// Objects that get no shape: no outline, or a shape with no size.
|
||||
let mut skipped = 0;
|
||||
let mut no_size = false;
|
||||
// Each shape gets the same share of the halvings, so the shape around one object does not
|
||||
// depend on the other objects.
|
||||
let splits = TOTAL_SPLITS / groups.len().max(1);
|
||||
// The shapes share the halvings, so the work stays bounded however many objects are selected.
|
||||
let splits = split_share(groups.len());
|
||||
for ids in &groups {
|
||||
match shape_around(d, &symbols, ids, kind, offset, splits) {
|
||||
Around::Shape(live) => made.push(live),
|
||||
@@ -139,9 +138,9 @@ enum Around {
|
||||
PastCanvas,
|
||||
}
|
||||
|
||||
/// The live rectangle or circle around `ids`, grown by `offset`. A circle halves its curves
|
||||
/// `splits` times at most in all.
|
||||
fn shape_around(d: &Document, symbols: &SymbolBoxes, ids: &[NodeId], kind: Kind, offset: f64, splits: usize) -> Around {
|
||||
/// The live rectangle or circle around `ids`, grown by `offset`. A circle halves its curves as
|
||||
/// `splits` allows.
|
||||
fn shape_around(d: &Document, symbols: &SymbolBoxes, ids: &[NodeId], kind: Kind, offset: f64, splits: Splits) -> Around {
|
||||
match kind {
|
||||
Kind::Rectangle => {
|
||||
let Some(r) = d.bounds_of_with(ids, false, symbols) else { return Around::NoOutline };
|
||||
@@ -231,10 +230,10 @@ fn outline_points(n: &Node, symbols: &SymbolBoxes, out: &mut Gathered, depth: us
|
||||
|
||||
/// Adds to `out` points whose convex hull, grown by [`FLATNESS`], holds the curve `c`: the ends of
|
||||
/// pieces whose control points lie within [`FLATNESS`] of their chord, and for pieces still curved
|
||||
/// after [`MAX_SPLITS`] halvings, or once `splits` is used up, the corners of [`held`]. A flat piece
|
||||
/// that ends where it starts adds its control points too, so a small loop is not taken for a single
|
||||
/// point. A curve with a point that is not finite adds nothing.
|
||||
fn curve_points(c: CubicBez, depth: u32, out: &mut Vec<Point>, splits: &mut usize) {
|
||||
/// after [`MAX_SPLITS`] halvings, or when `splits` allows no more ([`Splits::take`]), the corners of
|
||||
/// [`held`]. A flat piece that ends where it starts adds its control points too, so a small loop is
|
||||
/// not taken for a single point. A curve with a point that is not finite adds nothing.
|
||||
fn curve_points(c: CubicBez, depth: u32, out: &mut Vec<Point>, splits: &mut Splits) {
|
||||
if ![c.p0, c.p1, c.p2, c.p3].iter().all(|p| p.is_finite()) {
|
||||
return;
|
||||
}
|
||||
@@ -244,10 +243,9 @@ fn curve_points(c: CubicBez, depth: u32, out: &mut Vec<Point>, splits: &mut usiz
|
||||
if c.p0 == c.p3 {
|
||||
out.extend([c.p1, c.p2]);
|
||||
}
|
||||
} else if depth >= MAX_SPLITS || *splits == 0 {
|
||||
} else if depth >= MAX_SPLITS || !splits.take(depth) {
|
||||
out.extend(held(c));
|
||||
} else {
|
||||
*splits -= 1;
|
||||
let (a, b) = c.subdivide();
|
||||
curve_points(a, depth + 1, out, splits);
|
||||
curve_points(b, depth + 1, out, splits);
|
||||
@@ -289,27 +287,67 @@ fn clip(poly: &[Point], x: bool, bound: f64, below: bool) -> Vec<Point> {
|
||||
out
|
||||
}
|
||||
|
||||
/// How many halvings [`curve_points`] makes for one command in all, over every curve it measures;
|
||||
/// with `each`, every shape gets an equal share.
|
||||
/// How many halvings [`curve_points`] makes for one command, over every curve it measures, before
|
||||
/// it halves each further curve [`MIN_SPLITS`] times only; with `each`, every shape gets an equal
|
||||
/// share ([`split_share`]).
|
||||
const TOTAL_SPLITS: usize = 1 << 20;
|
||||
|
||||
/// How many more halvings [`curve_points`] makes for one command once [`TOTAL_SPLITS`] is used up,
|
||||
/// each within the first [`MIN_SPLITS`] halvings of a curve; with `each`, shared as
|
||||
/// [`TOTAL_SPLITS`] is. After that, curves count by [`held`] whole.
|
||||
const EARLY_SPLITS: usize = 7 << 20;
|
||||
|
||||
/// How many times [`curve_points`] halves a curve once [`TOTAL_SPLITS`] is used up: 8 pieces, which
|
||||
/// keeps the circle fitted to a circle of four curves less than 0.3% larger than that circle.
|
||||
const MIN_SPLITS: u32 = 3;
|
||||
|
||||
/// The halvings [`curve_points`] may still make.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
struct Splits {
|
||||
/// Halvings at any depth.
|
||||
any: usize,
|
||||
/// Halvings within the first [`MIN_SPLITS`] of a curve, once `any` is used up.
|
||||
early: usize,
|
||||
}
|
||||
|
||||
impl Splits {
|
||||
/// Takes one halving of a piece `depth` halvings into its curve; false when none is left.
|
||||
fn take(&mut self, depth: u32) -> bool {
|
||||
if self.any > 0 {
|
||||
self.any -= 1;
|
||||
} else if depth < MIN_SPLITS && self.early > 0 {
|
||||
self.early -= 1;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
/// The halvings each of `shapes` shapes may make: an equal share of [`TOTAL_SPLITS`] and of
|
||||
/// [`EARLY_SPLITS`].
|
||||
fn split_share(shapes: usize) -> Splits {
|
||||
let n = shapes.max(1);
|
||||
Splits { any: TOTAL_SPLITS / n, early: EARLY_SPLITS / n }
|
||||
}
|
||||
|
||||
/// How many points [`outline_points`] gathers before it keeps only the corners of their convex hull.
|
||||
const COMPACT_AT: usize = 1 << 16;
|
||||
|
||||
/// Points gathered for a circle, kept down to the corners of their convex hull whenever they grow
|
||||
/// past `limit`: only the hull decides the circle. The points held stay within about twice the
|
||||
/// hull's corners, and grow only with the anchors and objects measured and the [`TOTAL_SPLITS`]
|
||||
/// halvings.
|
||||
/// hull's corners, and grow only with the anchors and objects measured and the halvings
|
||||
/// ([`TOTAL_SPLITS`] and [`EARLY_SPLITS`]).
|
||||
struct Gathered {
|
||||
points: Vec<Point>,
|
||||
limit: usize,
|
||||
/// The halvings [`curve_points`] may still make ([`TOTAL_SPLITS`] at first).
|
||||
splits: usize,
|
||||
/// The halvings [`curve_points`] may still make (one shape's whole share at first).
|
||||
splits: Splits,
|
||||
}
|
||||
|
||||
impl Gathered {
|
||||
fn new() -> Self {
|
||||
Self { points: vec![], limit: COMPACT_AT, splits: TOTAL_SPLITS }
|
||||
Self { points: vec![], limit: COMPACT_AT, splits: split_share(1) }
|
||||
}
|
||||
|
||||
/// Keeps only the hull's corners once there are more than `limit` points; the next time waits
|
||||
|
||||
@@ -7,7 +7,7 @@ use serde_json::{Value, json};
|
||||
use vectorcraft_doc::{LiveShape, Node, NodeId, NodeKind};
|
||||
use vectorcraft_geom::{CubicBez, Point, Rect, Vec2, shapes};
|
||||
|
||||
use super::{CIRCLE, COMPACT_AT, Gathered, RECTANGLE};
|
||||
use super::{CIRCLE, COMPACT_AT, Gathered, RECTANGLE, Splits};
|
||||
use crate::Session;
|
||||
|
||||
fn session() -> Session {
|
||||
@@ -353,15 +353,17 @@ fn a_small_loop_gets_a_circle() {
|
||||
assert!(w > 0.02, "{w}");
|
||||
}
|
||||
|
||||
/// Once the command has used up its halvings, a curve counts by its control points' hull cut down to
|
||||
/// its bounding box: the points stay inside both and reach no farther than the curve along either
|
||||
/// axis, while its handles may.
|
||||
/// Once the command has used up both kinds of halvings, a curve counts by its control points' hull
|
||||
/// cut down to its bounding box: the points stay inside both and reach no farther than the curve
|
||||
/// along either axis, while its handles may.
|
||||
#[test]
|
||||
fn a_curve_past_the_halvings_counts_by_its_hull_inside_its_bounding_box() {
|
||||
// With nothing left, `curve_points` takes no halving, so `none` stays as it is.
|
||||
let mut none = Splits { any: 0, early: 0 };
|
||||
let c = CubicBez::new((0.0, 0.0), (20.0, 400.0), (380.0, 500.0), (400.0, 0.0));
|
||||
let b = vectorcraft_geom::kurbo::ParamCurveExtrema::bounding_box(&c);
|
||||
let mut out = vec![];
|
||||
super::curve_points(c, 0, &mut out, &mut 0);
|
||||
super::curve_points(c, 0, &mut out, &mut none);
|
||||
assert!(out.len() >= 4 && out.iter().all(|p| b.inflate(1e-9, 1e-9).contains(*p)), "{out:?} in {b:?}");
|
||||
assert!(out.iter().any(|p| (p.y - b.y1).abs() < 1e-9), "the curve's lowest point is reached: {out:?}");
|
||||
let (center, r) = shapes::enclosing_circle(&out).unwrap();
|
||||
@@ -372,16 +374,49 @@ fn a_curve_past_the_halvings_counts_by_its_hull_inside_its_bounding_box() {
|
||||
// The handle at x = 4,000,000 stays out: the curve reaches x = 16,000,000 / 9.
|
||||
let reach = CubicBez::new((0.0, 0.0), (4.0e6, 0.0), (0.0, 0.0), (0.0, 0.0));
|
||||
out.clear();
|
||||
super::curve_points(reach, 0, &mut out, &mut 0);
|
||||
super::curve_points(reach, 0, &mut out, &mut none);
|
||||
let far = out.iter().map(|p| p.x).fold(0.0, f64::max);
|
||||
assert!((far - 16.0e6 / 9.0).abs() < 1e-6, "{far}");
|
||||
out.clear();
|
||||
let mut splits = 3;
|
||||
let mut splits = Splits { any: 3, early: 0 };
|
||||
super::curve_points(c, 0, &mut out, &mut splits);
|
||||
assert_eq!(splits, 0);
|
||||
assert_eq!(splits, Splits { any: 0, early: 0 });
|
||||
assert!(out.len() > 4, "{out:?}");
|
||||
}
|
||||
|
||||
/// The circle fitted to a circle of four curves: less than 0.3% larger with only the early halvings
|
||||
/// left, and up to about 14% larger by the curves' hulls once those are used up too.
|
||||
#[test]
|
||||
fn a_circle_measured_past_the_halvings_stays_close() {
|
||||
let fitted = |mut splits: Splits| {
|
||||
let circle = shapes::ellipse(Rect::new(-100.0, -100.0, 100.0, 100.0)).to_bezpath();
|
||||
let mut out = vec![];
|
||||
for seg in circle.segments() {
|
||||
super::curve_points(seg.to_cubic(), 0, &mut out, &mut splits);
|
||||
}
|
||||
shapes::enclosing_circle(&out).unwrap()
|
||||
};
|
||||
let (center, r) = fitted(Splits { any: 0, early: 1000 });
|
||||
assert!(center.to_vec2().hypot() < 0.1 && (100.0..100.3).contains(&r), "{center:?} {r}");
|
||||
let (_, r) = fitted(Splits { any: 0, early: 0 });
|
||||
assert!((110.0..115.0).contains(&r), "{r}");
|
||||
}
|
||||
|
||||
/// Past the halvings at any depth, only the first [`super::MIN_SPLITS`] halvings of a curve take
|
||||
/// from the early ones; with `each`, every shape gets an equal share of both.
|
||||
#[test]
|
||||
fn early_halvings_are_taken_near_the_start_of_a_curve_and_shared() {
|
||||
let mut s = Splits { any: 1, early: 1 };
|
||||
assert!(s.take(super::MIN_SPLITS + 1));
|
||||
assert!(!s.take(super::MIN_SPLITS));
|
||||
assert!(s.take(0));
|
||||
assert!(!s.take(0));
|
||||
let whole = Splits { any: super::TOTAL_SPLITS, early: super::EARLY_SPLITS };
|
||||
assert_eq!(super::split_share(0), whole);
|
||||
assert_eq!(super::split_share(1), whole);
|
||||
assert_eq!(super::split_share(4), Splits { any: super::TOTAL_SPLITS / 4, early: super::EARLY_SPLITS / 4 });
|
||||
}
|
||||
|
||||
/// In an isolated group the shape goes on top of the group's art; in an isolated compound path it
|
||||
/// goes beside the compound path, never into it.
|
||||
#[test]
|
||||
|
||||
+74
-74
@@ -367,6 +367,80 @@ pub fn circle_through_points(points: &[Point]) -> Option<(Point, f64)> {
|
||||
circle.filter(|(c, r)| c.is_finite() && r.is_finite() && *r > 0.0)
|
||||
}
|
||||
|
||||
/// Regular polygon with `sides` (≥ 3), first vertex straight up from the centre.
|
||||
pub fn polygon(center: Point, radius: f64, sides: u32, rotation_deg: f64) -> PathData {
|
||||
let n = sides.max(3);
|
||||
let rot = rotation_deg.to_radians();
|
||||
let pts: Vec<Point> = (0..n)
|
||||
.map(|i| {
|
||||
let a = -PI / 2.0 + rot + TAU * i as f64 / n as f64;
|
||||
Point::new(center.x + radius * a.cos(), center.y + radius * a.sin())
|
||||
})
|
||||
.collect();
|
||||
PathData::single(SubPath::polyline(&pts, true))
|
||||
}
|
||||
|
||||
/// Regular polygon with `sides` (≥ 3), bezier tangent `rounded` factor and deterministic
|
||||
/// `randomized` vertex jitter.
|
||||
pub fn polygon_configured(center: Point, radius: f64, sides: u32, rotation_deg: f64, rounded: f64, randomized: f64) -> PathData {
|
||||
if (!rounded.is_finite() || rounded.abs() < 1e-9) && (!randomized.is_finite() || randomized.abs() < 1e-9) {
|
||||
return polygon(center, radius, sides.clamp(3, 1000), rotation_deg);
|
||||
}
|
||||
let n = sides.clamp(3, 1000);
|
||||
let rot = if rotation_deg.is_finite() { rotation_deg.to_radians() } else { 0.0 };
|
||||
let rand_amt = if randomized.is_finite() { randomized.clamp(0.0, 10.0) } else { 0.0 };
|
||||
let pts: Vec<Point> = (0..n)
|
||||
.map(|i| {
|
||||
let (dr, da) = if rand_amt > 1e-9 { vertex_jitter(i, n) } else { (0.0, 0.0) };
|
||||
let r = (radius * (1.0 + rand_amt * 0.45 * dr)).max(0.01);
|
||||
let a = -PI / 2.0 + rot + TAU * (i as f64 / n as f64) + rand_amt * (PI / n as f64) * da;
|
||||
Point::new(center.x + r * a.cos(), center.y + r * a.sin())
|
||||
})
|
||||
.collect();
|
||||
contour_with_rounding(&pts, rounded)
|
||||
}
|
||||
|
||||
/// Star with `points` tips (≥ 2), outer radius `r1`, inner radius `r2`, first tip up.
|
||||
pub fn star(center: Point, r1: f64, r2: f64, points: u32, rotation_deg: f64) -> PathData {
|
||||
let n = points.max(2) * 2;
|
||||
let rot = rotation_deg.to_radians();
|
||||
let pts: Vec<Point> = (0..n)
|
||||
.map(|i| {
|
||||
let r = if i % 2 == 0 { r1 } else { r2 };
|
||||
let a = -PI / 2.0 + rot + TAU * i as f64 / n as f64;
|
||||
Point::new(center.x + r * a.cos(), center.y + r * a.sin())
|
||||
})
|
||||
.collect();
|
||||
PathData::single(SubPath::polyline(&pts, true))
|
||||
}
|
||||
|
||||
/// Star with `points` tips (≥ 2), outer radius `r1`, inner radius `r2`, bezier tangent `rounded`
|
||||
/// factor and deterministic `randomized` vertex jitter.
|
||||
pub fn star_configured(center: Point, r1: f64, r2: f64, points: u32, rotation_deg: f64, rounded: f64, randomized: f64) -> PathData {
|
||||
if (!rounded.is_finite() || rounded.abs() < 1e-9) && (!randomized.is_finite() || randomized.abs() < 1e-9) {
|
||||
return star(center, r1, r2, points.clamp(2, 1000), rotation_deg);
|
||||
}
|
||||
let n = points.clamp(2, 1000) * 2;
|
||||
let rot = if rotation_deg.is_finite() { rotation_deg.to_radians() } else { 0.0 };
|
||||
let rand_amt = if randomized.is_finite() { randomized.clamp(0.0, 10.0) } else { 0.0 };
|
||||
let pts: Vec<Point> = (0..n)
|
||||
.map(|i| {
|
||||
let base_r = if i % 2 == 0 { r1 } else { r2 };
|
||||
let (dr, da) = if rand_amt > 1e-9 { vertex_jitter(i, n) } else { (0.0, 0.0) };
|
||||
let r = (base_r * (1.0 + rand_amt * 0.45 * dr)).max(0.01);
|
||||
let a = -PI / 2.0 + rot + TAU * (i as f64 / n as f64) + rand_amt * (PI / n as f64) * da;
|
||||
Point::new(center.x + r * a.cos(), center.y + r * a.sin())
|
||||
})
|
||||
.collect();
|
||||
contour_with_rounding(&pts, rounded)
|
||||
}
|
||||
|
||||
/// Inner radius of a "straight-armed" star (Illustrator's Alt-drag behaviour): shoulders aligned.
|
||||
pub fn straight_star_inner_radius(r1: f64, points: u32) -> f64 {
|
||||
let n = points.max(3) as f64;
|
||||
r1 * (PI / n * 2.0).cos() / (PI / n).cos()
|
||||
}
|
||||
|
||||
/// The smallest circle that holds every one of `points`: its center and radius. Points that are
|
||||
/// not finite are skipped; `None` when no finite point is left. One point gives a circle of
|
||||
/// radius 0 around it.
|
||||
@@ -457,80 +531,6 @@ fn chain(hull: &mut Vec<Point>, points: impl Iterator<Item = Point>) {
|
||||
hull.pop();
|
||||
}
|
||||
|
||||
/// Regular polygon with `sides` (≥ 3), first vertex straight up from the centre.
|
||||
pub fn polygon(center: Point, radius: f64, sides: u32, rotation_deg: f64) -> PathData {
|
||||
let n = sides.max(3);
|
||||
let rot = rotation_deg.to_radians();
|
||||
let pts: Vec<Point> = (0..n)
|
||||
.map(|i| {
|
||||
let a = -PI / 2.0 + rot + TAU * i as f64 / n as f64;
|
||||
Point::new(center.x + radius * a.cos(), center.y + radius * a.sin())
|
||||
})
|
||||
.collect();
|
||||
PathData::single(SubPath::polyline(&pts, true))
|
||||
}
|
||||
|
||||
/// Regular polygon with `sides` (≥ 3), bezier tangent `rounded` factor and deterministic
|
||||
/// `randomized` vertex jitter.
|
||||
pub fn polygon_configured(center: Point, radius: f64, sides: u32, rotation_deg: f64, rounded: f64, randomized: f64) -> PathData {
|
||||
if (!rounded.is_finite() || rounded.abs() < 1e-9) && (!randomized.is_finite() || randomized.abs() < 1e-9) {
|
||||
return polygon(center, radius, sides.clamp(3, 1000), rotation_deg);
|
||||
}
|
||||
let n = sides.clamp(3, 1000);
|
||||
let rot = if rotation_deg.is_finite() { rotation_deg.to_radians() } else { 0.0 };
|
||||
let rand_amt = if randomized.is_finite() { randomized.clamp(0.0, 10.0) } else { 0.0 };
|
||||
let pts: Vec<Point> = (0..n)
|
||||
.map(|i| {
|
||||
let (dr, da) = if rand_amt > 1e-9 { vertex_jitter(i, n) } else { (0.0, 0.0) };
|
||||
let r = (radius * (1.0 + rand_amt * 0.45 * dr)).max(0.01);
|
||||
let a = -PI / 2.0 + rot + TAU * (i as f64 / n as f64) + rand_amt * (PI / n as f64) * da;
|
||||
Point::new(center.x + r * a.cos(), center.y + r * a.sin())
|
||||
})
|
||||
.collect();
|
||||
contour_with_rounding(&pts, rounded)
|
||||
}
|
||||
|
||||
/// Star with `points` tips (≥ 2), outer radius `r1`, inner radius `r2`, first tip up.
|
||||
pub fn star(center: Point, r1: f64, r2: f64, points: u32, rotation_deg: f64) -> PathData {
|
||||
let n = points.max(2) * 2;
|
||||
let rot = rotation_deg.to_radians();
|
||||
let pts: Vec<Point> = (0..n)
|
||||
.map(|i| {
|
||||
let r = if i % 2 == 0 { r1 } else { r2 };
|
||||
let a = -PI / 2.0 + rot + TAU * i as f64 / n as f64;
|
||||
Point::new(center.x + r * a.cos(), center.y + r * a.sin())
|
||||
})
|
||||
.collect();
|
||||
PathData::single(SubPath::polyline(&pts, true))
|
||||
}
|
||||
|
||||
/// Star with `points` tips (≥ 2), outer radius `r1`, inner radius `r2`, bezier tangent `rounded`
|
||||
/// factor and deterministic `randomized` vertex jitter.
|
||||
pub fn star_configured(center: Point, r1: f64, r2: f64, points: u32, rotation_deg: f64, rounded: f64, randomized: f64) -> PathData {
|
||||
if (!rounded.is_finite() || rounded.abs() < 1e-9) && (!randomized.is_finite() || randomized.abs() < 1e-9) {
|
||||
return star(center, r1, r2, points.clamp(2, 1000), rotation_deg);
|
||||
}
|
||||
let n = points.clamp(2, 1000) * 2;
|
||||
let rot = if rotation_deg.is_finite() { rotation_deg.to_radians() } else { 0.0 };
|
||||
let rand_amt = if randomized.is_finite() { randomized.clamp(0.0, 10.0) } else { 0.0 };
|
||||
let pts: Vec<Point> = (0..n)
|
||||
.map(|i| {
|
||||
let base_r = if i % 2 == 0 { r1 } else { r2 };
|
||||
let (dr, da) = if rand_amt > 1e-9 { vertex_jitter(i, n) } else { (0.0, 0.0) };
|
||||
let r = (base_r * (1.0 + rand_amt * 0.45 * dr)).max(0.01);
|
||||
let a = -PI / 2.0 + rot + TAU * (i as f64 / n as f64) + rand_amt * (PI / n as f64) * da;
|
||||
Point::new(center.x + r * a.cos(), center.y + r * a.sin())
|
||||
})
|
||||
.collect();
|
||||
contour_with_rounding(&pts, rounded)
|
||||
}
|
||||
|
||||
/// Inner radius of a "straight-armed" star (Illustrator's Alt-drag behaviour): shoulders aligned.
|
||||
pub fn straight_star_inner_radius(r1: f64, points: u32) -> f64 {
|
||||
let n = points.max(3) as f64;
|
||||
r1 * (PI / n * 2.0).cos() / (PI / n).cos()
|
||||
}
|
||||
|
||||
/// Open straight line.
|
||||
pub fn line(a: Point, b: Point) -> PathData {
|
||||
PathData::single(SubPath::polyline(&[a, b], false))
|
||||
|
||||
@@ -846,8 +846,8 @@ pub(crate) fn humanize(k: &str) -> String {
|
||||
"Height Width" => "Height/Width:".into(),
|
||||
"Traps With Process Color" => "Traps with Process Color:".into(),
|
||||
"Cols" => "Columns:".into(),
|
||||
"Each" => "One per Object:".into(),
|
||||
"Flip Cols" => "Flip Columns:".into(),
|
||||
"Each" => "One per Object:".into(),
|
||||
_ => format!("{s}:"),
|
||||
}
|
||||
}
|
||||
|
||||
+6
-3
@@ -13711,9 +13711,12 @@ Commands:
|
||||
their corners, and type and other objects by the corners of their bounding box. It splits each curve into pieces
|
||||
until every piece's control points lie within 0.01 pt of its chord, fits the circle to the ends of the pieces, and
|
||||
makes the radius 0.01 pt larger, so the circle holds the curves themselves. A curve is split into 1,024 pieces at
|
||||
most, and one command splits its curves 1,048,576 times at most in all (with `each`, shared equally among the
|
||||
shapes); a piece that still bends more counts by the hull of its control points cut down to its bounding box,
|
||||
which can make the circle slightly larger than the smallest one. A path of a compound path selected on its own
|
||||
most. One command makes at most 1,048,576 splits at any depth, and with `each` every shape gets an equal share. A
|
||||
shape that has used up its share splits each further curve into at most 8 pieces, with at most 7,340,032 more
|
||||
splits shared the same way (8,388,608 in all), and then counts each further curve whole. A piece that still bends more counts by the hull of its control points cut down to its bounding box, which
|
||||
can make the circle larger than the smallest one. Before the 0.01 pt is added, the circle around a circle of four
|
||||
curves is less than 0.3% larger when each curve is split into 8 pieces, and about 14% larger when each counts
|
||||
whole. A path of a compound path selected on its own
|
||||
counts as an object, as `object.transform` moves it. `offset` (0 or more, default 0) adds space: a rectangle grows
|
||||
by `offset` on each side and a circle's radius grows by `offset`. `each: true` draws one shape around each selected
|
||||
object instead of one around the whole selection. The menu items Add Bounding Rectangle… and Add Bounding Circle…
|
||||
|
||||
@@ -2839,7 +2839,7 @@ A VectorCraft addition, so no area score moves. Object › Plug-ins › Path Pre
|
||||
|
||||
## Path Precision Tools add-on: Add Bounding Rectangle and Add Bounding Circle (2026-11-17)
|
||||
|
||||
A VectorCraft addition, so no area score moves. Object › Plug-ins › Path Precision Tools › Add Bounding Rectangle (`addon.pathtools.boundingRectangle`) draws a live rectangle on the selection's geometric bounding box, and Add Bounding Circle (`addon.pathtools.boundingCircle`) draws the [smallest enclosing circle](https://en.wikipedia.org/wiki/Smallest-circle_problem) of the selected outlines, with curves flattened to within 0.01 pt and the radius 0.01 pt larger, so the circle holds the curves. A curve is split into 1,024 pieces at most, and one command splits its curves 1,048,576 times at most in all (shared equally among the shapes); a piece that still bends more counts by the hull of its control points cut down to its bounding box, which can make the circle slightly larger than the smallest one. Both use the current paint, go on top of the current layer or the isolated group, and are one undo step; shapes with no size are skipped (#6966). The commands take `each` (one shape per object) and `offset`, and the menu items Add Bounding Rectangle… and Add Bounding Circle… open a dialog with Offset, One per Object and Preview. Tests: `shapes::tests` in `vectorcraft-geom` (`enclosing`, `convex_hull`), `cmd::addons::pathtools::bounding::tests` in `vectorcraft-engine` and `addons::pathtools::tests` in `vectorcraft-ui-egui` (`add_bounding_rectangle_and_circle_open_a_dialog_with_offset_and_one_per_object`). Commands: `docs/mcp.md` › Path Precision Tools add-on.
|
||||
A VectorCraft addition, so no area score moves. Object › Plug-ins › Path Precision Tools › Add Bounding Rectangle (`addon.pathtools.boundingRectangle`) draws a live rectangle on the selection's geometric bounding box, and Add Bounding Circle (`addon.pathtools.boundingCircle`) draws the [smallest enclosing circle](https://en.wikipedia.org/wiki/Smallest-circle_problem) of the selected outlines, with curves flattened to within 0.01 pt and the radius 0.01 pt larger, so the circle holds the curves. A curve is split into 1,024 pieces at most. One command makes at most 1,048,576 splits at any depth, and with `each` every shape gets an equal share. A shape that has used up its share splits each further curve into at most 8 pieces, with at most 7,340,032 more splits shared the same way (8,388,608 in all), and then counts each further curve whole. A piece that still bends more counts by the hull of its control points cut down to its bounding box, which can make the circle larger than the smallest one. Before the 0.01 pt is added, the circle around a circle of four curves is less than 0.3% larger when each curve is split into 8 pieces, and about 14% larger when each counts whole. Both use the current paint, go on top of the current layer or the isolated group, and are one undo step; shapes with no size are skipped (#6966). The commands take `each` (one shape per object) and `offset`, and the menu items Add Bounding Rectangle… and Add Bounding Circle… open a dialog with Offset, One per Object and Preview. Tests: `shapes::tests` in `vectorcraft-geom` (`enclosing`, `convex_hull`), `cmd::addons::pathtools::bounding::tests` in `vectorcraft-engine` and `addons::pathtools::tests` in `vectorcraft-ui-egui` (`add_bounding_rectangle_and_circle_open_a_dialog_with_offset_and_one_per_object`). Commands: `docs/mcp.md` › Path Precision Tools add-on.
|
||||
|
||||
## Path Precision Tools add-on: Expand Dashes into Paths (2026-11-01)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user