mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-01 21:57:12 -06:00
With alignDashes every run between corners and path ends holds a whole number of periods, scaled to fit, with a dash (or dot) centred on each corner and on both ends of an open path. It lives in the shared dash generator, so the canvas, SVG and PDF export (as outlines) and Outline Stroke all draw it. stroke.set: alignDashes and dashOffset edit the current pattern on their own, and a new dash array keeps the offset and alignment it replaces. The Stroke panel turns dashes on fitted to corners (or as last turned off), and its Exact/Fit buttons send only the flag. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
26 lines
1.2 KiB
Rust
26 lines
1.2 KiB
Rust
//! Headless frames of the Stroke panel's Dashed Line section.
|
|
|
|
use serde_json::json;
|
|
|
|
use super::tests_appearance::{app_with_rect, click, frame_events, run, text_rect};
|
|
use super::*;
|
|
|
|
/// Click the Dashed Line check box and return the stroke's dash afterwards.
|
|
fn toggle_dashes(ctx: &egui::Context, app: &mut VectorcraftApp) -> Option<vectorcraft_doc::Dash> {
|
|
let at = text_rect(&frame_events(ctx, app, vec![], stroke::show), "Dashed Line").center();
|
|
click(ctx, app, at, stroke::show);
|
|
current_stroke(app).unwrap().dash
|
|
}
|
|
|
|
#[test]
|
|
fn turning_dashes_on_fits_them_to_corners_and_turning_back_on_restores_the_last_ones() {
|
|
let (ctx, mut app) = (egui::Context::default(), app_with_rect());
|
|
let d = toggle_dashes(&ctx, &mut app).expect("dashes on");
|
|
assert_eq!((d.pattern, d.align_corners), (vec![12.0, 12.0], true));
|
|
// Exact 4/2 dashes turned off and on again come back as they were.
|
|
run(&mut app, "stroke.set", json!({"dash": [4, 2], "alignDashes": false}));
|
|
assert!(toggle_dashes(&ctx, &mut app).is_none());
|
|
let d = toggle_dashes(&ctx, &mut app).expect("dashes on");
|
|
assert_eq!((d.pattern, d.align_corners), (vec![4.0, 2.0], false));
|
|
}
|