mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-25 10:17:02 -06:00
Geometry effects reach objects that aren't paths through their outlines (vectorcraft_effects:: reshape: glyph outlines, evaluated live art, the symbol's art, an image clipped by its reshaped frame), applied to the whole art as one piece; the renderer caches that art per object and paints raster effects around it in the same filter layers paths use (shared Renderer::raster_fx, also used per fill/stroke). Exports bake the reshaped art; SVG writes per-item filters; PDF warns about raster effects on strokes as well as fills and objects. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
30 lines
1.1 KiB
Rust
30 lines
1.1 KiB
Rust
//! Raster effects in PDF export: not written yet, so a fill's, a stroke's or the object's own
|
|
//! raster effect is reported.
|
|
|
|
use vectorcraft_color::{Color, Paint};
|
|
use vectorcraft_doc::{Appearance, Document, Effect, Node, NodeId};
|
|
use vectorcraft_geom::{Rect, shapes};
|
|
|
|
use crate::*;
|
|
|
|
fn warnings(item: Option<usize>) -> Vec<String> {
|
|
let mut d = Document::new(100.0, 100.0);
|
|
let mut n = Node::path(
|
|
NodeId(0),
|
|
shapes::rectangle(Rect::new(20.0, 20.0, 80.0, 80.0)),
|
|
Appearance::basic(Paint::solid(Color::WHITE), Paint::solid(Color::BLACK), 2.0),
|
|
);
|
|
n.appearance.effects_mut(item).unwrap().push(Effect { id: "stylize.outerGlow".into(), params: Default::default(), visible: true });
|
|
n.id = d.alloc_id();
|
|
let layer = d.default_layer().unwrap();
|
|
d.insert(Some(layer), 0, n).unwrap();
|
|
export_with_report(&d, &PdfOptions::default()).unwrap().warnings
|
|
}
|
|
|
|
#[test]
|
|
fn raster_effects_warn_on_fills_strokes_and_objects() {
|
|
for item in [None, Some(0), Some(1)] {
|
|
assert!(warnings(item).iter().any(|w| w.starts_with("raster effects")), "{item:?}");
|
|
}
|
|
}
|