mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-15 20:34:18 +00:00
Merge pull request #3145 from adambelis/feat/width-smooth-profile
Width profiles run smooth between their points
This commit is contained in:
@@ -73,14 +73,13 @@ fn arrowheads_are_part_of_the_outline() {
|
||||
assert_eq!(path_of(&n).subpaths.len(), 1, "line and head are one shape");
|
||||
}
|
||||
|
||||
/// Outline Stroke of a Lens-profile line covers 7/12 of the full-width rectangle.
|
||||
/// Outline Stroke of a Lens-profile line covers 2/3 of the full-width rectangle.
|
||||
#[test]
|
||||
fn a_lens_profile_outlines_to_seven_twelfths_of_the_rectangle() {
|
||||
fn a_lens_profile_outlines_to_two_thirds_of_the_rectangle() {
|
||||
let mut s = session();
|
||||
line(&mut s, json!({"weight": 10, "profile": "lens"}));
|
||||
let n = outline(&mut s);
|
||||
// Each half of the lens swells on a cubic, flat at the middle (#5714).
|
||||
assert!(near(area(&n), 7.0 / 12.0 * 10.0 * 100.0, 2.0), "{}", area(&n));
|
||||
assert!(near(area(&n), 2.0 / 3.0 * 10.0 * 100.0, 2.0), "{}", area(&n));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -221,9 +221,9 @@ fn new_width_point_adjust_adjoining_uses_sampled_widths() {
|
||||
let (mut s, id) = line_session();
|
||||
let original = vec![(0.0, 9.0, 9.0), (0.25, 1.0, 0.0), (0.75, 3.0, 0.0), (1.0, 7.0, 7.0)];
|
||||
s.execute("stroke.widthProfile.set", &json!({"ids": [id.0], "points": original})).unwrap();
|
||||
// At t=0.5 the old left side is where the profile's curve is there (#5714) and the right
|
||||
// side is 0pt. Indexed editing of that sampled point is the existing convention: scale the
|
||||
// nonzero side, add from zero.
|
||||
// At t=0.5 the old left side is where the profile's curve is there and the right side is
|
||||
// 0pt. Indexed editing of that sampled point is the existing convention: scale the nonzero
|
||||
// side, add from zero.
|
||||
let sampled = vectorcraft_doc::WidthProfile { points: original }.at(0.5).0;
|
||||
let index = if indexed { Some(set(&mut s, json!({"id": id.0, "t": 0.5, "left": sampled * 5.0, "right": 0}))) } else { None };
|
||||
set(&mut s, json!({"id": id.0, "index": index, "t": 0.5, "left": 20, "right": 5, "adjustAdjoining": true}));
|
||||
|
||||
Reference in New Issue
Block a user