VectorCraft: An open-source, vector art tool written by scratch in pure Rust
Type cursors: the I-beam with a frame or curve badge for area type and type on a path
ham9zah93b310c069bf
diff --git a/crates/tools/src/cursors.toml b/crates/tools/src/cursors.tomlindex cd3bee130..53f298f72 100644--- a/crates/tools/src/cursors.toml+++ b/crates/tools/src/cursors.toml@@ -259,7 +259,7 @@ id = "TypeArea"group = "Type"shown_when = ["Type and Area Type over a closed path's outline, Alt up for Type: a click sets area type inside the path."]hotspot = "The I-beam's centre."-look = "The I-beam between two arcs, like a pair of parentheses around it: the type goes inside the shape."+look = "The Text I-beam with a small badge below right: a square frame with three short lines of type in it."[[cursor]]id = "TypeAreaVertical"@@ -273,7 +273,7 @@ id = "TypeOnPath"group = "Type"shown_when = ["Type over an open path's outline, or a closed one with Alt held; Type on a Path over any path's outline; Area Type over an open path with Alt held: a click sets type along the path."]hotspot = "The I-beam's centre."-look = "The I-beam crossing a wavy line below its centre: the type runs along the line."+look = "The Text I-beam with a small badge below right: a short smooth curve with a dot on it."[[cursor]]id = "TypeOnPathVertical"diff --git a/crates/ui-egui/src/cursors.rs b/crates/ui-egui/src/cursors.rsindex 13fe94b81..7890bc577 100644--- a/crates/ui-egui/src/cursors.rs+++ b/crates/ui-egui/src/cursors.rs@@ -366,25 +366,39 @@ fn ibeam(p: &mut Ink, o: Pos2) {line(p, o + vec2(-2.0, 3.0), o + vec2(2.0, 3.0));}-/// A type tool over a path: the I-beam (turned a quarter turn for vertical type, without its-/// baseline mark) between two arcs for area type inside a closed path, or crossing a wavy line for+/// A type tool over a path: the Text I-beam (turned a quarter turn for vertical type) with a badge+/// below right of it, as the Pen and the Blend tool mark what a click does: a small frame with+/// lines of type in it for area type inside a closed path, a smooth curve with a point on it for/// type along a path.fn type_in_path(p: &mut Ink, o: Pos2, vertical: bool, on_path: bool) {- let at = |x: f32, y: f32| if vertical { o + vec2(y, x) } else { o + vec2(x, y) };+ let at = |x: f32, y: f32| if vertical { o + vec2(-y, x) } else { o + vec2(x, y) };line(p, at(0.0, -8.0), at(0.0, 8.0));line(p, at(-3.0, -8.0), at(3.0, -8.0));line(p, at(-3.0, 8.0), at(3.0, 8.0));+ line(p, at(-2.0, 3.0), at(2.0, 3.0));+ let b = o + if vertical { vec2(2.0, 6.0) } else { vec2(6.0, 2.0) };if on_path {- let wave = (0..=12).map(|i| {- let x = -9.0 + 1.5 * i as f32;- at(x, 4.0 + 2.0 * (x * 0.55).sin())- });- strokes(p, &[wave.collect()]);+ // A quarter-wave rising to the right, smooth at this size.+ let curve: Vec<Pos2> = (0..=16)+ .map(|i| {+ let t = i as f32 / 16.0;+ b + vec2(10.0 * t, 8.0 - 8.0 * (t * std::f32::consts::FRAC_PI_2).sin().powf(1.6))+ })+ .collect();+ strokes(p, &[curve]);+ let dot = b + vec2(4.0, 8.0 - 8.0 * (0.4 * std::f32::consts::FRAC_PI_2).sin().powf(1.6));+ p.circle_filled(dot, 2.4, HALO);+ p.circle_filled(dot, 1.5, INK);} else {- strokes(- p,- &[vec![at(-6.0, -8.0), at(-8.5, -4.0), at(-8.5, 4.0), at(-6.0, 8.0)], vec![at(6.0, -8.0), at(8.5, -4.0), at(8.5, 4.0), at(6.0, 8.0)]],- );+ poly(p, vec![b, b + vec2(9.0, 0.0), b + vec2(9.0, 9.0), b + vec2(0.0, 9.0)], HALO, INK);+ let rows: Vec<Vec<Pos2>> = if vertical {+ [6.5, 4.5, 2.5].iter().map(|&x| vec![b + vec2(x, 2.5), b + vec2(x, 6.5)]).collect()+ } else {+ [2.5, 4.5, 6.5].iter().map(|&y| vec![b + vec2(2.5, y), b + vec2(6.5, y)]).collect()+ };+ for r in rows {+ p.add(Shape::line(r, Stroke::new(1.0, INK)));+ }}}