fix(anatomy): V1-2.2 refuse zones without a usable interior
A polygon or path zone or trigger must fill a disc of 4 CSS px on the 320 x 568 preview under the layer's nonzero rule, stroke left out: conservative widest-disc search on the flattened outline, caps and a per-sheet budget, closed codes interior_too_small and marker_interior_too_small. Browser probe on six projects.
This commit is contained in:
1 parent
de2dfb392e
commit
8dd2d78d38
18 files changed
+1852
-38
No files matched your search
@@ -0,0 +1,232 @@
|
||||
//! The browser proof of the interior rule (owner brief « V1-2.2 : fermeture du dernier MEDIUM »,
|
||||
//! 2026-11-01): `apps/app/e2e/fixtures/interior-probe.json`, read by
|
||||
//! `apps/app/e2e/ui/interior-clicks.spec.ts` in Chromium, Firefox and WebKit. Each case is a
|
||||
//! sheet whose main view, framed `0 0 286 310` (one unit per CSS px on the phone preview), holds
|
||||
//! one shape: the canvas the editor gets (`view.canvas`), the verdict's code, and the widest disc
|
||||
//! the core measures. The equine draft's shapes give their discs too. The file is generated
|
||||
//! here and compared byte for byte; `MAKE_INTERIOR_PROBE=1` writes it.
|
||||
#![allow(clippy::disallowed_methods, clippy::unwrap_used, clippy::expect_used)]
|
||||
|
||||
mod common;
|
||||
|
||||
use common::sheet_readers::{DETAIL_ASSET, MAIN_ASSET, OPEN, document, drawing};
|
||||
use faunosteo_core::anatomy::interior::{
|
||||
Budget, LAYER_FILL_RULE, Search, geometry_outline, widest_disc,
|
||||
};
|
||||
use faunosteo_core::domain::sheet::preview::{PreviewInput, PreviewSheet, PreviewStatus};
|
||||
use faunosteo_core::domain::sheet::{AnatomicalSheetDocument, Annotation, Geometry};
|
||||
use faunosteo_core::facade::call_with_preview;
|
||||
use serde_json::{Value, json};
|
||||
|
||||
const FIXTURE: &str = "apps/app/e2e/fixtures/interior-probe.json";
|
||||
const THIN: &str = "annotation.geometry.interior_too_small";
|
||||
const PHONE: &str = "0 0 286 310";
|
||||
|
||||
/// The widest disc of a shape, measured to a thousandth of a unit: centre and radius.
|
||||
fn widest(geometry: &Geometry) -> Value {
|
||||
let outline = geometry_outline(geometry, 0.001).unwrap();
|
||||
let search = Search {
|
||||
floor: 0.0,
|
||||
enough: f64::INFINITY,
|
||||
precision: 0.001,
|
||||
};
|
||||
match widest_disc(&outline, LAYER_FILL_RULE, &search, &mut Budget::default()) {
|
||||
Some(disc) => json!({
|
||||
"x": round(disc.centre.0),
|
||||
"y": round(disc.centre.1),
|
||||
"r": round(disc.radius),
|
||||
}),
|
||||
None => Value::Null,
|
||||
}
|
||||
}
|
||||
|
||||
fn round(value: f64) -> f64 {
|
||||
(value * 1000.0).round() / 1000.0
|
||||
}
|
||||
|
||||
/// One case: the canvas, the frame codes, the widest disc.
|
||||
fn case(name: &str, geometry: Value, root: &str) -> Value {
|
||||
let mut doc: Value = serde_json::from_str(&document()).unwrap();
|
||||
doc["annotations"][0]["id"] = json!("shape");
|
||||
doc["annotations"][0]["kind"] = json!("zone");
|
||||
doc["annotations"][0]["geometry"] = geometry.clone();
|
||||
let main = OPEN.replace(
|
||||
"viewBox=\"0 0 10 10\"",
|
||||
&format!("{root}viewBox=\"{PHONE}\""),
|
||||
) + "<path d=\"M0 0h1\"/></svg>";
|
||||
let detail = OPEN.to_owned() + "<path d=\"M0 0h1\"/></svg>";
|
||||
let input = PreviewInput {
|
||||
status: PreviewStatus::Draft,
|
||||
document: doc.to_string(),
|
||||
fingerprint: None,
|
||||
};
|
||||
let preview = PreviewSheet::load(
|
||||
input,
|
||||
vec![drawing(MAIN_ASSET, &main), drawing(DETAIL_ASSET, &detail)],
|
||||
)
|
||||
.unwrap();
|
||||
let codes: Vec<String> = preview
|
||||
.state()
|
||||
.unwrap()
|
||||
.report
|
||||
.issues
|
||||
.iter()
|
||||
.filter(|i| i.code.starts_with("annotation.geometry."))
|
||||
.map(|i| i.code.clone())
|
||||
.collect();
|
||||
let canvas: Value = serde_json::from_str(&call_with_preview(
|
||||
&preview,
|
||||
"view.canvas",
|
||||
&json!({ "viewId": "main" }).to_string(),
|
||||
))
|
||||
.unwrap();
|
||||
assert_eq!(canvas["ok"], json!(true), "{name}: {canvas}");
|
||||
let typed: Geometry = serde_json::from_value(geometry).unwrap();
|
||||
json!({
|
||||
"name": name,
|
||||
"accepted": codes.is_empty(),
|
||||
"codes": codes,
|
||||
"widest": widest(&typed),
|
||||
"svg": canvas["value"]["svg"],
|
||||
})
|
||||
}
|
||||
|
||||
fn polygon(points: &[[f64; 2]]) -> Value {
|
||||
json!({ "type": "polygon", "points": points })
|
||||
}
|
||||
|
||||
fn path(d: &str) -> Value {
|
||||
json!({ "type": "path", "d": d })
|
||||
}
|
||||
|
||||
fn ell(x: f64, y: f64, w: f64) -> Value {
|
||||
polygon(&[
|
||||
[x, y],
|
||||
[x + 40.0, y],
|
||||
[x + 40.0, y + w],
|
||||
[x + w, y + w],
|
||||
[x + w, y + 40.0],
|
||||
[x, y + 40.0],
|
||||
])
|
||||
}
|
||||
|
||||
fn star(cx: f64, cy: f64, r: f64) -> Value {
|
||||
let points: Vec<[f64; 2]> = (0..5)
|
||||
.map(|i| {
|
||||
let angle =
|
||||
-std::f64::consts::FRAC_PI_2 + f64::from(i * 2) * std::f64::consts::TAU / 5.0;
|
||||
[cx + r * angle.cos(), cy + r * angle.sin()]
|
||||
})
|
||||
.collect();
|
||||
polygon(&points)
|
||||
}
|
||||
|
||||
fn cases() -> Vec<Value> {
|
||||
let plain = "";
|
||||
vec![
|
||||
// Accepted: small shapes that fill.
|
||||
case(
|
||||
"square-6",
|
||||
polygon(&[[40.0, 40.0], [46.0, 40.0], [46.0, 46.0], [40.0, 46.0]]),
|
||||
plain,
|
||||
),
|
||||
case(
|
||||
"flat-triangle",
|
||||
polygon(&[[40.0, 40.0], [100.0, 40.0], [70.0, 44.6]]),
|
||||
plain,
|
||||
),
|
||||
case(
|
||||
"arc-disc-6",
|
||||
path("M40 50a3 3 0 1 0 6 0a3 3 0 1 0 -6 0Z"),
|
||||
plain,
|
||||
),
|
||||
case(
|
||||
"cubic-lens",
|
||||
path("M40 50C50 44 70 44 80 50C70 56 50 56 40 50Z"),
|
||||
plain,
|
||||
),
|
||||
case("ell-3.6", ell(40.0, 40.0, 3.6), plain),
|
||||
// Winding 2 at the centre: filled by the layer's nonzero rule, whatever the drawing says.
|
||||
case(
|
||||
"pentagram-evenodd-root",
|
||||
star(60.0, 60.0, 10.0),
|
||||
"fill-rule=\"evenodd\" ",
|
||||
),
|
||||
// Refused: no interior a tap reaches on the phone.
|
||||
case("forth-and-back", path("M40 40L90 90L40 40"), plain),
|
||||
case(
|
||||
"square-twice-opposite",
|
||||
path("M40 40h40v40h-40zM40 40v40h40v-40z"),
|
||||
plain,
|
||||
),
|
||||
case(
|
||||
"diagonal-sliver",
|
||||
polygon(&[[40.0, 40.0], [90.0, 90.0], [90.0, 88.6]]),
|
||||
plain,
|
||||
),
|
||||
case(
|
||||
"cubic-there-and-back",
|
||||
path("M40 80C50 40 80 40 90 80C80 40 50 40 40 80Z"),
|
||||
plain,
|
||||
),
|
||||
case(
|
||||
"arc-there-and-back",
|
||||
path("M40 80A25 25 0 0 1 90 80A25 25 0 0 0 40 80Z"),
|
||||
plain,
|
||||
),
|
||||
case(
|
||||
"flat-ellipse-45",
|
||||
path("M40 40A35 1 45 0 1 90 90A35 1 45 0 1 40 40Z"),
|
||||
plain,
|
||||
),
|
||||
case("ell-3.3", ell(40.0, 40.0, 3.3), plain),
|
||||
case(
|
||||
"triangle-6.6",
|
||||
polygon(&[[40.0, 45.716], [46.6, 45.716], [43.3, 40.0]]),
|
||||
plain,
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
/// The equine draft's polygons and paths: their widest disc, in the frame's units.
|
||||
fn equine() -> Vec<Value> {
|
||||
let text = common::repo_file("supabase/seed/anatomical-sheets/equine/draft/document.json");
|
||||
let doc: AnatomicalSheetDocument = serde_json::from_str(&text).unwrap();
|
||||
doc.annotations
|
||||
.iter()
|
||||
.filter_map(|a| {
|
||||
let geometry = match a {
|
||||
Annotation::Observable(o) => o.geometry.as_ref(),
|
||||
Annotation::DetailTrigger(t) => t.geometry.as_ref(),
|
||||
}?;
|
||||
if matches!(geometry, Geometry::Circle(_)) {
|
||||
return None;
|
||||
}
|
||||
Some(json!({ "id": a.id(), "view": a.view_id(), "widest": widest(geometry) }))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_interior_probe_is_current() {
|
||||
let cases = cases();
|
||||
for c in &cases {
|
||||
let refused = c["codes"] == json!([THIN]);
|
||||
assert!(c["accepted"] == json!(true) || refused, "{}", c["name"]);
|
||||
}
|
||||
let probe = json!({
|
||||
"generatedBy": "crates/core/tests/interior_probe.rs",
|
||||
"frame": { "width": 286, "height": 310 },
|
||||
"cases": cases,
|
||||
"equine": equine(),
|
||||
});
|
||||
let text = serde_json::to_string_pretty(&probe).unwrap() + "\n";
|
||||
let path = format!("{}/../../{FIXTURE}", env!("CARGO_MANIFEST_DIR"));
|
||||
if std::env::var("MAKE_INTERIOR_PROBE").is_ok_and(|v| v == "1") {
|
||||
std::fs::write(&path, &text).unwrap();
|
||||
}
|
||||
assert!(
|
||||
common::repo_file(FIXTURE) == text,
|
||||
"{FIXTURE} is stale: MAKE_INTERIOR_PROBE=1 cargo test --test interior_probe"
|
||||
);
|
||||
}
|
||||
@@ -24,10 +24,12 @@ use serde_json::{Value, json};
|
||||
const SEED: &str = "supabase/seed/anatomical-sheets/equine/draft";
|
||||
const HORSE_ID: &str = "7f767f74-3b36-51a7-8465-52dd7e2ead4a";
|
||||
const TOO_SMALL: &str = "annotation.geometry.too_small";
|
||||
const THIN: &str = "annotation.geometry.interior_too_small";
|
||||
const NO_FRAME: &str = "view.frame.unknown";
|
||||
const OUT_OF_FRAME: &str = "annotation.geometry.out_of_frame";
|
||||
/// The verdict's closed codes, as the SQL stores them.
|
||||
const SMALL_FAILURE: &str = "verification.validation.marker_too_small";
|
||||
const THIN_FAILURE: &str = "verification.validation.marker_interior_too_small";
|
||||
const FRAME_FAILURE: &str = "verification.validation.out_of_frame";
|
||||
|
||||
/// The frame and size issues `(code, path)`, the verdict and the preview agreeing, and the
|
||||
@@ -68,7 +70,7 @@ fn judged(
|
||||
let state = PreviewSheet::load(input, given).unwrap().state().unwrap();
|
||||
let issues = |all: &[faunosteo_core::domain::sheet::SheetIssue]| -> Vec<(String, String)> {
|
||||
all.iter()
|
||||
.filter(|i| [TOO_SMALL, NO_FRAME, OUT_OF_FRAME].contains(&i.code.as_str()))
|
||||
.filter(|i| [TOO_SMALL, THIN, NO_FRAME, OUT_OF_FRAME].contains(&i.code.as_str()))
|
||||
.map(|i| (i.code.clone(), i.path.clone()))
|
||||
.collect()
|
||||
};
|
||||
@@ -179,28 +181,50 @@ fn the_blown_up_horse_is_refused() {
|
||||
assert_eq!(text, equine(), "the document is never rewritten");
|
||||
}
|
||||
|
||||
/// The threshold on the real sheet: the junctions fall below 4 px once the horse is scaled by
|
||||
/// more than 4.966 / 4 ≈ 1.2414; the other points (disc r 22) hold until ≈ 1.517.
|
||||
/// The threshold on the real sheet. The caudal zone's widest disc (4.951 px) falls below 4 px
|
||||
/// first, once the horse is scaled by more than 4.951 / 4 ≈ 1.2378; then the junctions, past
|
||||
/// 4.966 / 4 ≈ 1.2414; the other points (disc r 22) hold until ≈ 1.517, the other zones (at
|
||||
/// least 11.30 px) until ≈ 2.8. In doubt the measure refuses: at 1.236 (4.006 px) the search,
|
||||
/// which cuts no cell below 0.05 px, has not shown the disc.
|
||||
#[test]
|
||||
fn the_equine_threshold_falls_on_the_junctions_first() {
|
||||
fn the_equine_threshold_falls_on_the_caudal_zone_then_the_junctions() {
|
||||
let text = equine();
|
||||
let small = |factor: f64| -> Vec<String> {
|
||||
let small = |factor: f64| -> Vec<(String, String)> {
|
||||
let (issues, _) = judged(&text, &[(HORSE_ID, &scaled_horse(factor))]);
|
||||
let doc: Value = serde_json::from_str(&text).unwrap();
|
||||
issues
|
||||
let mut found: Vec<(String, String)> = issues
|
||||
.iter()
|
||||
.map(|(_, path)| {
|
||||
.map(|(code, path)| {
|
||||
let index: usize = path[12..path.len() - 10].parse().unwrap();
|
||||
doc["annotations"][index]["id"].as_str().unwrap().to_owned()
|
||||
let id = doc["annotations"][index]["id"].as_str().unwrap();
|
||||
(id.to_owned(), code.clone())
|
||||
})
|
||||
.collect()
|
||||
.collect();
|
||||
found.sort();
|
||||
found
|
||||
};
|
||||
assert!(small(1.24).is_empty());
|
||||
let mut junctions = small(1.25);
|
||||
junctions.sort();
|
||||
assert_eq!(junctions, ["c7-t1", "l6-s1", "t18-l1"]);
|
||||
assert_eq!(small(1.51).len(), 3);
|
||||
assert_eq!(small(1.52).len(), 13, "every point, the zones still shown");
|
||||
let pair = |id: &str, code: &str| (id.to_owned(), code.to_owned());
|
||||
assert!(small(1.23).is_empty());
|
||||
assert_eq!(small(1.24), [pair("caudal", THIN)]);
|
||||
let (_, failures) = judged(&text, &[(HORSE_ID, &scaled_horse(1.24))]);
|
||||
assert_eq!(
|
||||
failures,
|
||||
[THIN_FAILURE],
|
||||
"the interior alone, never a rules failure"
|
||||
);
|
||||
assert_eq!(
|
||||
small(1.25),
|
||||
[
|
||||
pair("c7-t1", TOO_SMALL),
|
||||
pair("caudal", THIN),
|
||||
pair("l6-s1", TOO_SMALL),
|
||||
pair("t18-l1", TOO_SMALL),
|
||||
]
|
||||
);
|
||||
assert_eq!(small(1.51).len(), 4);
|
||||
let past = small(1.52);
|
||||
assert_eq!(past.len(), 14, "every point and the caudal zone");
|
||||
assert_eq!(past.iter().filter(|(_, code)| code == THIN).count(), 1);
|
||||
}
|
||||
|
||||
/// A point shows its visible disc, `2 × max(2, r − 12)`, never its transparent hitbox; at
|
||||
@@ -381,3 +405,152 @@ fn path_numbers_past_the_frame_magnitude_are_refused() {
|
||||
assert_eq!(main(d), [OUT_OF_FRAME], "{d}");
|
||||
}
|
||||
}
|
||||
|
||||
/// The last MEDIUM (owner brief 2026-11-01, zone without interior): a polygon or a path must fill
|
||||
/// a disc of 4 px on the smallest preview, its stroke left out. A frame of 286 × 310 units shows
|
||||
/// one unit per CSS px on the main view. Each shape passes the bounds rule (it was accepted
|
||||
/// before this rule) and is now refused.
|
||||
#[test]
|
||||
fn shapes_without_a_usable_interior_are_refused() {
|
||||
let phone = "0 0 286 310";
|
||||
let hostile = [
|
||||
// A path drawn forth and back: winding 0 everywhere.
|
||||
path("M20 20L200 200L20 20"),
|
||||
path("M20 20L200 20L200 200L200 20Z"),
|
||||
// The same square twice, in opposite directions: winding 0 under nonzero.
|
||||
path("M20 20h100v100h-100zM20 20v100h100v-100z"),
|
||||
// A near-flat polygon on the diagonal, 1 px thick, 180 px of bounds.
|
||||
json!({ "type": "polygon", "points": [[20, 20], [200, 200], [200, 198.6]] }),
|
||||
// A cubic and an arc travelled there and back.
|
||||
path("M20 150C60 20 160 20 200 150C160 20 60 20 20 150Z"),
|
||||
path("M20 150A90 90 0 0 1 200 150A90 90 0 0 0 20 150Z"),
|
||||
// A flat ellipse turned 45°: 2 px thick, 127 px of bounds.
|
||||
path("M50 50A127 1 45 0 1 230 230A127 1 45 0 1 50 50Z"),
|
||||
// An L whose arms are 3.3 px wide: its widest disc, at the elbow, is 3.87 px.
|
||||
json!({ "type": "polygon", "points": [[20, 20], [80, 20], [80, 23.3], [23.3, 23.3], [23.3, 80], [20, 80]] }),
|
||||
];
|
||||
for geometry in hostile {
|
||||
let found = on_main(geometry.clone(), phone);
|
||||
assert_eq!(codes(&found), [THIN], "{geometry}");
|
||||
assert!(found.1.iter().any(|f| f == THIN_FAILURE), "{:?}", found.1);
|
||||
}
|
||||
}
|
||||
|
||||
/// Small shapes that fill: a 4.5 px tall triangle, a disc of 6 px drawn with two arcs, a cubic
|
||||
/// lens, the L with 3.6 px arms (4.22 px at the elbow), a pentagram whose centre has winding 2
|
||||
/// (the layer fills nonzero: 6.18 px; under evenodd only a tip would hold 3.26 px).
|
||||
#[test]
|
||||
fn small_shapes_that_fill_are_accepted() {
|
||||
let phone = "0 0 286 310";
|
||||
let legitimate = [
|
||||
json!({ "type": "polygon", "points": [[20, 20], [200, 20], [110, 24.5]] }),
|
||||
path("M100 100a3 3 0 1 0 6 0a3 3 0 1 0 -6 0Z"),
|
||||
path("M20 100C40 90 60 90 80 100C60 110 40 110 20 100Z"),
|
||||
json!({ "type": "polygon", "points": [[20, 20], [80, 20], [80, 23.6], [23.6, 23.6], [23.6, 80], [20, 80]] }),
|
||||
json!({ "type": "polygon", "points": star(100.0, 100.0, 10.0) }),
|
||||
];
|
||||
for geometry in legitimate {
|
||||
assert!(
|
||||
codes(&on_main(geometry.clone(), phone)).is_empty(),
|
||||
"{geometry}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn star(cx: f64, cy: f64, r: f64) -> Vec<[f64; 2]> {
|
||||
(0..5)
|
||||
.map(|i| {
|
||||
let angle =
|
||||
-std::f64::consts::FRAC_PI_2 + f64::from(i * 2) * std::f64::consts::TAU / 5.0;
|
||||
[cx + r * angle.cos(), cy + r * angle.sin()]
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The threshold, on a shape whose widest disc is off its bounds' centre: an L with arms `w`
|
||||
/// wide holds a disc of `2√2 w / (1 + √2)` at its elbow, a sharp peak the search approaches
|
||||
/// from below. In doubt it refuses: measured, the first L accepted holds 4.026 px.
|
||||
#[test]
|
||||
fn the_interior_threshold_holds_at_its_edge() {
|
||||
let elbow = |w: f64| {
|
||||
let shape = json!({ "type": "polygon", "points": [[20, 20], [80, 20], [80, 20.0 + w], [20.0 + w, 20.0 + w], [20.0 + w, 80], [20, 80]] });
|
||||
codes(&on_main(shape, "0 0 286 310"))
|
||||
};
|
||||
let diameter = |w: f64| 2.0 * std::f64::consts::SQRT_2 * w / (1.0 + std::f64::consts::SQRT_2);
|
||||
assert!((diameter(3.44) - 4.030).abs() < 1e-3);
|
||||
assert!(elbow(3.44).is_empty(), "4.030 px");
|
||||
assert_eq!(elbow(3.43), [THIN], "4.019 px, in the doubt band");
|
||||
assert_eq!(elbow(3.41), [THIN], "3.995 px");
|
||||
}
|
||||
|
||||
/// Extreme frames and scales: the measure follows the projection, not the units. The same L at
|
||||
/// a tenth of the scale, near the offset limit, and in a one-unit frame.
|
||||
#[test]
|
||||
fn the_interior_follows_the_projection() {
|
||||
let l = |x: f64, y: f64, unit: f64, w: f64| {
|
||||
let p = |a: f64, b: f64| [x + a * unit, y + b * unit];
|
||||
json!({ "type": "polygon", "points": [p(0.0, 0.0), p(60.0, 0.0), p(60.0, w), p(w, w), p(w, 60.0), p(0.0, 60.0)] })
|
||||
};
|
||||
// Ten units per px.
|
||||
assert!(codes(&on_main(l(200.0, 200.0, 10.0, 3.6), "0 0 2860 3100")).is_empty());
|
||||
assert_eq!(
|
||||
codes(&on_main(l(200.0, 200.0, 10.0, 3.3), "0 0 2860 3100")),
|
||||
[THIN]
|
||||
);
|
||||
// The far edge at 256 spans (`MAX_FRAME_OFFSET_RATIO`): 2 860 units across, 0.1 px each.
|
||||
let near = MAX_FRAME_OFFSET_RATIO * 2860.0 - 2860.0;
|
||||
let frame = format!("{near} 0 2860 3100");
|
||||
assert!(codes(&on_main(l(near + 200.0, 200.0, 10.0, 3.6), &frame)).is_empty());
|
||||
assert_eq!(
|
||||
codes(&on_main(l(near + 200.0, 200.0, 10.0, 3.3), &frame)),
|
||||
[THIN]
|
||||
);
|
||||
// A one-unit frame: 286 px per unit.
|
||||
let unit = 1.0 / 286.0;
|
||||
assert!(codes(&on_main(l(0.1, 0.1, unit, 3.6), "0 0 1 1.0839")).is_empty());
|
||||
assert_eq!(
|
||||
codes(&on_main(l(0.1, 0.1, unit, 3.3), "0 0 1 1.0839")),
|
||||
[THIN]
|
||||
);
|
||||
}
|
||||
|
||||
/// A drawing scaled inside never changes the interior: the markers are drawn in the frame.
|
||||
#[test]
|
||||
fn drawing_transforms_never_change_the_interior() {
|
||||
let mut doc: Value = serde_json::from_str(&document()).unwrap();
|
||||
doc["annotations"][0]["geometry"] = path("M20 20L200 200L20 20");
|
||||
let scaled = OPEN.replace("0 0 10 10", "0 0 286 310")
|
||||
+ "<g transform=\"scale(1000)\"><path d=\"M0 0h10v10z\"/></g></svg>";
|
||||
let plain = OPEN.to_owned() + "<path d=\"M0 0h1\"/></svg>";
|
||||
let (issues, _) = judged(
|
||||
&doc.to_string(),
|
||||
&[(MAIN_ASSET, &scaled), (DETAIL_ASSET, &plain)],
|
||||
);
|
||||
assert_eq!(
|
||||
issues,
|
||||
[(THIN.to_owned(), "annotations[0].geometry".to_owned())]
|
||||
);
|
||||
}
|
||||
|
||||
/// Over the measure's caps the shape is refused, never accepted: a disc drawn with 5 000 vertices.
|
||||
#[test]
|
||||
fn a_shape_too_complex_to_measure_is_refused() {
|
||||
let ring = |count: u32| {
|
||||
let points: Vec<[f64; 2]> = (0..count)
|
||||
.map(|i| {
|
||||
let angle = f64::from(i) * std::f64::consts::TAU / f64::from(count);
|
||||
[143.0 + 100.0 * angle.cos(), 155.0 + 100.0 * angle.sin()]
|
||||
})
|
||||
.collect();
|
||||
json!({ "type": "polygon", "points": points })
|
||||
};
|
||||
assert!(codes(&on_main(ring(4096), "0 0 286 310")).is_empty());
|
||||
assert_eq!(codes(&on_main(ring(4097), "0 0 286 310")), [THIN]);
|
||||
// The same cap on a path's outline, its curves' chords counted.
|
||||
let square = |sides: usize| format!("M40 40{}h100v100h-100Z", "h0.001".repeat(sides));
|
||||
assert_eq!(
|
||||
codes(&on_main(path(&square(4092)), "0 0 286 310")),
|
||||
Vec::<String>::new()
|
||||
);
|
||||
assert_eq!(codes(&on_main(path(&square(4093)), "0 0 286 310")), [THIN]);
|
||||
}
|
||||
Reference in new issue
Block a user