mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-25 10:17:02 -06:00
The Effect menu had no Rasterize. Object › Rasterize replaces the object with an image, so its paths can no longer be edited. Effect › Rasterize… (`rasterize`) is a live effect with Object › Rasterize's options: color model, resolution (the document's raster effects resolution by default), white or transparent background, anti-aliasing, Create Clipping Mask and Add Around Object. The canvas draws the object as square pixels over its bounds, and its paths, type and other art stay as they are. The effects above it in the stack, shadows included, are part of its image, and shadows below it are cast by the image. When Rasterize is an object's only raster effect, Expand Appearance and PDF and SVG export give the image Object › Rasterize gives with the same options. Object › Rasterize now measures the art as drawn, with its geometry effects, brush art and raster effects, so a Transform effect that moves the art no longer leaves the image empty. Its Create Clipping Mask clips the image to the art as drawn. The canvas no longer panics drawing a pixel effect such as Gaussian Blur on an object about 65,500 screen pixels wide: the raster of such an object is at most 32,768 pixels a side, and the object is drawn into it at a lower resolution. Docs: docs/mcp.md, docs/effects-parity.md, docs/target-app-parity.md, ROADMAP.
39 lines
1.7 KiB
Rust
39 lines
1.7 KiB
Rust
//! Scale Strokes & Effects on effects: the catalogue's distance parameters and `scale_effect`.
|
|
|
|
use serde_json::json;
|
|
use vectorcraft_doc::Effect;
|
|
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn every_distance_parameter_is_a_parameter() {
|
|
for e in effect_catalog() {
|
|
for k in e.lengths.always.iter().chain(e.lengths.absolute) {
|
|
assert!(e.defaults.get(*k).is_some() || e.params.contains(&format!("{k}?:")), "{}: `{k}` is not a parameter", e.id);
|
|
}
|
|
if !e.lengths.absolute.is_empty() {
|
|
assert!(e.defaults.get("relative").is_some(), "{}: absolute lengths need a `relative` param", e.id);
|
|
}
|
|
}
|
|
}
|
|
|
|
#[test]
|
|
fn scale_effect_scales_distances_only() {
|
|
let mut e = new_effect("stylize.dropShadow", &json!({"x": 3, "y": "4 pt"})).unwrap();
|
|
scale_effect(&mut e, 2.0);
|
|
assert_eq!((&e.params["x"], &e.params["y"], &e.params["blur"]), (&json!(6.0), &json!(8.0), &json!(10.0)));
|
|
assert_eq!(e.params["opacity"], json!(75.0));
|
|
// Rasterize's Add Around Object is a distance; its resolution isn't.
|
|
let mut r = new_effect(RASTERIZE, &json!({"addAround": 10, "resolution": 150})).unwrap();
|
|
scale_effect(&mut r, 2.0);
|
|
assert_eq!((&r.params["addAround"], &r.params["resolution"]), (&json!(20.0), &json!(150)));
|
|
// Outline Stroke without a weight follows its stroke's: nothing to scale.
|
|
let mut o = Effect { id: "path.outlineStroke".into(), params: json!(null), visible: true };
|
|
scale_effect(&mut o, 2.0);
|
|
assert_eq!(o.params, json!(null));
|
|
// Relative tweaks are percentages of the object's size.
|
|
let mut t = new_effect("distort.tweak", &json!({"h": 10, "relative": true})).unwrap();
|
|
scale_effect(&mut t, 2.0);
|
|
assert_eq!(t.params["h"], json!(10));
|
|
}
|