mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-24 03:12:57 +01:00
Merge upstream/main into fix/2414-svg-classes
This commit is contained in:
commit
fce9b70e0f
80 files changed
+1400
-212
No files matched your search
Generated
+1
@@ -5022,6 +5022,7 @@ dependencies = [
|
||||
name = "vectorcraft-ui-egui"
|
||||
version = "0.14.0"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"craft-ui",
|
||||
"egui",
|
||||
"egui_extras",
|
||||
|
||||
@@ -253,7 +253,7 @@ The scores are self-assessed from our code against public documentation;
|
||||
- reliable exchange of .ai files (layer structure in real files; proprietary editing data isn't written);
|
||||
- an interaction-fidelity pass covering every tool's modifiers and small behaviours;
|
||||
- 3D and Materials beyond the initial live Revolve (Extrude & Bevel, Inflate, Rotate, materials);
|
||||
- most of the raster effects (10 of 57 still missing; Cutout, Film Grain, Neon Glow, Plastic Wrap, Poster Edges, Smudge Stick, Sponge and Watercolor are available under Artistic, Bas Relief, Chalk & Charcoal, Charcoal, Chrome, Graphic Pen, Halftone Pattern, Note Paper, Photocopy, Plaster, Reticulation, Stamp and Water Paper under Sketch) and the Effect Gallery;
|
||||
- most of the raster effects (9 of 57 still missing; Cutout, Film Grain, Neon Glow, Plastic Wrap, Poster Edges, Smudge Stick, Sponge and Watercolor are available under Artistic, Bas Relief, Chalk & Charcoal, Charcoal, Chrome, Graphic Pen, Halftone Pattern, Note Paper, Photocopy, Plaster, Reticulation, Stamp, Torn Edges and Water Paper under Sketch) and the Effect Gallery;
|
||||
- CJK composition for vertical type (vertical type itself has initial support, with a Japanese interface);
|
||||
- scripting, and the rest of Variables (image and graph kinds, dataset import);
|
||||
- generative AI features.
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ blocking it ([Alpha gate](docs/roadmap.md#alpha-gate)).
|
||||
|
||||
| | Value | Kind |
|
||||
|---|---|---|
|
||||
| **Feature breadth** (Illustrator's menu items, tools, effects, formats exist) | **~88%** | measured in part: menu items 348/375 wired (92.8%), tools 89/92, Illustrator effects 46/50, Photoshop effects 52/57, 3D 4/4 (initial types, no materials) |
|
||||
| **Feature breadth** (Illustrator's menu items, tools, effects, formats exist) | **~88%** | measured in part: menu items 348/375 wired (92.8%), tools 89/92, Illustrator effects 46/50, Photoshop effects 54/57, 3D 4/4 (initial types, no materials) |
|
||||
| **Feature depth** (weighted by use, scored by behaviour) | **~75%** | estimated |
|
||||
| **To beta** | **~170–270 h** one agent · ~50–80 h with 4–6 agents | estimated |
|
||||
| **To full parity** | **~360–590 h** one agent · ~95–165 h with 4–6 agents | estimated |
|
||||
|
||||
@@ -238,6 +238,11 @@ pub struct DocSetup {
|
||||
pub export_text: ExportText,
|
||||
/// Background Contents chosen in New Document.
|
||||
pub background: Background,
|
||||
/// Character panel menu › System Layout: every text object advances by whole points. Off by
|
||||
/// default and for documents from before it, and saved only when on.
|
||||
/// <https://helpx.adobe.com/illustrator/desktop/design-with-text/edit-format-text/turn-fractional-character-widths-off-or-on.html>
|
||||
#[serde(default, rename = "systemLayout", skip_serializing_if = "crate::skip::is_default")]
|
||||
pub system_layout: bool,
|
||||
}
|
||||
|
||||
impl Default for DocSetup {
|
||||
@@ -260,6 +265,7 @@ impl Default for DocSetup {
|
||||
small_caps_size: 70.0,
|
||||
export_text: ExportText::Editable,
|
||||
background: Background::Transparent,
|
||||
system_layout: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,6 +109,12 @@ pub struct CharStyle {
|
||||
/// its proportional heights, `vpal`.
|
||||
#[serde(default, rename = "proportionalMetrics", skip_serializing_if = "crate::skip::is_default")]
|
||||
pub proportional_metrics: bool,
|
||||
/// Tate-chu-yoko (Character panel menu, East Asian options): in vertical type these characters
|
||||
/// stand side by side across one em of the column. Horizontal type keeps the mark and does not
|
||||
/// move them. Two or three half-width digits do this without the mark.
|
||||
/// <https://helpx.adobe.com/illustrator/using/formatting-asian-characters.html>
|
||||
#[serde(default, rename = "tateChuYoko", skip_serializing_if = "crate::skip::is_default")]
|
||||
pub tate_chu_yoko: bool,
|
||||
/// Digits (Character panel menu, Middle Eastern options): the numeral system the digits of
|
||||
/// these characters are drawn in, whatever digits were typed.
|
||||
#[serde(default, skip_serializing_if = "crate::skip::is_default")]
|
||||
@@ -292,6 +298,7 @@ impl Default for CharStyle {
|
||||
position: CharPosition::Normal,
|
||||
char_align: CharAlign::RomanBaseline,
|
||||
proportional_metrics: false,
|
||||
tate_chu_yoko: false,
|
||||
small_caps: None,
|
||||
digits: Digits::Default,
|
||||
no_break: false,
|
||||
@@ -1413,6 +1420,11 @@ pub struct TextObject {
|
||||
/// Off for new type and for documents from before it, and saved only when on.
|
||||
#[serde(default, rename = "opticalMarginAlignment", skip_serializing_if = "crate::skip::is_default")]
|
||||
pub optical_margin: bool,
|
||||
/// Character panel menu › System Layout, copied from the document: when on, each character
|
||||
/// that takes space advances by a whole number of points. Off by default, and saved only when
|
||||
/// on. The document setting is [`crate::DocSetup::system_layout`].
|
||||
#[serde(default, rename = "systemLayout", skip_serializing_if = "crate::skip::is_default")]
|
||||
pub system_layout: bool,
|
||||
/// Character panel menu › Fractional Widths: spacing between characters uses fractions of a
|
||||
/// point. On for new type and for documents from before it, and saved only when off. Off, each
|
||||
/// character that takes any space advances by a whole number of points, at least one, so small
|
||||
@@ -1517,6 +1529,7 @@ impl TextObject {
|
||||
path_spacing: 0.0,
|
||||
wrap: Vec::new(),
|
||||
optical_margin: false,
|
||||
system_layout: false,
|
||||
fractional_widths: true,
|
||||
cached_bounds: None,
|
||||
cached_baselines: Vec::new(),
|
||||
|
||||
+82
-28
@@ -13,13 +13,14 @@
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use serde_json::Value;
|
||||
use vectorcraft_doc::color::{Color, Paint};
|
||||
use vectorcraft_doc::{Appearance, AppearanceItem, Node, NodeId, NodeKind, StrokeLayer};
|
||||
use vectorcraft_geom::{FillRule, PathData, Rect};
|
||||
use vectorcraft_pathops::{self as po, PathfinderOp};
|
||||
|
||||
/// Effect ids of the Pathfinder submenu with their operation, in Illustrator's menu order.
|
||||
pub const PATHFINDER_EFFECTS: [(&str, &str, PathfinderOp); 11] = [
|
||||
pub const PATHFINDER_EFFECTS: [(&str, &str, PathfinderOp); 12] = [
|
||||
("pathfinder.add", "Add", PathfinderOp::Unite),
|
||||
("pathfinder.intersect", "Intersect", PathfinderOp::Intersect),
|
||||
("pathfinder.exclude", "Exclude", PathfinderOp::Exclude),
|
||||
@@ -31,6 +32,7 @@ pub const PATHFINDER_EFFECTS: [(&str, &str, PathfinderOp); 11] = [
|
||||
("pathfinder.crop", "Crop", PathfinderOp::Crop),
|
||||
("pathfinder.outline", "Outline", PathfinderOp::Outline),
|
||||
("pathfinder.hardMix", "Hard Mix", PathfinderOp::HardMix),
|
||||
("pathfinder.softMix", "Soft Mix", PathfinderOp::SoftMix),
|
||||
];
|
||||
|
||||
/// Is `id` an Effect → Pathfinder effect?
|
||||
@@ -140,7 +142,14 @@ pub fn pathfinder_children(group: &Node, hook: Option<OutlineHook>) -> Option<Ve
|
||||
if shapes.is_empty() {
|
||||
return Some(vec![]);
|
||||
}
|
||||
stack = if op == PathfinderOp::HardMix {
|
||||
stack = if op == PathfinderOp::SoftMix {
|
||||
let rate = mixing_rate(&e.params);
|
||||
po::regions(&shapes)
|
||||
.into_iter()
|
||||
.filter(|r| !r.path.is_empty())
|
||||
.map(|r| Arc::new(soft_mix_face(r.path, &r.sources, rate, &shapes, &sources)))
|
||||
.collect()
|
||||
} else if op == PathfinderOp::HardMix {
|
||||
po::regions(&shapes)
|
||||
.into_iter()
|
||||
.filter(|r| !r.path.is_empty())
|
||||
@@ -157,26 +166,55 @@ pub fn pathfinder_children(group: &Node, hook: Option<OutlineHook>) -> Option<Ve
|
||||
Some(stack)
|
||||
}
|
||||
|
||||
fn mixing_rate(params: &Value) -> f64 {
|
||||
params.get("mixingRate").and_then(|v| v.as_f64()).filter(|r| r.is_finite() && *r > 0.0 && *r <= 100.0).map(|r| r / 100.0).unwrap_or(0.5)
|
||||
}
|
||||
|
||||
fn fill_cmyk(src: &Node) -> Option<[f32; 4]> {
|
||||
let paint = src.appearance.fill_paint();
|
||||
let color = paint.color()?;
|
||||
let tinted = match paint {
|
||||
Paint::Solid { tint, .. } => color.tinted(tint),
|
||||
_ => color,
|
||||
};
|
||||
Some(tinted.to_cmyk())
|
||||
}
|
||||
|
||||
/// One face of a Soft Mix: CMYK blended bottom to top at `rate`; no stroke.
|
||||
fn soft_mix_face(path: PathData, covering: &[usize], rate: f64, shapes: &[po::Shape], sources: &[Node]) -> Node {
|
||||
let rate = rate as f32;
|
||||
let mut cmyk: Option<[f32; 4]> = None;
|
||||
for &si in covering {
|
||||
let Some(ch) = fill_cmyk(&sources[shapes[si].key as usize]) else { continue };
|
||||
cmyk = Some(match cmyk {
|
||||
None => ch,
|
||||
Some(acc) => {
|
||||
let t = rate;
|
||||
let u = 1.0 - t;
|
||||
[acc[0] * u + ch[0] * t, acc[1] * u + ch[1] * t, acc[2] * u + ch[2] * t, acc[3] * u + ch[3] * t]
|
||||
}
|
||||
});
|
||||
}
|
||||
let fill = cmyk.map(|c| Paint::solid(Color::cmyk(c[0], c[1], c[2], c[3]))).unwrap_or(Paint::None);
|
||||
soft_mix_styled(path, covering, shapes, sources, fill)
|
||||
}
|
||||
|
||||
/// One face of a Hard Mix: the max of each CMYK channel over every covering shape's fill; no stroke.
|
||||
fn hard_mix_face(path: PathData, covering: &[usize], shapes: &[po::Shape], sources: &[Node]) -> Node {
|
||||
let mut cmyk = [0.0f32; 4];
|
||||
let mut painted = false;
|
||||
for &si in covering {
|
||||
let src = &sources[shapes[si].key as usize];
|
||||
let paint = src.appearance.fill_paint();
|
||||
if let Some(color) = paint.color() {
|
||||
let tinted = match paint {
|
||||
Paint::Solid { tint, .. } => color.tinted(tint),
|
||||
_ => color,
|
||||
};
|
||||
let [c, m, y, k] = tinted.to_cmyk();
|
||||
for (out, v) in cmyk.iter_mut().zip([c, m, y, k]) {
|
||||
*out = out.max(v);
|
||||
}
|
||||
painted = true;
|
||||
let Some(ch) = fill_cmyk(&sources[shapes[si].key as usize]) else { continue };
|
||||
for (out, v) in cmyk.iter_mut().zip(ch) {
|
||||
*out = out.max(v);
|
||||
}
|
||||
painted = true;
|
||||
}
|
||||
let fill = if painted { Paint::solid(Color::cmyk(cmyk[0], cmyk[1], cmyk[2], cmyk[3])) } else { Paint::None };
|
||||
soft_mix_styled(path, covering, shapes, sources, fill)
|
||||
}
|
||||
|
||||
fn soft_mix_styled(path: PathData, covering: &[usize], shapes: &[po::Shape], sources: &[Node], fill: Paint) -> Node {
|
||||
let top = covering.last().and_then(|&si| sources.get(shapes[si].key as usize));
|
||||
let mut n = Node::path(top.map_or(NodeId(0), |s| s.id), path, Appearance::basic(fill, Paint::None, 0.0));
|
||||
if let Some(src) = top {
|
||||
@@ -359,19 +397,8 @@ mod tests {
|
||||
po::area(n.path_data().unwrap(), FillRule::NonZero).abs()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hard_mix_takes_the_highest_of_each_cmyk_channel_and_drops_strokes() {
|
||||
let a = Appearance::basic(Paint::solid(Color::cmyk(0.2, 0.66, 0.4, 0.0)), Paint::solid(Color::BLACK), 2.0);
|
||||
let b = Appearance::basic(Paint::solid(Color::cmyk(0.4, 0.2, 0.3, 0.1)), Paint::solid(Color::BLACK), 2.0);
|
||||
let mut g = Node::group(
|
||||
NodeId(10),
|
||||
vec![
|
||||
Arc::new(Node::path(NodeId(1), shapes::rectangle(Rect::new(0.0, 0.0, 10.0, 10.0)), a)),
|
||||
Arc::new(Node::path(NodeId(2), shapes::rectangle(Rect::new(5.0, 0.0, 15.0, 10.0)), b)),
|
||||
],
|
||||
);
|
||||
g.appearance.effects.push(Effect { id: "pathfinder.hardMix".into(), params: serde_json::json!({}), visible: true });
|
||||
let faces = pathfinder_children(&g, None).unwrap();
|
||||
fn overlap_cmyk(g: &Node) -> [f32; 4] {
|
||||
let faces = pathfinder_children(g, None).unwrap();
|
||||
assert_eq!(faces.len(), 3);
|
||||
let overlap = faces
|
||||
.iter()
|
||||
@@ -381,10 +408,37 @@ mod tests {
|
||||
})
|
||||
.expect("overlap face");
|
||||
assert!(overlap.appearance.stroke_paint().is_none());
|
||||
let [c, m, y, k] = overlap.appearance.fill_paint().color().unwrap().to_cmyk();
|
||||
overlap.appearance.fill_paint().color().unwrap().to_cmyk()
|
||||
}
|
||||
|
||||
fn two_overlapping_cmyk_squares() -> Node {
|
||||
let a = Appearance::basic(Paint::solid(Color::cmyk(0.2, 0.66, 0.4, 0.0)), Paint::solid(Color::BLACK), 2.0);
|
||||
let b = Appearance::basic(Paint::solid(Color::cmyk(0.4, 0.2, 0.3, 0.1)), Paint::solid(Color::BLACK), 2.0);
|
||||
Node::group(
|
||||
NodeId(10),
|
||||
vec![
|
||||
Arc::new(Node::path(NodeId(1), shapes::rectangle(Rect::new(0.0, 0.0, 10.0, 10.0)), a)),
|
||||
Arc::new(Node::path(NodeId(2), shapes::rectangle(Rect::new(5.0, 0.0, 15.0, 10.0)), b)),
|
||||
],
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn hard_mix_takes_the_highest_of_each_cmyk_channel_and_drops_strokes() {
|
||||
let mut g = two_overlapping_cmyk_squares();
|
||||
g.appearance.effects.push(Effect { id: "pathfinder.hardMix".into(), params: serde_json::json!({}), visible: true });
|
||||
let [c, m, y, k] = overlap_cmyk(&g);
|
||||
assert!((c - 0.4).abs() < 0.02 && (m - 0.66).abs() < 0.02 && (y - 0.4).abs() < 0.02 && (k - 0.1).abs() < 0.02, "{c} {m} {y} {k}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn soft_mix_blends_cmyk_bottom_to_top_and_drops_strokes() {
|
||||
let mut g = two_overlapping_cmyk_squares();
|
||||
g.appearance.effects.push(Effect { id: "pathfinder.softMix".into(), params: serde_json::json!({"mixingRate": 50.0}), visible: true });
|
||||
let [c, m, y, k] = overlap_cmyk(&g);
|
||||
assert!((c - 0.3).abs() < 0.02 && (m - 0.43).abs() < 0.02 && (y - 0.35).abs() < 0.02 && (k - 0.05).abs() < 0.02, "{c} {m} {y} {k}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shape_modes_follow_the_pathfinder_panel() {
|
||||
let add = pathfinder_children(&group_with("pathfinder.add"), None).unwrap();
|
||||
|
||||
@@ -82,7 +82,7 @@ pub use reshape::{expand_outlined, has_gradient_copies, has_item_geometry, image
|
||||
pub use revolve::{REVOLVE, has_revolve, revolve_art, revolve_options, validate_revolve};
|
||||
pub use solids::{
|
||||
EXTRUDE, INFLATE, ROTATE, ROTATION_PRESETS, SOLIDS, extrude_options, has_solid, inflate_options, is_three_d, solid_art, validate_solid,
|
||||
view_options,
|
||||
validate_three_d, view_options,
|
||||
};
|
||||
pub use warp::{WarpStyle, warp_point};
|
||||
|
||||
@@ -162,6 +162,7 @@ fn lengths_of(id: &str) -> Lengths {
|
||||
"sketch.graphicPen" => always(&["strokeLength"]),
|
||||
"sketch.halftonePattern" => always(&["size"]),
|
||||
"sketch.notePaper" => always(&["relief"]),
|
||||
"sketch.tornEdges" => always(&["smoothness"]),
|
||||
"sketch.waterPaper" => always(&["fiberLength"]),
|
||||
RASTERIZE => always(&["addAround"]),
|
||||
_ => Lengths::default(),
|
||||
@@ -378,6 +379,13 @@ pub fn effect_catalog() -> Vec<EffectInfo> {
|
||||
"{grain: 0..20 (4; monochrome noise in shadows and midtones), highlightArea: 0..20 (0; widens the bright highlight area), intensity: 0..10 (10; highlight strength and quieter highlight grain)}. Smooth document-space grain follows translations; minification uses approximate footprint filtering. Coverage and pure white are preserved; black takes light speckles, and saturated colour channels may clip. Grain 0 with either highlightArea 0 or intensity 0 leaves the art unchanged. Original visual approximation; chosen VectorCraft defaults.",
|
||||
json!({"grain": 4.0, "highlightArea": 0.0, "intensity": 10.0}),
|
||||
),
|
||||
r(
|
||||
"artistic.fresco",
|
||||
"Fresco…",
|
||||
ARTISTIC,
|
||||
"{brushSize: 1..10 (2; wider brush dabs), brushDetail: 0..10 (10; sharper edges and less smoothing), texture: 1..3 (1; deeper plaster relief)} repaints the object as coarse pigment on a textured wall, keeping its coverage. Original visual approximation; chosen VectorCraft defaults.",
|
||||
json!({"brushSize": 2.0, "brushDetail": 10.0, "texture": 1.0}),
|
||||
),
|
||||
r(
|
||||
"artistic.neonGlow",
|
||||
"Neon Glow…",
|
||||
@@ -639,6 +647,13 @@ pub fn effect_catalog() -> Vec<EffectInfo> {
|
||||
"{lightDarkBalance: 0..50 (25; the larger, the more of the object prints black), smoothness: 1..50 (5; rounds the shapes)} simplifies the object to solid black and white, as a rubber stamp would print it. Coverage is kept. Original visual approximation; chosen VectorCraft defaults.",
|
||||
json!({"lightDarkBalance": 25.0, "smoothness": 5.0}),
|
||||
),
|
||||
r(
|
||||
"sketch.tornEdges",
|
||||
"Torn Edges…",
|
||||
SKETCH,
|
||||
"{imageBalance: 0..50 (25; lower leaves more midtones as ink, higher as paper), smoothness: 0..15 (11; softens tones and the ragged edges), contrast: 0..20 (17; 20 is pure black and white)} redraws the object in high-contrast black and white with torn, ragged edges along its tones, keeping its coverage. Original visual approximation; chosen VectorCraft defaults.",
|
||||
json!({"imageBalance": 25.0, "smoothness": 11.0, "contrast": 17.0}),
|
||||
),
|
||||
r(
|
||||
"sketch.waterPaper",
|
||||
"Water Paper…",
|
||||
@@ -803,7 +818,17 @@ pub fn effect_catalog() -> Vec<EffectInfo> {
|
||||
v.push(g(id, label, WARP, WARP_DOC, json!({"bend": 50.0, "horizontal": 0.0, "vertical": 0.0, "orientation": "horizontal"})));
|
||||
}
|
||||
for (id, label, _) in PATHFINDER_EFFECTS {
|
||||
v.push(g(id, label, PATHFINDER, "{} (groups and layers: live Pathfinder over the members)", json!({})));
|
||||
if id == "pathfinder.softMix" {
|
||||
v.push(g(
|
||||
id,
|
||||
label,
|
||||
PATHFINDER,
|
||||
"{mixingRate?: 1..100 % (50)} blend overlapping fills in CMYK bottom to top (groups and layers: live Pathfinder over the members)",
|
||||
json!({"mixingRate": 50.0}),
|
||||
));
|
||||
} else {
|
||||
v.push(g(id, label, PATHFINDER, "{} (groups and layers: live Pathfinder over the members)", json!({})));
|
||||
}
|
||||
}
|
||||
v.push(g(
|
||||
CROP_MARKS,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//! Effect › Artistic (Colored Pencil, Cutout, Dry Brush, Film Grain, Neon Glow, Paint Daubs, Palette Knife, Plastic Wrap, Poster
|
||||
//! Effect › Artistic (Colored Pencil, Cutout, Dry Brush, Film Grain, Fresco, Neon Glow, Paint Daubs, Palette Knife, Plastic Wrap, Poster
|
||||
//! Edges, Rough Pastels, Smudge Stick, Sponge, Underpainting and Watercolor). Original filters built from
|
||||
//! public behaviour documentation:
|
||||
//! <https://helpx.adobe.com/illustrator/using/summary-effects.html> and
|
||||
@@ -10,7 +10,7 @@ use std::f64::consts::TAU;
|
||||
use super::brushstrokes::{LEFT, RIGHT, Smear, TONE_SOFTNESS, mix, streak, stroke_reach, unit, unpremultiply};
|
||||
use super::edges::sobel;
|
||||
use super::pixelate::{Around, Place, Soft, cell, point_in, rand, value_noise};
|
||||
use super::texture::{self, Light, Texture, Tones, luma, premultiply, straight, texturizer};
|
||||
use super::texture::{self, Light, Texture, Tones, luma, premultiply, smooth_noise, straight, texturizer};
|
||||
use super::{PixelSpace, blur_plane, pick};
|
||||
use vectorcraft_geom::{Point, Vec2};
|
||||
|
||||
@@ -72,6 +72,7 @@ pub(super) fn paint_daub_radius(size: f64) -> f64 {
|
||||
size.clamp(1.0, 50.0) * 0.48
|
||||
}
|
||||
const SALT_PENCIL: u64 = 304;
|
||||
const SALT_FRESCO: u64 = 320;
|
||||
|
||||
/// Keep the last cell's four corner values: magnified adjacent pixels often share a cell.
|
||||
/// The cache changes only cost, never the field, and needs constant storage per raster.
|
||||
@@ -426,6 +427,59 @@ fn rough_bristle(p: Point, k: u64) -> f32 {
|
||||
rand(SALT_DAUB + 3, i, j, k) as f32
|
||||
}
|
||||
|
||||
/// Fresco: coarse brush dabs on a plaster wall. `brush_size` (1..10) sets dab spacing,
|
||||
/// `brush_detail` (0..10) keeps sharper edges when high, and `texture` (1..3) deepens the
|
||||
/// relief. Coverage is kept.
|
||||
pub(super) fn fresco(px: &mut [[u8; 4]], w: usize, h: usize, space: &PixelSpace, brush_size: f64, brush_detail: f64, texture: f64) {
|
||||
if !([brush_size, brush_detail, texture].iter().all(|v| v.is_finite()) && space.px.is_finite() && space.px > 0.0) {
|
||||
return;
|
||||
}
|
||||
let Some(place) = Place::new(space, w, h) else { return };
|
||||
let brush_size = brush_size.clamp(1.0, 10.0);
|
||||
let brush_detail = brush_detail.clamp(0.0, 10.0);
|
||||
let texture = texture.round().clamp(1.0, 3.0);
|
||||
let side = 2.0 + 1.8 * brush_size;
|
||||
let sigma = (0.15 * (10.0 - brush_detail) * brush_size / place.px).max(0.0);
|
||||
let soft = Soft::new(px, w, sigma);
|
||||
let tex_strength = 0.08 + 0.07 * (texture - 1.0);
|
||||
let tex_scale = 3.0 / texture;
|
||||
let streak_mix = 0.25 * (1.0 - brush_detail / 10.0);
|
||||
place.each(px, |x, y, p| {
|
||||
if p[3] == 0 {
|
||||
return;
|
||||
}
|
||||
let q = place.at(x, y);
|
||||
let (Some(i), Some(j)) = (cell(q.x / side), cell(q.y / side)) else { return };
|
||||
let jx = (rand(SALT_FRESCO, i, j, 0) - 0.5) * 0.35 * side;
|
||||
let jy = (rand(SALT_FRESCO, i, j, 1) - 0.5) * 0.35 * side;
|
||||
let sample = Point::new(q.x + jx, q.y + jy);
|
||||
let mut sampled = soft.at(place.index(sample));
|
||||
if sampled[3] <= 0.0 {
|
||||
sampled = soft.at(place.index(q));
|
||||
}
|
||||
if sampled[3] <= 0.0 {
|
||||
return;
|
||||
}
|
||||
let [r, g, b, alpha] = sampled;
|
||||
let c = [r, g, b].map(|v| v / alpha);
|
||||
let angle = TAU * rand(SALT_FRESCO, i, j, 2);
|
||||
let (fx, fy) = (q.x - i as f64 * side, q.y - j as f64 * side);
|
||||
let along = fx * angle.cos() + fy * angle.sin();
|
||||
let streak = (1.0 - streak_mix * (0.5 + 0.5 * (along / side).sin().powi(2))) as f32;
|
||||
let bump = (1.0 + tex_strength * smooth_noise(SALT_FRESCO + 3, q, tex_scale * side)) as f32;
|
||||
let lit = c.map(|v| (v * streak * bump).clamp(0.0, 1.0));
|
||||
*p = premultiply(lit, f32::from(p[3]) / 255.0);
|
||||
});
|
||||
}
|
||||
|
||||
/// How far (document units) a Fresco dab can reach from a pixel.
|
||||
pub(super) fn fresco_reach(brush_size: f64, brush_detail: f64) -> f64 {
|
||||
let brush_size = brush_size.clamp(1.0, 10.0);
|
||||
let brush_detail = brush_detail.clamp(0.0, 10.0);
|
||||
let side = 2.0 + 1.8 * brush_size;
|
||||
side + 0.15 * (10.0 - brush_detail) * brush_size
|
||||
}
|
||||
|
||||
/// How far (document units) Plastic Wrap's softened relief is sampled at `smoothness` (1..15).
|
||||
pub(super) fn plastic_reach(smoothness: f64) -> f64 {
|
||||
3.0 * (0.15 + 0.35 * smoothness.clamp(1.0, 15.0))
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//! Photoshop-style raster effects (Effect › Artistic › Colored Pencil, Cutout, Dry Brush, Film Grain, Neon Glow, Paint Daubs, Plastic Wrap and
|
||||
//! Photoshop-style raster effects (Effect › Artistic › Colored Pencil, Cutout, Dry Brush, Film Grain, Fresco, Neon Glow, Paint Daubs, Plastic Wrap and
|
||||
//! Poster Edges, Rough Pastels, Smudge Stick, Sponge and Watercolor, Blur › Radial Blur and Smart Blur, Brush Strokes › Accented Edges, Angled Strokes,
|
||||
//! Crosshatch, Dark Strokes, Ink Outlines, Spatter, Sprayed Strokes and Sumi-e, Distort › Diffuse
|
||||
//! Glow, Glass and Ocean Ripple, Pixelate › Color Halftone, Crystallize, Mezzotint and Pointillize,
|
||||
//! Sharpen › Unsharp Mask, Sketch › Bas Relief, Chalk & Charcoal, Charcoal, Graphic Pen, Halftone Pattern, Note Paper, Photocopy, Plaster,
|
||||
//! Reticulation and Stamp, Stylize ›
|
||||
//! Reticulation, Stamp and Torn Edges, Stylize ›
|
||||
//! Glowing Edges, Texture
|
||||
//! › Craquelure, Grain, Mosaic Tiles, Patchwork, Stained Glass and Texturizer, and Video ›
|
||||
//! De-Interlace and NTSC Colors): filters over premultiplied RGBA8 pixels.
|
||||
@@ -44,11 +44,12 @@ pub use sketch::{HALFTONE_TYPES, HalftonePattern};
|
||||
pub use texture::{GRAIN_TYPES, Grain, LIGHT_DIRECTIONS, Light, TEXTURES, TEXTURES_LOADED, Texture};
|
||||
|
||||
/// The Photoshop-style effect ids (all raster effects, see [`crate::is_raster`]).
|
||||
pub const PIXEL_EFFECTS: [&str; 53] = [
|
||||
pub const PIXEL_EFFECTS: [&str; 55] = [
|
||||
"artistic.coloredPencil",
|
||||
"artistic.cutout",
|
||||
"artistic.dryBrush",
|
||||
"artistic.filmGrain",
|
||||
"artistic.fresco",
|
||||
"artistic.neonGlow",
|
||||
"artistic.paintDaubs",
|
||||
"artistic.paletteKnife",
|
||||
@@ -88,6 +89,7 @@ pub const PIXEL_EFFECTS: [&str; 53] = [
|
||||
"sketch.plaster",
|
||||
"sketch.reticulation",
|
||||
"sketch.stamp",
|
||||
"sketch.tornEdges",
|
||||
"sketch.waterPaper",
|
||||
"stylize.glowingEdges",
|
||||
"texture.craquelure",
|
||||
@@ -117,6 +119,9 @@ pub enum PixelFx {
|
||||
/// Artistic › Film Grain: monochrome grain in shadows and midtones, a wider bright
|
||||
/// highlight area (0..20), and tonal intensity (0..10), preserving coverage.
|
||||
FilmGrain { grain: f64, highlight: f64, intensity: f64 },
|
||||
/// Artistic › Fresco: coarse brush dabs on plaster; `brush_size` (1..10), `brush_detail`
|
||||
/// (0..10) and `texture` (1..3).
|
||||
Fresco { brush_size: f64, brush_detail: f64, texture: f64 },
|
||||
/// Artistic › Smudge Stick: the dark areas smudged along short diagonal strokes `stroke`
|
||||
/// (0..10) long, the light areas (widened by `highlight`, 0..20) smudged longer and lightened
|
||||
/// by up to `intensity` (0..10).
|
||||
@@ -232,6 +237,10 @@ pub enum PixelFx {
|
||||
/// Sketch › Reticulation: black ink on white paper through a high-contrast film-grain screen;
|
||||
/// `density` (0..50), `foreground` and `background` (0..50) pull tones before the grain.
|
||||
Reticulation { density: f64, foreground: f64, background: f64 },
|
||||
/// Sketch › Torn Edges: high-contrast black and white with ragged edges; `image_balance`
|
||||
/// (0..50) shifts ink versus paper, `smoothness` (0..15) softens tones and fraying, `contrast`
|
||||
/// (0..20) hardens the split.
|
||||
TornEdges { image_balance: f64, smoothness: f64, contrast: f64 },
|
||||
/// Sketch › Water Paper: colours flow on damp fibrous paper; `fiber_length` (3..50) sets the
|
||||
/// fibers and daubs, `brightness` and `contrast` (0..100) adjust the wash. Ranges and defaults
|
||||
/// are unverified VectorCraft choices (helpx documents the controls only).
|
||||
@@ -369,6 +378,11 @@ pub(crate) fn parse(id: &str, p: &Value) -> Option<PixelFx> {
|
||||
light: Light::parse(text(p, "lightDirection", "top")),
|
||||
invert: flag(p, "invert", false),
|
||||
},
|
||||
"artistic.fresco" => PixelFx::Fresco {
|
||||
brush_size: num(p, "brushSize", 2.0).clamp(1.0, 10.0),
|
||||
brush_detail: num(p, "brushDetail", 10.0).clamp(0.0, 10.0),
|
||||
texture: num(p, "texture", 1.0).round().clamp(1.0, 3.0),
|
||||
},
|
||||
"artistic.smudgeStick" => PixelFx::SmudgeStick {
|
||||
stroke: num(p, "strokeLength", 2.0).clamp(0.0, 10.0),
|
||||
highlight: num(p, "highlightArea", 12.0).clamp(0.0, 20.0),
|
||||
@@ -510,6 +524,11 @@ pub(crate) fn parse(id: &str, p: &Value) -> Option<PixelFx> {
|
||||
foreground: num(p, "foregroundLevel", 6.0).clamp(0.0, 50.0),
|
||||
background: num(p, "backgroundLevel", 6.0).clamp(0.0, 50.0),
|
||||
},
|
||||
"sketch.tornEdges" => PixelFx::TornEdges {
|
||||
image_balance: num(p, "imageBalance", 25.0).clamp(0.0, 50.0),
|
||||
smoothness: num(p, "smoothness", 11.0).clamp(0.0, 15.0),
|
||||
contrast: num(p, "contrast", 17.0).clamp(0.0, 20.0),
|
||||
},
|
||||
"sketch.waterPaper" => PixelFx::WaterPaper {
|
||||
fiber_length: num(p, "fiberLength", 15.0).clamp(3.0, 50.0),
|
||||
brightness: num(p, "brightness", 50.0).clamp(0.0, 100.0),
|
||||
@@ -601,7 +620,8 @@ impl PixelFx {
|
||||
| PixelFx::HalftonePattern { .. }
|
||||
| PixelFx::NotePaper { .. }
|
||||
| PixelFx::Plaster { .. }
|
||||
| PixelFx::Reticulation { .. } => 0.0,
|
||||
| PixelFx::Reticulation { .. }
|
||||
| PixelFx::TornEdges { .. } => 0.0,
|
||||
PixelFx::BasRelief { .. } | PixelFx::Charcoal { .. } | PixelFx::Photocopy { .. } | PixelFx::Stamp { .. } => 0.0,
|
||||
PixelFx::WaterPaper { fiber_length, .. } => sketch::water_paper_shift(fiber_length),
|
||||
PixelFx::GlowingEdges { width, smoothness, .. } => width.max(smoothness * 3.0),
|
||||
@@ -610,6 +630,7 @@ impl PixelFx {
|
||||
PixelFx::SmudgeStick { .. } | PixelFx::Sponge { .. } | PixelFx::Watercolor { .. } => 0.0,
|
||||
PixelFx::FilmGrain { .. }
|
||||
| PixelFx::ColoredPencil { .. }
|
||||
| PixelFx::Fresco { .. }
|
||||
| PixelFx::Cutout { .. }
|
||||
| PixelFx::DryBrush { .. }
|
||||
| PixelFx::NeonGlow { .. }
|
||||
@@ -676,14 +697,15 @@ impl PixelFx {
|
||||
| PixelFx::HalftonePattern { .. }
|
||||
| PixelFx::NotePaper { .. }
|
||||
| PixelFx::Reticulation { .. } => Some(0.0),
|
||||
PixelFx::Fresco { brush_size, brush_detail, .. } => Some(artistic::fresco_reach(brush_size, brush_detail)),
|
||||
PixelFx::DryBrush { size, detail, .. } => Some(artistic::dry_brush_reach(size, detail)),
|
||||
PixelFx::Plaster { smoothness, .. } => Some(sketch::plaster_reach(smoothness)),
|
||||
PixelFx::PaintDaubs { size, .. } => Some(artistic::paint_daub_radius(size) + size * 0.15),
|
||||
PixelFx::WaterPaper { fiber_length, .. } => {
|
||||
Some(sketch::water_paper_shift(fiber_length) + 3.0 * (0.06 * fiber_length.clamp(3.0, 50.0)).max(0.35))
|
||||
}
|
||||
// Cutout's palette comes from the whole object.
|
||||
PixelFx::Cutout { .. } => None,
|
||||
// Cutout's palette and Torn Edges' peak-normalised edges come from the whole object.
|
||||
PixelFx::Cutout { .. } | PixelFx::TornEdges { .. } => None,
|
||||
// The softened tones around the pixel.
|
||||
PixelFx::NeonGlow { size, .. } => Some(3.0 * artistic::glow_spread(size)),
|
||||
PixelFx::PlasticWrap { smoothness, .. } => Some(artistic::plastic_reach(smoothness)),
|
||||
@@ -714,6 +736,7 @@ impl PixelFx {
|
||||
PixelFx::Cutout { levels, simplicity, fidelity } => artistic::cutout(px, w, h, space, levels, simplicity, fidelity),
|
||||
PixelFx::DryBrush { size, detail, texture } => artistic::dry_brush(px, w, h, space, size, detail, texture),
|
||||
PixelFx::FilmGrain { grain, highlight, intensity } => artistic::film_grain(px, w, h, space, grain, highlight, intensity),
|
||||
PixelFx::Fresco { brush_size, brush_detail, texture } => artistic::fresco(px, w, h, space, brush_size, brush_detail, texture),
|
||||
PixelFx::SmudgeStick { stroke, highlight, intensity } => paint::smudge_stick(px, w, h, space, stroke, highlight, intensity),
|
||||
PixelFx::Sponge { brush, definition, smoothness } => paint::sponge(px, w, h, space, brush, definition, smoothness),
|
||||
PixelFx::Watercolor { detail, shadow, texture } => paint::watercolor(px, w, h, space, detail, shadow, texture),
|
||||
@@ -764,6 +787,7 @@ impl PixelFx {
|
||||
PixelFx::Stamp { balance, smoothness } => sketch_ink::stamp(px, w, h, space, balance, smoothness),
|
||||
PixelFx::Plaster { image_balance, smoothness, light } => sketch::plaster(px, w, h, space, image_balance, smoothness, light),
|
||||
PixelFx::Reticulation { density, foreground, background } => sketch::reticulation(px, w, h, space, density, foreground, background),
|
||||
PixelFx::TornEdges { image_balance, smoothness, contrast } => sketch::torn_edges(px, w, h, space, image_balance, smoothness, contrast),
|
||||
PixelFx::WaterPaper { fiber_length, brightness, contrast } => sketch::water_paper(px, w, h, space, fiber_length, brightness, contrast),
|
||||
PixelFx::GlowingEdges { width, brightness, smoothness } => edges::glow(px, w, h, to_px(width), brightness, to_px(smoothness)),
|
||||
PixelFx::ColorHalftone { max_radius, angles } => pixelate::color_halftone(px, w, h, space, max_radius, angles),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//! Effect › Sketch (Bas Relief, Chalk & Charcoal, Charcoal, Chrome, Halftone Pattern, Note Paper, Photocopy, Plaster,
|
||||
//! Reticulation, Stamp and Water Paper; Graphic Pen lives in
|
||||
//! Reticulation, Stamp, Torn Edges and Water Paper; Graphic Pen lives in
|
||||
//! [`super::brushstrokes`]). Original filters built from public behaviour documentation:
|
||||
//! <https://helpx.adobe.com/illustrator/using/summary-effects.html> (Sketch effects redraw in
|
||||
//! black and white; Water Paper flows colours on damp fibrous paper) and the public Photoshop Elements Artistic filters guide. Visual
|
||||
@@ -17,6 +17,7 @@ use super::{PixelSpace, blur_plane, pick};
|
||||
|
||||
const SALT_CHALK: u64 = 216;
|
||||
const SALT_CHROME: u64 = 0xC40_4D45;
|
||||
const SALT_TORN: u64 = 0x746f726e5f6564;
|
||||
const SALT_WATER: u64 = 208;
|
||||
const EDGE_SOFT: f64 = 0.8;
|
||||
const TONE_SOFT: f64 = 1.0;
|
||||
@@ -361,6 +362,55 @@ pub(super) fn reticulation(px: &mut [[u8; 4]], w: usize, h: usize, space: &Pixel
|
||||
});
|
||||
}
|
||||
|
||||
/// Torn Edges: the object in high-contrast black and white with ragged edges. `image_balance`
|
||||
/// (0..50) shifts whether midtones fall to ink or paper; `smoothness` (0..15) softens tones and
|
||||
/// the fraying; `contrast` (0..20) hardens the split. Coverage is kept.
|
||||
pub(super) fn torn_edges(px: &mut [[u8; 4]], w: usize, h: usize, space: &PixelSpace, image_balance: f64, smoothness: f64, contrast: f64) {
|
||||
if !(image_balance.is_finite() && smoothness.is_finite() && contrast.is_finite()) {
|
||||
return;
|
||||
}
|
||||
let Some(place) = Place::new(space, w, h) else { return };
|
||||
if w == 0 || h == 0 || w.checked_mul(h) != Some(px.len()) {
|
||||
return;
|
||||
}
|
||||
let mut tone: Vec<f32> = px.iter().map(|p| luma(straight(*p)) * f32::from(p[3]) / 255.0).collect();
|
||||
let cover: Vec<f32> = px.iter().map(|p| f32::from(p[3]) / 255.0).collect();
|
||||
let sigma = (0.12 * smoothness.clamp(0.0, 15.0)) / place.px.max(1e-9);
|
||||
if sigma > 0.0 {
|
||||
blur_plane(&mut tone, w, h, sigma);
|
||||
}
|
||||
let mut edges: Vec<f32> = sobel(&tone, w, h).into_iter().zip(sobel(&cover, w, h)).map(|(t, c)| t.max(c)).collect();
|
||||
let edge_soft = (0.08 * smoothness.clamp(0.0, 15.0)) / place.px.max(1e-9);
|
||||
if edge_soft > 0.0 {
|
||||
blur_plane(&mut edges, w, h, edge_soft);
|
||||
}
|
||||
let peak = edges.iter().copied().fold(0.0f32, f32::max);
|
||||
let balance = image_balance.clamp(0.0, 50.0);
|
||||
// Lower balance favours ink (darker result); higher balance favours paper.
|
||||
let balance_tone = 0.25 + balance / 50.0 * 0.75;
|
||||
let steep = 4.0 + contrast.clamp(0.0, 20.0) * 0.45;
|
||||
let hard = contrast.clamp(0.0, 20.0) >= 18.0;
|
||||
let fray = 0.25 + 0.05 * smoothness.clamp(0.0, 15.0);
|
||||
place.each(px, |x, y, p| {
|
||||
let a = f32::from(p[3]) / 255.0;
|
||||
if a <= 0.0 {
|
||||
*p = [0; 4];
|
||||
return;
|
||||
}
|
||||
let i = y * w + x;
|
||||
let t = tone.get(i).copied().unwrap_or(0.0);
|
||||
let e = if peak > 1e-6 { edges.get(i).copied().unwrap_or(0.0) / peak } else { 0.0 };
|
||||
let noise = smooth_noise(SALT_TORN, place.at(x, y), 2.5 + 0.3 * smoothness) as f32;
|
||||
let local = (1.0 - balance_tone) as f32 + e * fray as f32 * noise;
|
||||
let mut ink = 1.0 / (1.0 + (steep as f32 * (t - local)).exp());
|
||||
if hard {
|
||||
ink = if ink > 0.5 { 1.0 } else { 0.0 };
|
||||
}
|
||||
let paper = 1.0 - ink.clamp(0.0, 1.0);
|
||||
*p = premultiply([paper, paper, paper], a);
|
||||
});
|
||||
}
|
||||
|
||||
/// How far Water Paper's blotchy displacement can shift content (document units).
|
||||
pub(super) fn water_paper_shift(fiber_length: f64) -> f64 {
|
||||
0.12 * fiber_length.clamp(3.0, 50.0)
|
||||
|
||||
@@ -2071,6 +2071,13 @@ fn halftone(p: serde_json::Value, src: &[u8], w: usize, h: usize, s: &PixelSpace
|
||||
out
|
||||
}
|
||||
|
||||
/// Torn Edges of `p` over `w` × `h` pixels of `src`, laid out by `s`.
|
||||
fn torn(p: serde_json::Value, src: &[u8], w: usize, h: usize, s: &PixelSpace) -> Vec<u8> {
|
||||
let mut out = src.to_vec();
|
||||
fx("sketch.tornEdges", p).apply(&mut out, w, h, s);
|
||||
out
|
||||
}
|
||||
|
||||
/// Water Paper of `p` over `w` × `h` pixels of `src`, laid out by `s`.
|
||||
fn water_paper(p: serde_json::Value, src: &[u8], w: usize, h: usize, s: &PixelSpace) -> Vec<u8> {
|
||||
let mut out = src.to_vec();
|
||||
@@ -2404,6 +2411,63 @@ fn reticulation_density_changes_the_grain() {
|
||||
assert_ne!(low, high);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn torn_edges_params_take_defaults_and_stay_in_range() {
|
||||
assert_eq!(fx("sketch.tornEdges", json!({})), PixelFx::TornEdges { image_balance: 25.0, smoothness: 11.0, contrast: 17.0 });
|
||||
assert_eq!(
|
||||
fx("sketch.tornEdges", json!({"imageBalance": 0, "smoothness": 99, "contrast": -1})),
|
||||
PixelFx::TornEdges { image_balance: 0.0, smoothness: 15.0, contrast: 0.0 }
|
||||
);
|
||||
assert_eq!(
|
||||
fx("sketch.tornEdges", json!({"imageBalance": 1e9, "smoothness": -3, "contrast": 1e9})),
|
||||
PixelFx::TornEdges { image_balance: 50.0, smoothness: 0.0, contrast: 20.0 }
|
||||
);
|
||||
for junk in [json!({"imageBalance": "x"}), json!({"smoothness": null})] {
|
||||
assert_eq!(fx("sketch.tornEdges", junk), fx("sketch.tornEdges", json!({})));
|
||||
}
|
||||
assert_eq!(fx("sketch.tornEdges", json!({})).reach(), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn torn_edges_draws_in_black_and_white_and_keeps_coverage() {
|
||||
let (w, h) = (64, 48);
|
||||
let src = ramp(w, h);
|
||||
let out = torn(json!({"imageBalance": 12, "contrast": 20, "smoothness": 5}), &src, w, h, &space(w, h));
|
||||
for (p, q) in out.as_chunks::<4>().0.iter().zip(src.as_chunks::<4>().0) {
|
||||
assert_eq!(p[3], q[3], "coverage kept");
|
||||
assert!(p[0] == p[1] && p[1] == p[2] && (p[0] == 0 || p[0] == p[3]), "black or white: {p:?}");
|
||||
}
|
||||
assert!(share(&out, |p| p[0] == 0) > 0.05 && share(&out, |p| p[0] == p[3]) > 0.05, "ink and paper");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn torn_edges_image_balance_shifts_ink_on_a_grey_ramp() {
|
||||
let (w, h) = (80, 16);
|
||||
let src = image(w, h, |x, _| grey((x * 255 / (w - 1)) as u8));
|
||||
let params = json!({"imageBalance": 25, "contrast": 20, "smoothness": 5});
|
||||
let out = torn(params, &src, w, h, &space(w, h));
|
||||
let mut dark_ink = 0usize;
|
||||
let mut bright_ink = 0usize;
|
||||
for y in 0..h {
|
||||
for x in 0..w / 4 {
|
||||
if at(&out, w, x, y)[0] == 0 {
|
||||
dark_ink += 1;
|
||||
}
|
||||
}
|
||||
for x in 3 * w / 4..w {
|
||||
if at(&out, w, x, y)[0] == 0 {
|
||||
bright_ink += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
let dark_n = (w / 4) * h;
|
||||
let bright_n = (w - 3 * w / 4) * h;
|
||||
assert!(dark_ink as f64 / dark_n as f64 > bright_ink as f64 / bright_n as f64 + 0.2, "dark end of ramp is inkier than bright end");
|
||||
let dark = share(&torn(json!({"imageBalance": 0, "contrast": 20, "smoothness": 5}), &src, w, h, &space(w, h)), |p| p[0] == 0);
|
||||
let light = share(&torn(json!({"imageBalance": 50, "contrast": 20, "smoothness": 5}), &src, w, h, &space(w, h)), |p| p[0] == 0);
|
||||
assert!(dark > light + 0.15, "low balance leaves more ink: dark={dark} light={light}");
|
||||
}
|
||||
|
||||
/// The distinct colours of the covered pixels.
|
||||
fn colours(d: &[u8]) -> std::collections::BTreeSet<[u8; 4]> {
|
||||
d.as_chunks::<4>().0.iter().filter(|p| p[3] > 0).copied().collect()
|
||||
@@ -2485,6 +2549,11 @@ fn artistic_params_take_defaults_and_stay_in_range() {
|
||||
),
|
||||
PixelFx::RoughPastels { length: 0.0, detail: 20.0, texture: Texture::Canvas, scaling: 0.5, relief: 50.0, light: Light::Top, invert: true }
|
||||
);
|
||||
assert_eq!(fx("artistic.fresco", json!({})), PixelFx::Fresco { brush_size: 2.0, brush_detail: 10.0, texture: 1.0 });
|
||||
assert_eq!(
|
||||
fx("artistic.fresco", json!({"brushSize": 0, "brushDetail": 99, "texture": 4.7})),
|
||||
PixelFx::Fresco { brush_size: 1.0, brush_detail: 10.0, texture: 3.0 }
|
||||
);
|
||||
assert_eq!(fx("artistic.plasticWrap", json!({})), PixelFx::PlasticWrap { highlight: 20.0, detail: 12.0, smoothness: 15.0 });
|
||||
assert_eq!(
|
||||
fx("artistic.plasticWrap", json!({"highlightStrength": -1, "detail": 99, "smoothness": 0})),
|
||||
@@ -2494,6 +2563,7 @@ fn artistic_params_take_defaults_and_stay_in_range() {
|
||||
"artistic.coloredPencil",
|
||||
"artistic.cutout",
|
||||
"artistic.dryBrush",
|
||||
"artistic.fresco",
|
||||
"artistic.neonGlow",
|
||||
"artistic.plasticWrap",
|
||||
"artistic.posterEdges",
|
||||
@@ -2548,6 +2618,7 @@ fn artistic_filters_leave_invalid_coordinate_spaces_alone() {
|
||||
let filters = [
|
||||
PixelFx::Cutout { levels: 4.0, simplicity: 4.0, fidelity: 2.0 },
|
||||
PixelFx::DryBrush { size: 2.0, detail: 10.0, texture: 1.0 },
|
||||
PixelFx::Fresco { brush_size: 2.0, brush_detail: 10.0, texture: 1.0 },
|
||||
PixelFx::NeonGlow { size: 5.0, brightness: 15.0, colour },
|
||||
PixelFx::PlasticWrap { highlight: 20.0, detail: 12.0, smoothness: 15.0 },
|
||||
PixelFx::PosterEdges { thickness: 2.0, intensity: 1.0, posterization: 2.0 },
|
||||
@@ -2600,6 +2671,9 @@ fn artistic_filters_leave_invalid_coordinate_spaces_alone() {
|
||||
light: Light::Top,
|
||||
invert: false,
|
||||
},
|
||||
PixelFx::Fresco { brush_size: f64::NAN, brush_detail: 10.0, texture: 1.0 },
|
||||
PixelFx::Fresco { brush_size: 2.0, brush_detail: f64::INFINITY, texture: 1.0 },
|
||||
PixelFx::Fresco { brush_size: 2.0, brush_detail: 10.0, texture: f64::NEG_INFINITY },
|
||||
] {
|
||||
if run(&f, &space(w, h)) != src {
|
||||
changed.push(format!("{f:?}"));
|
||||
@@ -2629,6 +2703,22 @@ fn underpainting_softens_more_with_a_larger_brush_and_keeps_coverage() {
|
||||
assert!(out.as_chunks::<4>().0.iter().zip(src.as_chunks::<4>().0).all(|(o, s)| o[3] == s[3]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fresco_keeps_coverage_and_responds_to_texture() {
|
||||
let (w, h) = (48, 32);
|
||||
let src = ramp(w, h);
|
||||
let mut low = src.clone();
|
||||
let mut high = src.clone();
|
||||
fx("artistic.fresco", json!({"texture": 1})).apply(&mut low, w, h, &space(w, h));
|
||||
fx("artistic.fresco", json!({"texture": 3})).apply(&mut high, w, h, &space(w, h));
|
||||
assert_ne!(low, src);
|
||||
assert_ne!(high, src);
|
||||
assert_ne!(low, high, "deeper texture changes the relief");
|
||||
for (a, b) in low.as_chunks::<4>().0.iter().zip(src.as_chunks::<4>().0) {
|
||||
assert_eq!(a[3], b[3], "alpha is preserved");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn plastic_wrap_adds_specular_highlights_and_keeps_coverage() {
|
||||
let (w, h) = (48, 32);
|
||||
|
||||
@@ -143,6 +143,13 @@ pub fn validate_solid(n: &Node, id: &str, p: &Value) -> Result<(), String> {
|
||||
facets(id, &path, rule, b, p).map(|_| ())
|
||||
}
|
||||
|
||||
/// Can 3D effect `id` (Revolve included, [`is_three_d`]) with parameters `p` draw `n`? Checked
|
||||
/// before a command changes the document: Revolve by [`crate::validate_revolve`], the others by
|
||||
/// [`validate_solid`].
|
||||
pub fn validate_three_d(n: &Node, id: &str, p: &Value) -> Result<(), String> {
|
||||
if id == crate::REVOLVE { crate::validate_revolve(n, p) } else { validate_solid(n, id, p) }
|
||||
}
|
||||
|
||||
/// One surface: each facet a path shaded from `paint`, as a group with the paint's opacity and
|
||||
/// blend mode (so overlapping facets don't add up their transparency).
|
||||
fn surface(n: &Node, facets: Vec<Facet>, paint: &Paint, opacity: f32, blend: BlendMode, colored: bool) -> Node {
|
||||
|
||||
@@ -441,6 +441,7 @@ fn import_text(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
return Err(bad(C, "the text is empty"));
|
||||
}
|
||||
let mut t = TextObject::point(Point::ZERO, text, super::super::create::new_type_style(s, &Value::Null));
|
||||
t.system_layout = s.doc()?.doc.setup.system_layout;
|
||||
crate::cmd::typecmd::refresh_bounds(&mut t);
|
||||
let n = Node::new(NodeId(1), NodeKind::Text(Box::new(t)));
|
||||
let count = s.load_clipboard(Clipboard { nodes: vec![n], ..Default::default() }, p)?;
|
||||
|
||||
@@ -506,6 +506,7 @@ fn text_create(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
t.kind = vectorcraft_doc::TextKind::Area { frame: shapes::rectangle(Rect::new(0.0, 0.0, w, h)) };
|
||||
t.area.fit = new_area_fit(s, a, "text.create")?;
|
||||
}
|
||||
t.system_layout = s.doc()?.doc.setup.system_layout;
|
||||
if bool_or(p, "placeholder", false) {
|
||||
super::typemenu::fill_with_placeholder(&mut t);
|
||||
} else {
|
||||
|
||||
@@ -353,6 +353,7 @@ fn artwork(doc: &mut Document, d: &Dimension, old: &[NodeId]) -> Result<Vec<Arc<
|
||||
};
|
||||
let mut text = TextObject::point(Point::ZERO, &label, style);
|
||||
text.para.justify = vectorcraft_doc::Justify::Center;
|
||||
text.system_layout = doc.setup.system_layout;
|
||||
super::typecmd::refresh_bounds(&mut text);
|
||||
// Centre the label's box on its anchor point, along the line.
|
||||
let bounds = text.cached_bounds.unwrap_or_else(|| text.estimate_bounds());
|
||||
|
||||
@@ -139,8 +139,11 @@ fn check_revolve_count(n: &Node, cmd: &str) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
const ONE_3D: &str = "An object takes one 3D effect. Edit the existing effect's options, or remove it first.";
|
||||
pub(crate) const ONE_3D: &str = "An object takes one 3D effect. Edit the existing effect's options, or remove it first.";
|
||||
|
||||
/// `effect.apply`: adds effect `effect` (or `id`) with `params`, its defaults filled in, to the
|
||||
/// targets' active item as one undo step. A 3D effect must fit each target, which takes only one;
|
||||
/// a Pathfinder effect on loose objects groups them first. → `{ids, index, item}`.
|
||||
pub(crate) fn apply(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
const C: &str = "effect.apply";
|
||||
let id = str_param(p, "effect").or_else(|| str_param(p, "id")).ok_or_else(|| bad(C, "missing `effect` id"))?;
|
||||
@@ -172,13 +175,9 @@ pub(crate) fn apply(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
if effects::is_three_d(id) {
|
||||
for target in appearance_targets(s, p)? {
|
||||
let n = s.doc()?.doc.node(target).ok_or(EngineError::NoNode(target))?;
|
||||
if id == effects::REVOLVE {
|
||||
effects::validate_revolve(n, &effect.params).map_err(|e| bad(C, e))?;
|
||||
if effects::has_revolve(n) {
|
||||
return Err(bad(C, "A profile supports one Revolve effect. Edit the existing effect's options instead."));
|
||||
}
|
||||
} else {
|
||||
effects::validate_solid(n, id, &effect.params).map_err(|e| bad(C, e))?;
|
||||
effects::validate_three_d(n, id, &effect.params).map_err(|e| bad(C, e))?;
|
||||
if id == effects::REVOLVE && effects::has_revolve(n) {
|
||||
return Err(bad(C, "A profile supports one Revolve effect. Edit the existing effect's options instead."));
|
||||
}
|
||||
if effects::has_revolve(n) || effects::has_solid(n) {
|
||||
return Err(bad(C, ONE_3D));
|
||||
@@ -333,6 +332,9 @@ fn lighting_preset(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
set_params(s, &options)
|
||||
}
|
||||
|
||||
/// `effect.setParams`: merges `params` into the effect at `index` of the targets' active item, and
|
||||
/// sets its Warp style (`warpStyle`) or visibility (`visible`), as one undo step. They are checked
|
||||
/// as `effect.apply` checks them, and a visible 3D effect must still fit. → `{ids}`.
|
||||
fn set_params(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
const C: &str = "effect.setParams";
|
||||
let index = index_param(p, "index", C)?;
|
||||
@@ -372,11 +374,7 @@ fn set_params(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
if let (Some(cur), Value::Object(new)) = (prospective.as_object_mut(), effects::upgrade_params(&e.id, ¶ms)) {
|
||||
cur.extend(new);
|
||||
}
|
||||
if e.id == effects::REVOLVE {
|
||||
effects::validate_revolve(n, &prospective).map_err(|e| bad(C, e))?;
|
||||
} else {
|
||||
effects::validate_solid(n, &e.id, &prospective).map_err(|e| bad(C, e))?;
|
||||
}
|
||||
effects::validate_three_d(n, &e.id, &prospective).map_err(|e| bad(C, e))?;
|
||||
}
|
||||
}
|
||||
let ids = edit_effects(s, p, item, C, "Effect Options", &format!("{C}: no effect at index {index}"), |fx| {
|
||||
@@ -410,7 +408,9 @@ const GLASS: &str = "distort.glass";
|
||||
/// Effect › Texture › Texturizer.
|
||||
const TEXTURIZER: &str = "texture.texturizer";
|
||||
|
||||
fn texture_load_effect(id: &str) -> bool {
|
||||
/// Does effect `id` have Load Texture: a `textureImage` that `effect.apply` reads from an image
|
||||
/// file (Glass, Texturizer)?
|
||||
pub(crate) fn texture_load_effect(id: &str) -> bool {
|
||||
id == GLASS || id == TEXTURIZER
|
||||
}
|
||||
|
||||
|
||||
@@ -94,6 +94,12 @@ pub const UNSUPPORTED: &[Unsupported] = &[
|
||||
extensions: &["pict", "pct", "pic"],
|
||||
hint: "PICT is a retired format and is not supported: convert the file to PDF or PNG first",
|
||||
},
|
||||
Unsupported {
|
||||
id: "pmd",
|
||||
label: "PageMaker",
|
||||
extensions: &["pmd"],
|
||||
hint: "PageMaker (.pmd) is not supported: open the layout in PageMaker and export PDF or EPS, or place a PDF export here",
|
||||
},
|
||||
];
|
||||
|
||||
/// The unsupported format an id or extension (any case, leading dot allowed) names.
|
||||
|
||||
@@ -169,7 +169,7 @@ fn formats_list_dxf_and_what_can_not_be_written() {
|
||||
}
|
||||
assert!(r["writable"].as_array().unwrap().contains(&json!("dxf")));
|
||||
let unsupported: Vec<&str> = r["unsupported"].as_array().unwrap().iter().map(|u| u["id"].as_str().unwrap()).collect();
|
||||
assert_eq!(unsupported, ["dwg", "pict"]);
|
||||
assert_eq!(unsupported, ["dwg", "pict", "pmd"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -191,4 +191,9 @@ fn dwg_and_pict_say_what_to_use_instead() {
|
||||
.unwrap_err()
|
||||
.to_string();
|
||||
assert!(e.contains("DWG is not available"), "{e}");
|
||||
let e = s
|
||||
.execute("document.open", &json!({"name": "brochure.PMD", "dataBase64": vectorcraft_format::base64_encode(b"PageMaker")}))
|
||||
.unwrap_err()
|
||||
.to_string();
|
||||
assert!(e.contains("brochure.PMD") && e.contains("PageMaker"), "{e}");
|
||||
}
|
||||
@@ -373,6 +373,7 @@ impl Gen<'_> {
|
||||
let style = label_style(self.styles, role);
|
||||
let mut t = TextObject::point(at, s, style);
|
||||
t.para.justify = justify;
|
||||
t.system_layout = self.d.setup.system_layout;
|
||||
refresh_bounds(&mut t);
|
||||
Arc::new(Node::new(self.d.alloc_id(), NodeKind::Text(Box::new(t))))
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Character / Paragraph",
|
||||
[],
|
||||
None,
|
||||
"{ids?|id?, kerning?: 1/1000 em|\"auto\", baselineShift?: pt, hScale?: %, vScale?: %, rotation?: deg, underline?, strikethrough?, allCaps?, smallCaps?: bool, position?: \"normal\"|\"superscript\"|\"subscript\" (sizes from Document Setup), leftIndent?, rightIndent?, firstLineIndent?, spaceBefore?, spaceAfter?: pt (±1296), hyphenate?: bool, wordsLongerThan?: letters 1..25 (5), afterFirst?, beforeLast?: letters 1..15 (3), hyphenLimit?: lines 0..25 (0: no limit), hyphenationZone?: pt 0..1296 (0; Single-line Composer only), hyphenateCapitalized?: bool (true) (Paragraph panel menu › Hyphenation…: only words longer than wordsLongerThan break, keeping afterFirst letters before the hyphen and beforeLast after it; at most hyphenLimit lines in a row end with a hyphen; a line whose text already ends within hyphenationZone of its right edge breaks before the next word instead of hyphenating it; the counts are rounded, and every value is clamped to its range), wordSpacing?: % 0..1000 (80, 100, 133), letterSpacing?: % of a word space -100..500 (0, 0, 0), glyphScaling?: % 50..200 (100, 100, 100): each [min, desired, max] or {min?, desired?, max?} (Paragraph panel menu › Justification…: Desired applies to every line, Minimum and Maximum bound what justified lines may use; values are clamped to their range, and Minimum ≤ Desired ≤ Maximum must hold afterwards or nothing changes), autoLeading?: % of the size 0..500 (120; the leading of characters whose leading is Auto), singleWordJustification?: \"fullJustify\"|\"alignLeft\"|\"alignCenter\"|\"alignRight\" (a justified line holding one word), mojikumi?: \"none\"|\"lineEndHalf\" (Japanese punctuation spacing), kinsoku?: \"none\"|\"hard\"|\"soft\" (Kinsoku Set: Soft lets 々, ー and small kana start a line), direction?: \"auto\"|\"leftToRight\"|\"rightToLeft\" (paragraph direction; auto: from each paragraph's first strong character), leadingModel?: \"romanBaseline\"|\"emBoxTop\" (leading measured baseline to baseline, or em box top to top), charAlign?: \"romanBaseline\"|\"emBoxTop\"|\"emBoxCenter\"|\"emBoxBottom\"|\"icfTop\"|\"icfBottom\" (where characters smaller than the largest on their line line up with it), proportionalMetrics?: bool (full-width glyphs on the font's proportional widths: `palt` in horizontal type, `vpal` in vertical type), noBreak?: bool (Character panel menu › No Break: these characters stay on one line, including across a space inside the run), digits?: \"default\"|\"arabic\"|\"hindi\"|\"farsi\" (Character panel menu › Digits: the numeral system every digit is drawn in, whatever was typed), fontAxes?: {\"wght\": 650, …} (Character panel › Variable Font, as text.setRangeStyle: each axis named set in its units and clamped to its range, null back to the style's own setting), burasagari?: \"none\"|\"standard\"|\"forced\" (Paragraph panel menu › Burasagari None/Regular/Force: an East Asian comma or full stop ending an area type line hangs outside it: when it doesn't fit, or always; new type: \"standard\"), romanHangingPunctuation?: bool (Paragraph panel menu › Roman Hanging Punctuation: quotation marks, hyphens, full stops and commas starting or ending a line hang outside the margin, asterisks, tildes, ellipses, dashes, colons and semicolons by half; off by default), kashida?: \"none\"|\"short\"|\"medium\"|\"long\"|\"stylistic\" (Paragraph panel › Insert Kashidas: justified lines of horizontal area type lengthen each Arabic word with a kashida between its last pair of joined letters, at most a quarter, half or whole em long, or whole tatweels up to an em for stylistic, before they widen their word spaces; none by default), composer?: \"singleLine\"|\"everyLine\" (line breaking, Every-line by default), start?: byte, end?: byte} (baselineShift is in document points and hScale includes the object transform; groups include their text descendants; with a range: the character attributes style that range and the paragraph attributes apply to the paragraphs it touches; without: all the text)",
|
||||
"{ids?|id?, kerning?: 1/1000 em|\"auto\", baselineShift?: pt, hScale?: %, vScale?: %, rotation?: deg, underline?, strikethrough?, allCaps?, smallCaps?: bool, position?: \"normal\"|\"superscript\"|\"subscript\" (sizes from Document Setup), leftIndent?, rightIndent?, firstLineIndent?, spaceBefore?, spaceAfter?: pt (±1296), hyphenate?: bool, wordsLongerThan?: letters 1..25 (5), afterFirst?, beforeLast?: letters 1..15 (3), hyphenLimit?: lines 0..25 (0: no limit), hyphenationZone?: pt 0..1296 (0; Single-line Composer only), hyphenateCapitalized?: bool (true) (Paragraph panel menu › Hyphenation…: only words longer than wordsLongerThan break, keeping afterFirst letters before the hyphen and beforeLast after it; at most hyphenLimit lines in a row end with a hyphen; a line whose text already ends within hyphenationZone of its right edge breaks before the next word instead of hyphenating it; the counts are rounded, and every value is clamped to its range), wordSpacing?: % 0..1000 (80, 100, 133), letterSpacing?: % of a word space -100..500 (0, 0, 0), glyphScaling?: % 50..200 (100, 100, 100): each [min, desired, max] or {min?, desired?, max?} (Paragraph panel menu › Justification…: Desired applies to every line, Minimum and Maximum bound what justified lines may use; values are clamped to their range, and Minimum ≤ Desired ≤ Maximum must hold afterwards or nothing changes), autoLeading?: % of the size 0..500 (120; the leading of characters whose leading is Auto), singleWordJustification?: \"fullJustify\"|\"alignLeft\"|\"alignCenter\"|\"alignRight\" (a justified line holding one word), mojikumi?: \"none\"|\"lineEndHalf\" (Japanese punctuation spacing), kinsoku?: \"none\"|\"hard\"|\"soft\" (Kinsoku Set: Soft lets 々, ー and small kana start a line), direction?: \"auto\"|\"leftToRight\"|\"rightToLeft\" (paragraph direction; auto: from each paragraph's first strong character), leadingModel?: \"romanBaseline\"|\"emBoxTop\" (leading measured baseline to baseline, or em box top to top), charAlign?: \"romanBaseline\"|\"emBoxTop\"|\"emBoxCenter\"|\"emBoxBottom\"|\"icfTop\"|\"icfBottom\" (where characters smaller than the largest on their line line up with it), proportionalMetrics?: bool (full-width glyphs on the font's proportional widths: `palt` in horizontal type, `vpal` in vertical type), tateChuYoko?: bool (Character panel menu › Tate-chu-yoko, with Show East Asian Options: in vertical type those characters stand side by side across one em of the column; kept on the characters and ignored in horizontal type), noBreak?: bool (Character panel menu › No Break: these characters stay on one line, including across a space inside the run), digits?: \"default\"|\"arabic\"|\"hindi\"|\"farsi\" (Character panel menu › Digits: the numeral system every digit is drawn in, whatever was typed), fontAxes?: {\"wght\": 650, …} (Character panel › Variable Font, as text.setRangeStyle: each axis named set in its units and clamped to its range, null back to the style's own setting), burasagari?: \"none\"|\"standard\"|\"forced\" (Paragraph panel menu › Burasagari None/Regular/Force: an East Asian comma or full stop ending an area type line hangs outside it: when it doesn't fit, or always; new type: \"standard\"), romanHangingPunctuation?: bool (Paragraph panel menu › Roman Hanging Punctuation: quotation marks, hyphens, full stops and commas starting or ending a line hang outside the margin, asterisks, tildes, ellipses, dashes, colons and semicolons by half; off by default), kashida?: \"none\"|\"short\"|\"medium\"|\"long\"|\"stylistic\" (Paragraph panel › Insert Kashidas: justified lines of horizontal area type lengthen each Arabic word with a kashida between its last pair of joined letters, at most a quarter, half or whole em long, or whole tatweels up to an em for stylistic, before they widen their word spaces; none by default), composer?: \"singleLine\"|\"everyLine\" (line breaking, Every-line by default), start?: byte, end?: byte} (baselineShift is in document points and hScale includes the object transform; groups include their text descendants; with a range: the character attributes style that range and the paragraph attributes apply to the paragraphs it touches; without: all the text)",
|
||||
has_doc,
|
||||
set_format
|
||||
),
|
||||
@@ -328,6 +328,7 @@ fn set_format(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
"leadingModel",
|
||||
"charAlign",
|
||||
"proportionalMetrics",
|
||||
"tateChuYoko",
|
||||
"noBreak",
|
||||
"digits",
|
||||
"fontAxes",
|
||||
@@ -465,6 +466,9 @@ fn set_format(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
if let Some(v) = flag("proportionalMetrics") {
|
||||
st.proportional_metrics = v;
|
||||
}
|
||||
if let Some(v) = flag("tateChuYoko") {
|
||||
st.tate_chu_yoko = v;
|
||||
}
|
||||
if let Some(v) = flag("noBreak") {
|
||||
st.no_break = v;
|
||||
}
|
||||
|
||||
@@ -382,6 +382,7 @@ fn pf_label(op: PathfinderOp) -> &'static str {
|
||||
PathfinderOp::Outline => "Outline",
|
||||
PathfinderOp::MinusBack => "Minus Back",
|
||||
PathfinderOp::HardMix => "Hard Mix",
|
||||
PathfinderOp::SoftMix => "Soft Mix",
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -228,6 +228,7 @@ pub(super) fn area_text(story: Story, frame: Rect, setup: &vectorcraft_doc::DocS
|
||||
t.set_paragraph_styles(story.paras);
|
||||
}
|
||||
t.kind = vectorcraft_doc::TextKind::Area { frame: shapes::rectangle(Rect::from_origin_size(Point::ORIGIN, frame.size())) };
|
||||
t.system_layout = setup.system_layout;
|
||||
crate::cmd::typecmd::refresh_bounds(&mut t);
|
||||
t
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use serde_json::{Map, Value, json};
|
||||
use vectorcraft_doc::{Effect, Node};
|
||||
use vectorcraft_plugins::{Kind, Plugin, effect, export, objects, registry};
|
||||
|
||||
use super::*;
|
||||
@@ -58,6 +59,10 @@ fn plugin_by_id(cmd: &str, p: &Value) -> Result<Arc<Plugin>> {
|
||||
registry::get(id).ok_or_else(|| err(vectorcraft_plugins::Error::NotFound(id.into())))
|
||||
}
|
||||
|
||||
/// `plugin.run`: runs filter `id` on `ids` (else the selected paths and compound paths) with its
|
||||
/// parameters and `_context`, and applies its output as one undo step ([`objects::apply_output`];
|
||||
/// effect records as [`admit_effects`] admits them). → `{plugin, ids}`: what it made or changed,
|
||||
/// which is then selected.
|
||||
fn run(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
const C: &str = "plugin.run";
|
||||
let plugin = plugin_by_id(C, p)?;
|
||||
@@ -85,13 +90,57 @@ fn run(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let params = serde_json::to_vec(¶ms).map_err(|e| bad(C, e.to_string()))?;
|
||||
let out = objects::decode(&plugin.run(&input, ¶ms).map_err(err)?).map_err(err)?;
|
||||
let ids = s.edit(m.name.trim_end_matches('…'), |d, sel| {
|
||||
let ids = objects::apply_output(d, &inputs, out, parent).map_err(err)?;
|
||||
let ids = objects::apply_output(d, &inputs, out, parent, &admit_effects).map_err(err)?;
|
||||
sel.set(ids.iter().copied());
|
||||
Ok(ids)
|
||||
})?;
|
||||
Ok(json!({"plugin": m.id, "ids": ids.iter().map(|i| i.0).collect::<Vec<_>>()}))
|
||||
}
|
||||
|
||||
/// Admits the effect records a filter returned for object `n` (written, its effects still its own)
|
||||
/// as `effect.apply` would apply them: each new record a known effect (one of ours, or an installed
|
||||
/// live-effect plug-in) with parameters it takes, filled in to their defaults. A record the object
|
||||
/// already had stays as it was. An object takes one 3D effect (its fills' and strokes' own
|
||||
/// counted), which must fit it, and the `textureImage` of an effect with Load Texture (Glass,
|
||||
/// Texturizer) comes as the effect stores it, never as a file to read: a plug-in can't have the
|
||||
/// host read one.
|
||||
fn admit_effects(fx: &[Effect], n: &Node) -> std::result::Result<Vec<Effect>, String> {
|
||||
use vectorcraft_render::effects;
|
||||
const C: &str = "plugin.run";
|
||||
let mut out = Vec::with_capacity(fx.len());
|
||||
for (j, e) in fx.iter().enumerate() {
|
||||
if n.appearance.effects.contains(e) {
|
||||
out.push(e.clone());
|
||||
continue;
|
||||
}
|
||||
let refuse = |why: String| format!("[{j}] `{}`: {why}", e.id);
|
||||
let params = if e.params.is_null() { json!({}) } else { e.params.clone() };
|
||||
match effect::installed(&e.id) {
|
||||
Some(plugin) => {
|
||||
plugin.manifest().resolve_params(¶ms).map_err(|why| refuse(why.to_string()))?;
|
||||
}
|
||||
None => super::params::check_effect_params(C, &e.id, ¶ms).map_err(|why| refuse(why.to_string()))?,
|
||||
}
|
||||
if super::effectcmd::texture_load_effect(&e.id)
|
||||
&& let Some(t) = params.get(effects::pixel::TEXTURE_IMAGE)
|
||||
&& !t.as_str().is_some_and(|t| effects::pixel::texture(t).is_some())
|
||||
{
|
||||
return Err(refuse("`textureImage` must be a texture as effect.list gives it".into()));
|
||||
}
|
||||
let mut admitted = effects::new_effect(&e.id, ¶ms).ok_or_else(|| refuse("no such effect".into()))?;
|
||||
if effects::is_three_d(&e.id) {
|
||||
effects::validate_three_d(n, &e.id, &admitted.params).map_err(refuse)?;
|
||||
}
|
||||
admitted.visible = e.visible;
|
||||
out.push(admitted);
|
||||
}
|
||||
let items = n.appearance.items.iter().flat_map(|i| i.effects());
|
||||
if out.iter().chain(items).filter(|e| effects::is_three_d(&e.id)).count() > 1 {
|
||||
return Err(super::effectcmd::ONE_3D.into());
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// Largest base64 payload `plugin.install` accepts (the module limit, encoded).
|
||||
const MAX_DATA_CHARS: usize = (32 << 20) / 3 * 4 + 4;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Character",
|
||||
[],
|
||||
None,
|
||||
"{id? (default: the one selected type object), start?: byte, end?: byte (default: all text), font?, style?, size?: pt, leading?: pt|\"auto\", tracking?, kerning?: 1/1000 em|\"auto\", baselineShift?: pt, hScale?: %, vScale?: %, rotation?: deg, fill?: colour|\"none\", stroke?: colour|\"none\", keepModel?: bool (fill and stroke, as paint.setFill), strokeWidth?: pt, strokeOptions?: {weight?, cap?, join?, miterLimit?, align?, dash?, dashOffset?, alignDashes?} (as stroke.set: the character stroke), underline?, strikethrough?, allCaps?: bool, smallCaps?: bool, position?: \"normal\"|\"superscript\"|\"subscript\" (sizes from Document Setup), features?: [\"dlig\", \"-liga\", …], charAlign?: \"romanBaseline\"|\"emBoxTop\"|\"emBoxCenter\"|\"emBoxBottom\"|\"icfTop\"|\"icfBottom\", proportionalMetrics?: bool (full-width glyphs on the font's proportional widths: `palt` in horizontal type, `vpal` in vertical type), noBreak?: bool (Character panel menu › No Break: these characters stay on one line, including across a space inside the run), digits?: \"default\"|\"arabic\"|\"hindi\"|\"farsi\" (Character panel menu › Digits: the numeral system every digit is drawn in, whatever was typed), fontAxes?: {\"wght\": 650, …} (Character panel › Variable Font: the setting of each variation axis named, in the axis's units and clamped to its range; null: back to the style's own setting; other axes keep theirs; tags the font has no axis for are left out; a font or style change clears them; text.fontList {family, style} lists the axes)} style a character range (size/leading/baselineShift are document points and hScale includes the object transform; runs are split at the range ends) → {id, runs}",
|
||||
"{id? (default: the one selected type object), start?: byte, end?: byte (default: all text), font?, style?, size?: pt, leading?: pt|\"auto\", tracking?, kerning?: 1/1000 em|\"auto\", baselineShift?: pt, hScale?: %, vScale?: %, rotation?: deg, fill?: colour|\"none\", stroke?: colour|\"none\", keepModel?: bool (fill and stroke, as paint.setFill), strokeWidth?: pt, strokeOptions?: {weight?, cap?, join?, miterLimit?, align?, dash?, dashOffset?, alignDashes?} (as stroke.set: the character stroke), underline?, strikethrough?, allCaps?: bool, smallCaps?: bool, position?: \"normal\"|\"superscript\"|\"subscript\" (sizes from Document Setup), features?: [\"dlig\", \"-liga\", …], charAlign?: \"romanBaseline\"|\"emBoxTop\"|\"emBoxCenter\"|\"emBoxBottom\"|\"icfTop\"|\"icfBottom\", proportionalMetrics?: bool (full-width glyphs on the font's proportional widths: `palt` in horizontal type, `vpal` in vertical type), tateChuYoko?: bool (Character panel menu › Tate-chu-yoko, with Show East Asian Options: in vertical type those characters stand side by side across one em of the column; kept on the characters and ignored in horizontal type), noBreak?: bool (Character panel menu › No Break: these characters stay on one line, including across a space inside the run), digits?: \"default\"|\"arabic\"|\"hindi\"|\"farsi\" (Character panel menu › Digits: the numeral system every digit is drawn in, whatever was typed), fontAxes?: {\"wght\": 650, …} (Character panel › Variable Font: the setting of each variation axis named, in the axis's units and clamped to its range; null: back to the style's own setting; other axes keep theirs; tags the font has no axis for are left out; a font or style change clears them; text.fontList {family, style} lists the axes)} style a character range (size/leading/baselineShift are document points and hScale includes the object transform; runs are split at the range ends) → {id, runs}",
|
||||
has_doc,
|
||||
set_range_style
|
||||
),
|
||||
@@ -257,6 +257,7 @@ pub(crate) struct CharChange {
|
||||
small_caps: Option<Option<f64>>,
|
||||
char_align: Option<vectorcraft_doc::CharAlign>,
|
||||
proportional_metrics: Option<bool>,
|
||||
tate_chu_yoko: Option<bool>,
|
||||
no_break: Option<bool>,
|
||||
digits: Option<vectorcraft_doc::Digits>,
|
||||
font_axes: Option<AxisChange>,
|
||||
@@ -416,6 +417,7 @@ impl CharChange {
|
||||
small_caps,
|
||||
char_align: char_align_param(p, cmd)?,
|
||||
proportional_metrics: flag("proportionalMetrics"),
|
||||
tate_chu_yoko: flag("tateChuYoko"),
|
||||
no_break: flag("noBreak"),
|
||||
digits: digits_param(p, cmd)?,
|
||||
font_axes: font_axes_param(p, cmd)?,
|
||||
@@ -458,6 +460,7 @@ impl CharChange {
|
||||
&& self.small_caps.is_none()
|
||||
&& self.char_align.is_none()
|
||||
&& self.proportional_metrics.is_none()
|
||||
&& self.tate_chu_yoko.is_none()
|
||||
&& self.no_break.is_none()
|
||||
&& self.digits.is_none()
|
||||
&& self.font_axes.is_none()
|
||||
@@ -554,6 +557,9 @@ impl CharChange {
|
||||
if let Some(v) = self.proportional_metrics {
|
||||
st.proportional_metrics = v;
|
||||
}
|
||||
if let Some(v) = self.tate_chu_yoko {
|
||||
st.tate_chu_yoko = v;
|
||||
}
|
||||
if let Some(v) = self.no_break {
|
||||
st.no_break = v;
|
||||
}
|
||||
@@ -862,6 +868,7 @@ fn create_in_path(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
path_spacing: 0.0,
|
||||
wrap: Vec::new(),
|
||||
optical_margin: false,
|
||||
system_layout: false,
|
||||
fractional_widths: true,
|
||||
cached_bounds: None,
|
||||
cached_baselines: Vec::new(),
|
||||
@@ -870,6 +877,7 @@ fn create_in_path(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
if !on_path {
|
||||
t.area.fit = super::create::new_area_fit(s, p, C)?;
|
||||
}
|
||||
t.system_layout = s.doc()?.doc.setup.system_layout;
|
||||
if bool_or(p, "placeholder", false) {
|
||||
super::typemenu::fill_with_placeholder(&mut t);
|
||||
} else {
|
||||
@@ -1085,7 +1093,8 @@ fn headline_tracking(t: &TextObject, target: f64) -> Option<f64> {
|
||||
path_spacing: 0.0,
|
||||
wrap: Vec::new(),
|
||||
optical_margin: false,
|
||||
fractional_widths: true,
|
||||
system_layout: t.system_layout,
|
||||
fractional_widths: t.fractional_widths,
|
||||
cached_bounds: None,
|
||||
cached_baselines: Vec::new(),
|
||||
};
|
||||
|
||||
@@ -156,6 +156,7 @@ pub fn char_attrs(v: &CharStyle) -> Map<String, Value> {
|
||||
("small_caps", json!(v.small_caps)),
|
||||
("charAlign", json!(v.char_align)),
|
||||
("proportionalMetrics", json!(v.proportional_metrics)),
|
||||
("tateChuYoko", json!(v.tate_chu_yoko)),
|
||||
("noBreak", json!(v.no_break)),
|
||||
("digits", json!(v.digits)),
|
||||
] {
|
||||
|
||||
@@ -205,7 +205,7 @@ pub(crate) fn with_threads(d: &Document, ids: &[NodeId]) -> Vec<NodeId> {
|
||||
}
|
||||
|
||||
/// A closed path converted to an empty area-type frame with `style`.
|
||||
fn frame_from_path(n: &Node, style: vectorcraft_doc::CharStyle) -> Option<Node> {
|
||||
fn frame_from_path(n: &Node, style: vectorcraft_doc::CharStyle, system_layout: bool) -> Option<Node> {
|
||||
let NodeKind::Path { path, .. } = &n.kind else { return None };
|
||||
if !path.subpaths.first().is_some_and(|s| s.closed) {
|
||||
return None;
|
||||
@@ -213,6 +213,7 @@ fn frame_from_path(n: &Node, style: vectorcraft_doc::CharStyle) -> Option<Node>
|
||||
let mut t = TextObject::point(vectorcraft_geom::Point::ZERO, "", style);
|
||||
t.kind = TextKind::Area { frame: path.clone() };
|
||||
t.xf = vectorcraft_geom::Affine::IDENTITY;
|
||||
t.system_layout = system_layout;
|
||||
refresh_bounds(&mut t);
|
||||
Some(Node::new(n.id, NodeKind::Text(Box::new(t))))
|
||||
}
|
||||
@@ -222,7 +223,8 @@ fn create(s: &mut Session, _: &Value) -> Result<Value> {
|
||||
let ids = selected_roots(s)?;
|
||||
let d = &s.doc()?.doc;
|
||||
let style = ids.iter().find_map(|i| text_of(d, *i)).map(|t| t.first_style()).unwrap_or_default();
|
||||
let ok = ids.iter().all(|i| text_of(d, *i).is_some() || d.node(*i).is_some_and(|n| frame_from_path(n, style.clone()).is_some()));
|
||||
let system = d.setup.system_layout;
|
||||
let ok = ids.iter().all(|i| text_of(d, *i).is_some() || d.node(*i).is_some_and(|n| frame_from_path(n, style.clone(), system).is_some()));
|
||||
if ids.len() < 2 || !ok || !ids.iter().any(|i| text_of(d, *i).is_some()) {
|
||||
return Err(bad(C, "select area type and closed paths (at least one area type object)"));
|
||||
}
|
||||
@@ -231,7 +233,7 @@ fn create(s: &mut Session, _: &Value) -> Result<Value> {
|
||||
for id in &ids {
|
||||
if text_of(d, *id).is_none() {
|
||||
let n = d.node(*id).cloned().ok_or(EngineError::NoNode(*id))?;
|
||||
let f = frame_from_path(&n, style.clone()).ok_or_else(|| bad(C, "not a closed path"))?;
|
||||
let f = frame_from_path(&n, style.clone(), d.setup.system_layout).ok_or_else(|| bad(C, "not a closed path"))?;
|
||||
*d.node_mut(*id).ok_or(EngineError::NoNode(*id))? = f;
|
||||
}
|
||||
}
|
||||
@@ -271,7 +273,8 @@ fn add(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
(Some(v), None, None) => {
|
||||
let to = checked_id(s, v, C)?;
|
||||
let parent = d.parent_of(to).and_then(|i| d.node(i));
|
||||
let frame = text_of(d, to).is_some() || d.node(to).is_some_and(|n| frame_from_path(n, style.clone()).is_some());
|
||||
let system = d.setup.system_layout;
|
||||
let frame = text_of(d, to).is_some() || d.node(to).is_some_and(|n| frame_from_path(n, style.clone(), system).is_some());
|
||||
if to == from || !frame || parent.is_some_and(|n| matches!(n.kind, NodeKind::Compound { .. })) {
|
||||
return Err(bad(C, "`to` must be a closed path, area type or type on a path other than `from`"));
|
||||
}
|
||||
@@ -316,7 +319,8 @@ fn add(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
None => {
|
||||
if text_of(d, to).is_none() {
|
||||
let n = d.node(to).cloned().ok_or(EngineError::NoNode(to))?;
|
||||
*d.node_mut(to).ok_or(EngineError::NoNode(to))? = frame_from_path(&n, style).ok_or_else(|| bad(C, "not a closed path"))?;
|
||||
*d.node_mut(to).ok_or(EngineError::NoNode(to))? =
|
||||
frame_from_path(&n, style, d.setup.system_layout).ok_or_else(|| bad(C, "not a closed path"))?;
|
||||
}
|
||||
to
|
||||
}
|
||||
|
||||
@@ -52,6 +52,15 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
has_selection,
|
||||
optical_margin_alignment
|
||||
),
|
||||
cmd!(
|
||||
"type.systemLayout",
|
||||
"System Layout",
|
||||
[],
|
||||
None,
|
||||
"{on?: bool} turn System Layout on or off for the document (on omitted: the opposite of the document's setting) and every text object in it. On, each character that takes any space advances by a whole number of points, at least one, so small type does not run together; a character with no width stays at none. Off (the default, and what a document from before it reads as), spacing uses fractions of a point. New point, area and path type inherits the document's setting → {on}",
|
||||
has_doc,
|
||||
system_layout
|
||||
),
|
||||
cmd!(
|
||||
"type.fractionalWidths",
|
||||
"Fractional Widths",
|
||||
@@ -155,6 +164,31 @@ fn optical_margin_alignment(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
Ok(json!({"on": on, "ids": ids.iter().map(|id| id.0).collect::<Vec<_>>()}))
|
||||
}
|
||||
|
||||
/// Character panel menu › System Layout: set `on` (without it, the opposite of the document's
|
||||
/// setting) on the document and every text object, in one undo step. Off is the default.
|
||||
fn system_layout(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
let current = s.doc()?.doc.setup.system_layout;
|
||||
let on = p.get("on").and_then(Value::as_bool).unwrap_or(!current);
|
||||
s.edit("System Layout", |d, _| {
|
||||
d.setup.system_layout = on;
|
||||
let mut ids = vec![];
|
||||
d.walk(|n| {
|
||||
if matches!(n.kind, NodeKind::Text(_)) {
|
||||
ids.push(n.id);
|
||||
}
|
||||
});
|
||||
for id in ids {
|
||||
let Some(NodeKind::Text(t)) = d.node_mut(id).map(|n| &mut n.kind) else {
|
||||
continue;
|
||||
};
|
||||
t.system_layout = on;
|
||||
refresh_bounds(t);
|
||||
}
|
||||
Ok(())
|
||||
})?;
|
||||
Ok(json!({ "on": on }))
|
||||
}
|
||||
|
||||
/// Character panel menu › Fractional Widths: set `on` (without it, the opposite of the first
|
||||
/// object's setting) on every selected text object and every frame of their threads, in one undo
|
||||
/// step. On is the default.
|
||||
@@ -1167,6 +1201,55 @@ mod area_tests {
|
||||
assert!(!serde_json::from_value::<TextObject>(old).unwrap().optical_margin);
|
||||
}
|
||||
|
||||
/// Character panel menu › System Layout: `type.systemLayout` sets the document and every text
|
||||
/// object in one undo step. New type inherits it. Off by default and in a document from before
|
||||
/// the flag, and saved only when on. On, each positive advance is a whole number of points.
|
||||
#[test]
|
||||
fn system_layout_sets_the_document_and_every_text_object() {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 400, "height": 400})).unwrap();
|
||||
let id = s.execute("text.create", &json!({"x": 10, "y": 40, "size": 13, "text": "Hi"})).unwrap()["id"].as_u64().unwrap();
|
||||
s.execute("text.setStyle", &json!({"id": id, "tracking": 50})).unwrap();
|
||||
let other = s.execute("text.create", &json!({"x": 10, "y": 80, "text": "Yo"})).unwrap()["id"].as_u64().unwrap();
|
||||
let text = |s: &Session, id: u64| match &s.doc().unwrap().doc.node(NodeId(id)).unwrap().kind {
|
||||
NodeKind::Text(t) => (**t).clone(),
|
||||
_ => panic!("text"),
|
||||
};
|
||||
let setup = |s: &Session| s.doc().unwrap().doc.setup.clone();
|
||||
let advances = |s: &Session| {
|
||||
vectorcraft_text::layout(vectorcraft_text::FontDb::global(), &text(s, id)).glyphs.iter().map(|g| g.advance).collect::<Vec<_>>()
|
||||
};
|
||||
assert!(!setup(&s).system_layout);
|
||||
assert!(!text(&s, id).system_layout && !text(&s, other).system_layout);
|
||||
assert!(serde_json::to_value(setup(&s)).unwrap().get("systemLayout").is_none());
|
||||
assert!(serde_json::to_value(text(&s, id)).unwrap().get("systemLayout").is_none());
|
||||
let fractional = advances(&s);
|
||||
assert!(fractional.iter().any(|a| (a - a.round()).abs() > 1e-6), "{fractional:?}");
|
||||
assert_eq!(s.execute("type.systemLayout", &json!({})).unwrap()["on"], true);
|
||||
assert!(setup(&s).system_layout);
|
||||
assert!(text(&s, id).system_layout && text(&s, other).system_layout);
|
||||
let whole = advances(&s);
|
||||
assert!(whole.iter().all(|a| *a >= 1.0 && (a - a.round()).abs() < 1e-9), "{whole:?}");
|
||||
assert!(fractional.iter().zip(&whole).any(|(a, b)| (a - b).abs() > 0.05), "{fractional:?} {whole:?}");
|
||||
assert_eq!(serde_json::to_value(setup(&s)).unwrap()["systemLayout"], true);
|
||||
assert_eq!(serde_json::to_value(text(&s, id)).unwrap()["systemLayout"], true);
|
||||
// New type inherits the document's setting.
|
||||
let made = s.execute("text.create", &json!({"x": 10, "y": 120, "text": "Z"})).unwrap()["id"].as_u64().unwrap();
|
||||
assert!(text(&s, made).system_layout);
|
||||
// A boolean given as text is ignored, so the setting toggles off.
|
||||
assert_eq!(s.execute("type.systemLayout", &json!({"on": "no"})).unwrap()["on"], false);
|
||||
assert!(!setup(&s).system_layout && !text(&s, id).system_layout && !text(&s, made).system_layout);
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert!(setup(&s).system_layout && text(&s, id).system_layout);
|
||||
let back = vectorcraft_format::load(&vectorcraft_format::save(&s.doc().unwrap().doc, false)).unwrap();
|
||||
assert!(back.setup.system_layout);
|
||||
let NodeKind::Text(t) = &back.node(NodeId(id)).unwrap().kind else { panic!("text") };
|
||||
assert!(t.system_layout);
|
||||
let mut old = serde_json::to_value(setup(&s)).unwrap();
|
||||
old.as_object_mut().unwrap().remove("systemLayout");
|
||||
assert!(!serde_json::from_value::<vectorcraft_doc::DocSetup>(old).unwrap().system_layout);
|
||||
}
|
||||
|
||||
/// Character panel menu › Fractional Widths: `type.fractionalWidths` sets or toggles the flag
|
||||
/// on the selected type in one undo step. New type and a document from before the flag are on,
|
||||
/// and the flag is saved only when off. Off, each positive advance is a whole number of points.
|
||||
@@ -1544,6 +1627,36 @@ mod area_tests {
|
||||
assert!(!serde_json::from_value::<vectorcraft_doc::CharStyle>(old).unwrap().proportional_metrics);
|
||||
}
|
||||
|
||||
/// Tate-chu-yoko (Character panel menu, East Asian options): a character attribute, saved only
|
||||
/// when on. Documents written before it read as off.
|
||||
#[test]
|
||||
fn tate_chu_yoko_is_a_character_attribute_saved_only_when_on() {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 400, "height": 400})).unwrap();
|
||||
let id = s.execute("text.create", &json!({"x": 10, "y": 50, "text": "2026年"})).unwrap()["id"].as_u64().unwrap();
|
||||
let runs = |s: &Session| match &s.doc().unwrap().doc.node(NodeId(id)).unwrap().kind {
|
||||
NodeKind::Text(t) => t.runs.clone(),
|
||||
_ => panic!("text"),
|
||||
};
|
||||
assert!(!runs(&s)[0].style.tate_chu_yoko);
|
||||
assert!(serde_json::to_value(&runs(&s)[0].style).unwrap().get("tateChuYoko").is_none());
|
||||
s.execute("select.set", &json!({"ids": [id]})).unwrap();
|
||||
s.execute("text.setFormat", &json!({"tateChuYoko": true})).unwrap();
|
||||
assert!(runs(&s).iter().all(|r| r.style.tate_chu_yoko));
|
||||
assert_eq!(serde_json::to_value(&runs(&s)[0].style).unwrap()["tateChuYoko"], true);
|
||||
s.execute("edit.undo", &json!({})).unwrap();
|
||||
assert!(!runs(&s)[0].style.tate_chu_yoko);
|
||||
// The year only (2026 is 4 bytes); 年 stays unmarked.
|
||||
s.execute("text.setRangeStyle", &json!({"id": id, "start": 0, "end": 4, "tateChuYoko": true})).unwrap();
|
||||
let on: Vec<_> = runs(&s).iter().map(|r| (r.text.clone(), r.style.tate_chu_yoko)).collect();
|
||||
assert_eq!(on, [("2026".to_string(), true), ("年".to_string(), false)]);
|
||||
let old = serde_json::to_value(&runs(&s)[1].style).unwrap();
|
||||
assert!(old.get("tateChuYoko").is_none());
|
||||
assert!(!serde_json::from_value::<vectorcraft_doc::CharStyle>(old).unwrap().tate_chu_yoko);
|
||||
s.execute("text.setFormat", &json!({"tateChuYoko": false})).unwrap();
|
||||
assert!(runs(&s).iter().all(|r| !r.style.tate_chu_yoko));
|
||||
}
|
||||
|
||||
/// No Break is a character attribute, saved only when on.
|
||||
#[test]
|
||||
fn no_break_is_a_character_attribute_saved_only_when_on() {
|
||||
|
||||
@@ -262,6 +262,74 @@ fn stroke_width_test_effect() {
|
||||
std::fs::write(std::path::Path::new(&dir).join("stroke-width-test-effect.wasm"), wat::parse_str(src).unwrap()).unwrap();
|
||||
}
|
||||
|
||||
/// A filter is given its objects' effect records and their strokes' join, cap and miter limit, and
|
||||
/// may return them. The records are admitted as effect.apply would admit them; one that isn't
|
||||
/// refuses the whole output, and nothing changes.
|
||||
#[test]
|
||||
fn filters_set_effects_and_stroke_styles() {
|
||||
let mut s = session();
|
||||
let id = rect(&mut s, 10.0, "#ff0000");
|
||||
install_wat(
|
||||
&mut s,
|
||||
&tpl::module(&tpl::manifest("test.engine.fx", "effect", r#"{"n":{"type":"int","min":0,"max":3,"default":1}}"#), tpl::ECHO, "", 1),
|
||||
);
|
||||
let black = json!({"type": "solid", "color": {"model": "gray", "k": 1.0}});
|
||||
let out = |fx: Value| json!({"objects": [{"id": id.0, "strokes": [{"paint": black, "width": 4, "join": "round", "cap": "square", "miterLimit": 4}], "effects": fx}]});
|
||||
let filter = |s: &mut Session, name: &str, fx: Value| {
|
||||
install_wat(s, &tpl::returning(&tpl::manifest(name, "filter", "{}"), &out(fx).to_string()));
|
||||
s.execute("plugin.run", &json!({"id": name, "ids": [id.0]}))
|
||||
};
|
||||
let fx = json!([{"id": "distort.roughen", "params": {"size": 3}}, {"id": "plugin.test.engine.fx", "params": {"n": 2}, "visible": false}]);
|
||||
filter(&mut s, "test.engine.setfx", fx).unwrap();
|
||||
let n = node(&s, id);
|
||||
let st = n.appearance.stroke().unwrap();
|
||||
assert_eq!((st.width, st.join, st.cap, st.miter_limit), (4.0, vectorcraft_doc::LineJoin::Round, vectorcraft_doc::LineCap::Square, 4.0));
|
||||
let effects = &n.appearance.effects;
|
||||
assert_eq!(effects.iter().map(|e| (e.id.as_str(), e.visible)).collect::<Vec<_>>(), [("distort.roughen", true), ("plugin.test.engine.fx", false)]);
|
||||
assert_eq!(effects[0].params, vectorcraft_render::effects::merged_params("distort.roughen", &json!({"size": 3})), "filled in");
|
||||
assert_eq!(effects[1].params, json!({"n": 2}));
|
||||
// Handed back unchanged (an echo), nothing changes, not even the records' parameters.
|
||||
install_wat(&mut s, &tpl::module(&tpl::manifest("test.engine.same", "filter", "{}"), tpl::ECHO, "", 1));
|
||||
let before = s.doc().unwrap().doc.clone();
|
||||
run(&mut s, "plugin.run", json!({"id": "test.engine.same", "ids": [id.0]}));
|
||||
assert_eq!(s.doc().unwrap().doc, before);
|
||||
// Refused: what effect.apply refuses, a live effect that isn't installed, parameters its
|
||||
// manifest refuses, a texture to read from a file, two 3D effects.
|
||||
for (name, fx, why) in [
|
||||
("test.engine.unknown", json!([{"id": "distort.nothing"}]), "no such effect"),
|
||||
("test.engine.key", json!([{"id": "distort.roughen", "params": {"bogus": 1}}]), "bogus"),
|
||||
("test.engine.gone", json!([{"id": "plugin.test.engine.gone"}]), "no such effect"),
|
||||
("test.engine.badn", json!([{"id": "plugin.test.engine.fx", "params": {"n": "two"}}]), "`n`"),
|
||||
("test.engine.file", json!([{"id": "distort.glass", "params": {"textureImage": {"path": "/etc/hosts"}}}]), "textureImage"),
|
||||
("test.engine.file2", json!([{"id": "texture.texturizer", "params": {"textureImage": {"path": "/etc/hosts"}}}]), "textureImage"),
|
||||
("test.engine.two3d", json!([{"id": "threeD.extrude"}, {"id": "threeD.extrude"}]), "one 3D effect"),
|
||||
] {
|
||||
let e = filter(&mut s, name, fx).unwrap_err().to_string();
|
||||
assert!(e.contains("objects[0].effects") && e.contains(why), "{name}: {e}");
|
||||
assert_eq!(s.doc().unwrap().doc, before, "{name}");
|
||||
}
|
||||
}
|
||||
|
||||
/// `CRAFT_PLUGIN_FRAME_WASM=<folder>` saves a test filter to try in the app
|
||||
/// (`rough-frame-test-filter.wasm`): it adds a frame around 60,40–340,260 with a 6 pt stroke with
|
||||
/// round joins and caps, roughened by the Roughen effect.
|
||||
#[test]
|
||||
fn rough_frame_test_filter() {
|
||||
let Some(dir) = std::env::var_os("CRAFT_PLUGIN_FRAME_WASM") else { return };
|
||||
let frame = PathData::single(SubPath::polyline(
|
||||
&[Point::new(60.0, 40.0), Point::new(340.0, 40.0), Point::new(340.0, 260.0), Point::new(60.0, 260.0)],
|
||||
true,
|
||||
));
|
||||
let ink = json!({"type": "solid", "color": {"model": "rgb", "r": 0.15, "g": 0.2, "b": 0.45}});
|
||||
let out = json!({"objects": [{"name": "Frame", "path": frame, "fills": [],
|
||||
"strokes": [{"paint": ink, "width": 6, "join": "round", "cap": "round"}],
|
||||
"effects": [{"id": "distort.roughen", "params": {"size": 2, "detail": 8, "points": "smooth"}}]}]});
|
||||
let manifest = r#"{"id":"org.example.frame","name":"Rough Frame (test plug-in)","version":"1","kind":"filter",
|
||||
"description":"Adds a frame whose stroke is roughened by the Roughen effect.","params":{}}"#;
|
||||
let src = tpl::returning(manifest, &out.to_string());
|
||||
std::fs::write(std::path::Path::new(&dir).join("rough-frame-test-filter.wasm"), wat::parse_str(src).unwrap()).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn plugin_management_commands() {
|
||||
let mut s = session();
|
||||
|
||||
@@ -31,11 +31,12 @@ const BRUSH_STROKES: [(&str, &str); 8] = [
|
||||
];
|
||||
|
||||
/// Effect › Artistic, at their defaults.
|
||||
const ARTISTIC: [(&str, &str); 14] = [
|
||||
const ARTISTIC: [(&str, &str); 15] = [
|
||||
("artistic.coloredPencil", "{}"),
|
||||
("artistic.cutout", "{}"),
|
||||
("artistic.dryBrush", "{}"),
|
||||
("artistic.filmGrain", "{}"),
|
||||
("artistic.fresco", "{}"),
|
||||
("artistic.neonGlow", "{}"),
|
||||
// Wide Blurry softens dabs; Simple leaves uniform fills unchanged on the striped art.
|
||||
("artistic.paintDaubs", r#"{"brushType": "wideBlurry"}"#),
|
||||
@@ -214,6 +215,7 @@ fn artistic_settings_survive_a_save_and_open() {
|
||||
json!({"levels": 3.0, "edgeSimplicity": 2.0, "edgeFidelity": 3.0}),
|
||||
[json!({"levels": 2.0}), json!({"edgeSimplicity": 10.0})],
|
||||
),
|
||||
("artistic.fresco", json!({"brushSize": 4.0, "brushDetail": 6.0, "texture": 2.0}), [json!({"brushSize": 8.0}), json!({"texture": 3.0})]),
|
||||
(
|
||||
"artistic.neonGlow",
|
||||
json!({"glowSize": -6.0, "glowBrightness": 30.0, "color": "#ff3300"}),
|
||||
|
||||
@@ -26,7 +26,7 @@ impl Shape {
|
||||
}
|
||||
}
|
||||
|
||||
/// The ten Pathfinder panel operations.
|
||||
/// Pathfinder panel and effect operations.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
pub enum PathfinderOp {
|
||||
/// Shape mode: union of everything; result keeps the front-most key.
|
||||
@@ -53,6 +53,9 @@ pub enum PathfinderOp {
|
||||
/// Effect only: split into faces like Divide; overlapping faces take the highest of each CMYK
|
||||
/// channel from every shape covering them (Illustrator Effect → Pathfinder → Hard Mix).
|
||||
HardMix,
|
||||
/// Effect only: split into faces like Divide; overlapping faces blend fills in CMYK bottom to
|
||||
/// top by a mixing rate (Illustrator Effect → Pathfinder → Soft Mix).
|
||||
SoftMix,
|
||||
}
|
||||
|
||||
/// One face of the planar arrangement of a set of shapes (Shape Builder / Live Paint face).
|
||||
@@ -175,7 +178,7 @@ pub fn pathfinder(op: PathfinderOp, shapes: &[Shape]) -> Vec<Shape> {
|
||||
.collect()
|
||||
}
|
||||
PathfinderOp::Outline => outline_edges(&arr, shapes),
|
||||
PathfinderOp::HardMix => regions_of(&arr)
|
||||
PathfinderOp::HardMix | PathfinderOp::SoftMix => regions_of(&arr)
|
||||
.into_iter()
|
||||
.filter_map(|r| {
|
||||
let key = shapes.get(r.top()?)?.key;
|
||||
|
||||
+148
-50
@@ -10,7 +10,7 @@ use std::sync::Arc;
|
||||
|
||||
use serde_json::{Value, json};
|
||||
use vectorcraft_color::{Color, Paint};
|
||||
use vectorcraft_doc::{Appearance, AppearanceItem, Document, FillLayer, Node, NodeId, NodeKind, StrokeLayer};
|
||||
use vectorcraft_doc::{Appearance, AppearanceItem, Document, Effect, FillLayer, LineCap, LineJoin, Node, NodeId, NodeKind, StrokeLayer};
|
||||
use vectorcraft_geom::{FillRule, PathData, Point, Rect};
|
||||
|
||||
use crate::{Error, Result};
|
||||
@@ -26,6 +26,10 @@ pub const MAX_ANCHORS: usize = 4_000_000;
|
||||
pub const MAX_ITEMS: usize = 256;
|
||||
/// Thickest stroke a plug-in may set, in points.
|
||||
pub const MAX_STROKE_WIDTH: f64 = 1000.0;
|
||||
/// The range of a stroke's miter limit (as the Stroke panel's).
|
||||
pub const MITER_LIMIT: std::ops::RangeInclusive<f64> = 1.0..=500.0;
|
||||
/// Longest effect id a plug-in may return, in bytes.
|
||||
pub const MAX_EFFECT_ID: usize = 128;
|
||||
|
||||
/// One object returned by a plug-in. `None` fields keep the object's value (new objects take the
|
||||
/// defaults: a path, non-zero rule, no fills or strokes, full opacity).
|
||||
@@ -43,14 +47,51 @@ pub struct OutObject {
|
||||
pub fills: Option<Vec<Paint>>,
|
||||
pub strokes: Option<Vec<OutStroke>>,
|
||||
pub opacity: Option<f32>,
|
||||
/// The object's effects, in order, replacing its own (not its fills' or strokes'). The host
|
||||
/// admits them before they reach the document ([`AdmitEffects`]).
|
||||
pub effects: Option<Vec<Effect>>,
|
||||
}
|
||||
|
||||
/// One stroke of an [`OutObject`].
|
||||
/// One stroke of an [`OutObject`]. `None` fields keep the stroke's value (a new stroke's
|
||||
/// default: 1 pt, butt cap, miter join, miter limit 10).
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct OutStroke {
|
||||
pub paint: Paint,
|
||||
/// `None`: keep the stroke's weight (1 pt for a new stroke).
|
||||
pub width: Option<f64>,
|
||||
pub join: Option<LineJoin>,
|
||||
pub cap: Option<LineCap>,
|
||||
pub miter_limit: Option<f64>,
|
||||
}
|
||||
|
||||
impl OutStroke {
|
||||
/// A stroke of `paint` that keeps everything else.
|
||||
pub fn paint(paint: Paint) -> Self {
|
||||
Self { paint, width: None, join: None, cap: None, miter_limit: None }
|
||||
}
|
||||
}
|
||||
|
||||
/// How the host admits the effect records a filter returns for object `n` (written with the
|
||||
/// output, its effects still its own): the records to give it, or why they are refused. The
|
||||
/// plug-in crate checks their form; which effects exist and what parameters they take is the
|
||||
/// host's to say.
|
||||
pub type AdmitEffects<'a> = &'a dyn Fn(&[Effect], &Node) -> std::result::Result<Vec<Effect>, String>;
|
||||
|
||||
/// The name plug-ins use for line join `j`, as SVG's `stroke-linejoin`.
|
||||
fn join_name(j: LineJoin) -> &'static str {
|
||||
match j {
|
||||
LineJoin::Miter => "miter",
|
||||
LineJoin::Round => "round",
|
||||
LineJoin::Bevel => "bevel",
|
||||
}
|
||||
}
|
||||
|
||||
/// The name plug-ins use for line cap `c`, as SVG's `stroke-linecap`.
|
||||
fn cap_name(c: LineCap) -> &'static str {
|
||||
match c {
|
||||
LineCap::Butt => "butt",
|
||||
LineCap::Round => "round",
|
||||
LineCap::Square => "square",
|
||||
}
|
||||
}
|
||||
|
||||
fn rule_name(r: FillRule) -> &'static str {
|
||||
@@ -84,25 +125,23 @@ pub fn geometry(n: &Node) -> Option<(PathData, FillRule, bool)> {
|
||||
}
|
||||
|
||||
/// The fills and strokes of appearance `ap` as plug-ins see them, each in paint order: a fill is
|
||||
/// its paint, a stroke `{paint, width}`. Filters and live effects are given the same.
|
||||
/// its paint, a stroke `{paint, width, join, cap, miterLimit}`. Filters and live effects are given
|
||||
/// the same.
|
||||
pub(crate) fn paint_lists(ap: &Appearance) -> (Vec<Value>, Vec<Value>) {
|
||||
let fills = ap.items.iter().filter_map(|i| if let AppearanceItem::Fill(f) = i { Some(paint_json(&f.paint)) } else { None }).collect();
|
||||
let strokes = ap
|
||||
.items
|
||||
.iter()
|
||||
.filter_map(|i| if let AppearanceItem::Stroke(s) = i { Some(json!({"paint": paint_json(&s.paint), "width": s.width})) } else { None })
|
||||
.collect();
|
||||
let stroke = |s: &StrokeLayer| json!({"paint": paint_json(&s.paint), "width": s.width, "join": join_name(s.join), "cap": cap_name(s.cap), "miterLimit": s.miter_limit});
|
||||
let strokes = ap.items.iter().filter_map(|i| if let AppearanceItem::Stroke(s) = i { Some(stroke(s)) } else { None }).collect();
|
||||
(fills, strokes)
|
||||
}
|
||||
|
||||
/// A path or compound path as plug-ins see it (`None` for other objects): `{id, type, name?, path,
|
||||
/// fillRule, fills, strokes, opacity, bounds}`.
|
||||
/// fillRule, fills, strokes, effects, opacity, bounds}`.
|
||||
pub fn encode(n: &Node) -> Option<Value> {
|
||||
let (path, rule, compound) = geometry(n)?;
|
||||
let (fills, strokes) = paint_lists(&n.appearance);
|
||||
let mut o = json!({
|
||||
"id": n.id.0, "type": if compound { "compound" } else { "path" }, "path": path, "fillRule": rule_name(rule),
|
||||
"fills": fills, "strokes": strokes, "opacity": n.opacity, "bounds": rect_json(path.bounds()),
|
||||
"fills": fills, "strokes": strokes, "effects": n.appearance.effects, "opacity": n.opacity, "bounds": rect_json(path.bounds()),
|
||||
});
|
||||
if let Some(name) = &n.name {
|
||||
o["name"] = json!(name);
|
||||
@@ -227,6 +266,9 @@ fn opt<'a>(o: &'a serde_json::Map<String, Value>, key: &str) -> Option<&'a Value
|
||||
o.get(key).filter(|v| !v.is_null())
|
||||
}
|
||||
|
||||
/// Object `v` of a plug-in's output (`at` names it in errors), its anchors added to `anchors` and
|
||||
/// held to [`MAX_ANCHORS`]: each key it has checked, numbers clamped into range, as [`decode`] reads
|
||||
/// them.
|
||||
fn decode_object(v: &Value, at: &str, anchors: &mut usize) -> Result<OutObject> {
|
||||
let o = v.as_object().ok_or_else(|| out_err(at, "an object must be a JSON object"))?;
|
||||
let mut out = OutObject::default();
|
||||
@@ -268,18 +310,10 @@ fn decode_object(v: &Value, at: &str, anchors: &mut usize) -> Result<OutObject>
|
||||
out.fills = Some(fills.iter().enumerate().map(|(i, f)| decode_paint(f, &format!("{at}.fills[{i}]"))).collect::<Result<_>>()?);
|
||||
}
|
||||
if let Some(strokes) = list("strokes")? {
|
||||
let mut v = Vec::with_capacity(strokes.len());
|
||||
for (i, s) in strokes.iter().enumerate() {
|
||||
let at = format!("{at}.strokes[{i}]");
|
||||
let s = s.as_object().ok_or_else(|| out_err(&at, "a stroke must be {\"paint\", \"width\"}"))?;
|
||||
let paint = decode_paint(s.get("paint").unwrap_or(&Value::Null), &at)?;
|
||||
let width = match opt(s, "width") {
|
||||
None => None,
|
||||
Some(w) => Some(w.as_f64().ok_or_else(|| out_err(&at, "`width` must be a number"))?.clamp(0.0, MAX_STROKE_WIDTH)),
|
||||
};
|
||||
v.push(OutStroke { paint, width });
|
||||
}
|
||||
out.strokes = Some(v);
|
||||
out.strokes = Some(strokes.iter().enumerate().map(|(i, s)| decode_stroke(s, &format!("{at}.strokes[{i}]"))).collect::<Result<_>>()?);
|
||||
}
|
||||
if let Some(effects) = list("effects")? {
|
||||
out.effects = Some(effects.iter().enumerate().map(|(i, e)| decode_effect(e, &format!("{at}.effects[{i}]"))).collect::<Result<_>>()?);
|
||||
}
|
||||
if let Some(op) = opt(o, "opacity") {
|
||||
out.opacity = Some(unit(op.as_f64().ok_or_else(|| out_err(at, "`opacity` must be a number"))? as f32));
|
||||
@@ -287,6 +321,58 @@ fn decode_object(v: &Value, at: &str, anchors: &mut usize) -> Result<OutObject>
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// A stroke from plug-in output: `{paint, width?, join?, cap?, miterLimit?}`, its weight clamped
|
||||
/// to 0–[`MAX_STROKE_WIDTH`] and its miter limit into [`MITER_LIMIT`].
|
||||
fn decode_stroke(v: &Value, at: &str) -> Result<OutStroke> {
|
||||
let s = v.as_object().ok_or_else(|| out_err(at, "a stroke must be {\"paint\", \"width\"?, \"join\"?, \"cap\"?, \"miterLimit\"?}"))?;
|
||||
let number = |key: &str, range: std::ops::RangeInclusive<f64>| -> Result<Option<f64>> {
|
||||
let Some(v) = opt(s, key) else { return Ok(None) };
|
||||
let x = v.as_f64().filter(|x| x.is_finite()).ok_or_else(|| out_err(at, format!("`{key}` must be a number")))?;
|
||||
Ok(Some(x.clamp(*range.start(), *range.end())))
|
||||
};
|
||||
let join = match opt(s, "join").map(|j| j.as_str()) {
|
||||
None => None,
|
||||
Some(Some("miter")) => Some(LineJoin::Miter),
|
||||
Some(Some("round")) => Some(LineJoin::Round),
|
||||
Some(Some("bevel")) => Some(LineJoin::Bevel),
|
||||
Some(_) => return Err(out_err(at, "`join` must be \"miter\", \"round\" or \"bevel\"")),
|
||||
};
|
||||
let cap = match opt(s, "cap").map(|c| c.as_str()) {
|
||||
None => None,
|
||||
Some(Some("butt")) => Some(LineCap::Butt),
|
||||
Some(Some("round")) => Some(LineCap::Round),
|
||||
Some(Some("square")) => Some(LineCap::Square),
|
||||
Some(_) => return Err(out_err(at, "`cap` must be \"butt\", \"round\" or \"square\"")),
|
||||
};
|
||||
Ok(OutStroke {
|
||||
paint: decode_paint(s.get("paint").unwrap_or(&Value::Null), at)?,
|
||||
width: number("width", 0.0..=MAX_STROKE_WIDTH)?,
|
||||
join,
|
||||
cap,
|
||||
miter_limit: number("miterLimit", MITER_LIMIT)?,
|
||||
})
|
||||
}
|
||||
|
||||
/// An effect record from plug-in output: `{id, params?, visible?}`, in form only (the host says
|
||||
/// whether the effect exists and takes the parameters). `params` stays as given, so a record
|
||||
/// handed back unchanged equals the object's own.
|
||||
fn decode_effect(v: &Value, at: &str) -> Result<Effect> {
|
||||
let e = v.as_object().ok_or_else(|| out_err(at, "an effect must be {\"id\", \"params\"?, \"visible\"?}"))?;
|
||||
let id = e.get("id").and_then(Value::as_str).filter(|id| (1..=MAX_EFFECT_ID).contains(&id.len()) && !id.chars().any(char::is_control));
|
||||
let id = id.ok_or_else(|| out_err(at, format!("`id` must be an effect id of 1-{MAX_EFFECT_ID} bytes")))?;
|
||||
let params = match e.get("params") {
|
||||
None => Value::Null,
|
||||
Some(p @ (Value::Null | Value::Object(_))) => p.clone(),
|
||||
Some(_) => return Err(out_err(at, "`params` must be an object")),
|
||||
};
|
||||
let visible = match e.get("visible") {
|
||||
None | Some(Value::Null) => true,
|
||||
Some(Value::Bool(b)) => *b,
|
||||
Some(_) => return Err(out_err(at, "`visible` must be true or false")),
|
||||
};
|
||||
Ok(Effect { id: id.to_string(), params, visible })
|
||||
}
|
||||
|
||||
/// Parses a plug-in's output: `{"objects": [...]}`, or `{"error": "message"}` when the plug-in
|
||||
/// declined (the message reaches the user).
|
||||
pub fn decode(bytes: &[u8]) -> Result<Vec<OutObject>> {
|
||||
@@ -343,7 +429,7 @@ fn unlinked(mut p: Paint) -> Paint {
|
||||
|
||||
/// `p` as it may enter `doc`: unchanged from `was` (the paint in the same slot before), or
|
||||
/// without swatch links; a pattern must exist in the document.
|
||||
fn admit(doc: &Document, p: Paint, was: Option<&Paint>, at: &str) -> Result<Paint> {
|
||||
fn admit_paint(doc: &Document, p: Paint, was: Option<&Paint>, at: &str) -> Result<Paint> {
|
||||
if let Paint::Pattern { pattern, .. } = &p
|
||||
&& doc.pattern(pattern).is_none()
|
||||
{
|
||||
@@ -352,30 +438,27 @@ fn admit(doc: &Document, p: Paint, was: Option<&Paint>, at: &str) -> Result<Pain
|
||||
Ok(if was == Some(&p) { p } else { unlinked(p) })
|
||||
}
|
||||
|
||||
/// Sets the paints of `ap`'s fills (`fill`) or strokes to `new`, in paint order: extra items are
|
||||
/// removed (from the top), missing ones added above the last item of their kind (fills at the
|
||||
/// bottom, strokes on top when the object has none).
|
||||
fn set_items(ap: &mut Appearance, fill: bool, new: Vec<(Paint, Option<f64>)>) {
|
||||
/// Sets the paints of `ap`'s fills (`fill`) or strokes to `new` (a fill keeps everything but its
|
||||
/// paint), in paint order: extra items are removed (from the top), missing ones added above the
|
||||
/// last item of their kind (fills at the bottom, strokes on top when the object has none).
|
||||
fn set_items(ap: &mut Appearance, fill: bool, new: Vec<OutStroke>) {
|
||||
let idx: Vec<usize> = ap.items.iter().enumerate().filter(|(_, i)| i.is_fill() == fill).map(|(k, _)| k).collect();
|
||||
for &i in idx.iter().skip(new.len()).rev() {
|
||||
ap.remove_item(i);
|
||||
}
|
||||
let kept = new.len().min(idx.len());
|
||||
let mut at = idx.get(..kept).and_then(<[usize]>::last).map_or(if fill { 0 } else { ap.items.len() }, |i| i + 1);
|
||||
for (k, (paint, width)) in new.into_iter().enumerate() {
|
||||
for (k, o) in new.into_iter().enumerate() {
|
||||
match idx.get(k).and_then(|&i| ap.items.get_mut(i)) {
|
||||
Some(AppearanceItem::Fill(f)) => f.paint = paint,
|
||||
Some(AppearanceItem::Stroke(s)) => {
|
||||
s.paint = paint;
|
||||
if let Some(w) = width {
|
||||
s.width = w;
|
||||
}
|
||||
}
|
||||
Some(AppearanceItem::Fill(f)) => f.paint = o.paint,
|
||||
Some(AppearanceItem::Stroke(s)) => style(s, o),
|
||||
None => {
|
||||
let item = if fill {
|
||||
AppearanceItem::Fill(FillLayer::new(paint))
|
||||
AppearanceItem::Fill(FillLayer::new(o.paint))
|
||||
} else {
|
||||
AppearanceItem::Stroke(StrokeLayer::new(paint, width.unwrap_or(1.0)))
|
||||
let mut s = StrokeLayer::new(Paint::None, 1.0);
|
||||
style(&mut s, o);
|
||||
AppearanceItem::Stroke(s)
|
||||
};
|
||||
ap.insert_item(at, item);
|
||||
at += 1;
|
||||
@@ -384,6 +467,15 @@ fn set_items(ap: &mut Appearance, fill: bool, new: Vec<(Paint, Option<f64>)>) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Gives stroke `s` the paint of `o` and each of its weight, join, cap and miter limit it has.
|
||||
fn style(s: &mut StrokeLayer, o: OutStroke) {
|
||||
s.paint = o.paint;
|
||||
s.width = o.width.unwrap_or(s.width);
|
||||
s.join = o.join.unwrap_or(s.join);
|
||||
s.cap = o.cap.unwrap_or(s.cap);
|
||||
s.miter_limit = o.miter_limit.unwrap_or(s.miter_limit);
|
||||
}
|
||||
|
||||
/// A compound path's members: one path per subpath of `path`, keeping the ids of `old` members.
|
||||
fn members(doc: &mut Document, old: &[Arc<Node>], path: PathData) -> Vec<Arc<Node>> {
|
||||
path.subpaths
|
||||
@@ -396,14 +488,16 @@ fn members(doc: &mut Document, old: &[Arc<Node>], path: PathData) -> Vec<Arc<Nod
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Writes `o` into `n` (an input object, or a fresh node for a new one).
|
||||
fn write(doc: &mut Document, n: &mut Node, o: OutObject, at: &str) -> Result<()> {
|
||||
/// Writes `o` into `n` (an input object, or a fresh node for a new one); its effect records once
|
||||
/// `admit` lets them in.
|
||||
fn write(doc: &mut Document, n: &mut Node, o: OutObject, at: &str, admit: AdmitEffects) -> Result<()> {
|
||||
let (cur_path, cur_rule, cur_compound) = geometry(n).unwrap_or((PathData::default(), FillRule::NonZero, false));
|
||||
let compound = o.compound.unwrap_or(cur_compound);
|
||||
let rule = o.rule.unwrap_or(cur_rule);
|
||||
match (&mut n.kind, compound) {
|
||||
(NodeKind::Path { path, rule: r, live, .. }, false) => {
|
||||
if let Some(p) = o.path {
|
||||
// A path handed back as it was stays the live shape it was.
|
||||
if let Some(p) = o.path.filter(|p| p != path) {
|
||||
*path = p;
|
||||
*live = None;
|
||||
}
|
||||
@@ -421,16 +515,16 @@ fn write(doc: &mut Document, n: &mut Node, o: OutObject, at: &str) -> Result<()>
|
||||
(_, true) => n.kind = NodeKind::Compound { children: members(doc, &[], o.path.unwrap_or(cur_path)), rule },
|
||||
(_, false) => n.kind = NodeKind::Path { path: o.path.unwrap_or(cur_path), rule, live: None, clipping: false, guide: false },
|
||||
}
|
||||
for (fill, new) in [
|
||||
(true, o.fills.map(|f| f.into_iter().map(|p| (p, None)).collect::<Vec<_>>())),
|
||||
(false, o.strokes.map(|s| s.into_iter().map(|s| (s.paint, s.width)).collect())),
|
||||
] {
|
||||
for (fill, new) in [(true, o.fills.map(|f| f.into_iter().map(OutStroke::paint).collect::<Vec<_>>())), (false, o.strokes)] {
|
||||
let Some(new) = new else { continue };
|
||||
let was = paints(&n.appearance, fill);
|
||||
let admitted = new
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.map(|(i, (p, w))| Ok((admit(doc, p, was.get(i).copied(), &format!("{at}.{}[{i}]", if fill { "fills" } else { "strokes" }))?, w)))
|
||||
.map(|(i, s)| {
|
||||
let at = format!("{at}.{}[{i}]", if fill { "fills" } else { "strokes" });
|
||||
Ok(OutStroke { paint: admit_paint(doc, s.paint.clone(), was.get(i).copied(), &at)?, ..s })
|
||||
})
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
set_items(&mut n.appearance, fill, admitted);
|
||||
}
|
||||
@@ -440,6 +534,9 @@ fn write(doc: &mut Document, n: &mut Node, o: OutObject, at: &str) -> Result<()>
|
||||
if let Some(name) = o.name {
|
||||
n.name = Some(name).filter(|s| !s.trim().is_empty());
|
||||
}
|
||||
if let Some(effects) = o.effects {
|
||||
n.appearance.effects = admit(&effects, n).map_err(|why| out_err(&format!("{at}.effects"), why))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -539,8 +636,9 @@ impl Plan {
|
||||
/// without one are new and go just above the object listed before them, or, listed before any
|
||||
/// input object, just below the first one listed after them (at the first input object's place
|
||||
/// when the output keeps none; on top of `parent` when there were no inputs). Input objects missing
|
||||
/// from the output are deleted. Returns the resulting objects in output order (to select).
|
||||
pub fn apply_output(doc: &mut Document, inputs: &[NodeId], out: Vec<OutObject>, parent: Option<NodeId>) -> Result<Vec<NodeId>> {
|
||||
/// from the output are deleted. An object's effect records replace its own once `admit` lets them
|
||||
/// in. Returns the resulting objects in output order (to select).
|
||||
pub fn apply_output(doc: &mut Document, inputs: &[NodeId], out: Vec<OutObject>, parent: Option<NodeId>, admit: AdmitEffects) -> Result<Vec<NodeId>> {
|
||||
let wanted: HashSet<NodeId> = inputs.iter().copied().collect();
|
||||
let mut originals: HashMap<NodeId, Node> = HashMap::new();
|
||||
doc.walk(|n| {
|
||||
@@ -561,7 +659,7 @@ pub fn apply_output(doc: &mut Document, inputs: &[NodeId], out: Vec<OutObject>,
|
||||
let why = if wanted.contains(&id) { "is listed twice" } else { "is not the id of an input object" };
|
||||
out_err(&at, format!("{} {why}", id.0))
|
||||
})?;
|
||||
write(doc, &mut n, o, &at)?;
|
||||
write(doc, &mut n, o, &at, admit)?;
|
||||
if !run.is_empty() {
|
||||
let nodes = std::mem::take(&mut run);
|
||||
match prev {
|
||||
@@ -578,7 +676,7 @@ pub fn apply_output(doc: &mut Document, inputs: &[NodeId], out: Vec<OutObject>,
|
||||
return Err(out_err(&at, "a new object needs a `path`"));
|
||||
}
|
||||
let mut n = Node::path(doc.alloc_id(), PathData::default(), Appearance::default());
|
||||
write(doc, &mut n, o, &at)?;
|
||||
write(doc, &mut n, o, &at, admit)?;
|
||||
result.push(n.id);
|
||||
run.push(n);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,11 @@ fn names(d: &Document, layer: NodeId) -> Vec<String> {
|
||||
d.children(Some(layer)).unwrap().iter().map(|n| n.name.clone().unwrap_or_else(|| "?".into())).collect()
|
||||
}
|
||||
|
||||
/// Admits every effect record as it is (the host's checks are the engine's).
|
||||
fn keep(fx: &[Effect], _: &Node) -> std::result::Result<Vec<Effect>, String> {
|
||||
Ok(fx.to_vec())
|
||||
}
|
||||
|
||||
fn decode_json(v: Value) -> Result<Vec<OutObject>> {
|
||||
decode(v.to_string().as_bytes())
|
||||
}
|
||||
@@ -41,6 +46,8 @@ fn targets_are_selected_paths_in_paint_order() {
|
||||
assert_eq!(filter_targets(&d, &[layer]), [ids[0], ids[2]]);
|
||||
}
|
||||
|
||||
/// Objects as plug-ins are given them (type, name, fill rule, fills, strokes, bounds); handed back
|
||||
/// unchanged, they change nothing, swatch links included.
|
||||
#[test]
|
||||
fn objects_round_trip_through_the_json_model() {
|
||||
let (mut d, ids, _) = doc();
|
||||
@@ -56,10 +63,37 @@ fn objects_round_trip_through_the_json_model() {
|
||||
// Echoed back unchanged, nothing changes (swatch links included).
|
||||
let before = d.clone();
|
||||
let out = decode(&serde_json::to_vec(&input).unwrap()).unwrap();
|
||||
assert_eq!(apply_output(&mut d, &ids, out, None).unwrap(), ids);
|
||||
assert_eq!(apply_output(&mut d, &ids, out, None, &keep).unwrap(), ids);
|
||||
assert_eq!(d, before);
|
||||
}
|
||||
|
||||
/// A path handed back as it was stays the live shape it was (a rectangle keeps its corner
|
||||
/// widgets); a path that changed is a plain path.
|
||||
#[test]
|
||||
fn an_unchanged_path_stays_a_live_shape() {
|
||||
let (mut d, ids, _) = doc();
|
||||
let a = ids[0];
|
||||
let live = vectorcraft_doc::LiveShape::Rectangle {
|
||||
w: 10.0,
|
||||
h: 10.0,
|
||||
radii: [0.0; 4],
|
||||
radii_relative: false,
|
||||
kinds: Default::default(),
|
||||
xf: vectorcraft_geom::Affine::IDENTITY,
|
||||
};
|
||||
if let Some(NodeKind::Path { live: l, .. }) = d.node_mut(a).map(|n| &mut n.kind) {
|
||||
*l = Some(Box::new(live));
|
||||
}
|
||||
let input: Value = serde_json::from_slice(&encode_input(&d, &[a])).unwrap();
|
||||
let before = d.clone();
|
||||
apply_output(&mut d, &[a], decode(&serde_json::to_vec(&input).unwrap()).unwrap(), None, &keep).unwrap();
|
||||
assert_eq!(d, before, "still a live rectangle");
|
||||
apply_output(&mut d, &[a], decode_json(json!({"objects": [{"id": a.0, "path": square(1.0)}]})).unwrap(), None, &keep).unwrap();
|
||||
assert!(matches!(&d.node(a).unwrap().kind, NodeKind::Path { live: None, .. }), "moved: a plain path");
|
||||
}
|
||||
|
||||
/// An output updates the input objects it lists, deletes the ones it leaves out, and adds new
|
||||
/// objects where it lists them.
|
||||
#[test]
|
||||
fn outputs_update_add_and_delete_in_place() {
|
||||
let (mut d, ids, layer) = doc();
|
||||
@@ -67,7 +101,7 @@ fn outputs_update_add_and_delete_in_place() {
|
||||
let new = |name: &str| json!({"name": name, "path": square(5.0), "fills": [{"type": "solid", "color": {"model": "gray", "k": 0.5}}]});
|
||||
// A recoloured, B dropped, C kept; new objects around them.
|
||||
let out = json!({"objects": [new("n1"), {"id": a, "fills": [null, {"type": "solid", "color": {"model": "rgb", "r": 5, "g": 0, "b": 0}}]}, new("n2"), {"id": c}, new("n3")]});
|
||||
let sel = apply_output(&mut d, &ids, decode_json(out).unwrap(), None).unwrap();
|
||||
let sel = apply_output(&mut d, &ids, decode_json(out).unwrap(), None, &keep).unwrap();
|
||||
assert_eq!(names(&d, layer), ["n1", "A", "n2", "C", "n3", "?", "?"]);
|
||||
assert_eq!(sel.len(), 5);
|
||||
assert!(d.node(NodeId(b)).is_none());
|
||||
@@ -79,18 +113,22 @@ fn outputs_update_add_and_delete_in_place() {
|
||||
assert!(n1.appearance.stroke().is_none());
|
||||
}
|
||||
|
||||
/// New objects take the place of the input objects they replace, or go on top of the given
|
||||
/// container when there were none.
|
||||
#[test]
|
||||
fn new_objects_take_the_place_of_replaced_inputs_or_go_on_top() {
|
||||
let (mut d, ids, layer) = doc();
|
||||
let out = json!({"objects": [{"name": "X", "path": square(0.0)}]});
|
||||
apply_output(&mut d, &ids[1..], decode_json(out.clone()).unwrap(), None).unwrap();
|
||||
apply_output(&mut d, &ids[1..], decode_json(out.clone()).unwrap(), None, &keep).unwrap();
|
||||
assert_eq!(names(&d, layer), ["A", "X", "?", "?"], "B and C replaced by X at B's place");
|
||||
// No inputs (a generator): on top of the given container.
|
||||
let (mut d, _, layer) = doc();
|
||||
apply_output(&mut d, &[], decode_json(out).unwrap(), Some(layer)).unwrap();
|
||||
apply_output(&mut d, &[], decode_json(out).unwrap(), Some(layer), &keep).unwrap();
|
||||
assert_eq!(names(&d, layer).last().map(String::as_str), Some("X"));
|
||||
}
|
||||
|
||||
/// An output turns a path into a compound path and back and sets its fill rule, strokes (weights
|
||||
/// clamped), opacity and name.
|
||||
#[test]
|
||||
fn geometry_type_and_strokes_change() {
|
||||
let (mut d, ids, _) = doc();
|
||||
@@ -98,7 +136,7 @@ fn geometry_type_and_strokes_change() {
|
||||
let two = PathData::new(square(0.0).subpaths.into_iter().chain(square(2.0).subpaths).collect());
|
||||
let blue = json!({"type": "solid", "color": {"model": "rgb", "r": 0, "g": 0, "b": 1}});
|
||||
let out = json!({"objects": [{"id": a.0, "type": "compound", "path": two, "fillRule": "evenodd", "strokes": [{"paint": blue, "width": 4000}], "opacity": 0.5, "name": ""}]});
|
||||
apply_output(&mut d, &[a], decode_json(out).unwrap(), None).unwrap();
|
||||
apply_output(&mut d, &[a], decode_json(out).unwrap(), None, &keep).unwrap();
|
||||
let n = d.node(a).unwrap();
|
||||
let NodeKind::Compound { children, rule } = &n.kind else { panic!("not a compound: {:?}", n.kind) };
|
||||
assert_eq!((children.len(), *rule), (2, FillRule::EvenOdd));
|
||||
@@ -107,29 +145,32 @@ fn geometry_type_and_strokes_change() {
|
||||
assert_eq!(geometry(n).unwrap().0, two);
|
||||
// And back to a single path; strokes removed.
|
||||
let out = json!({"objects": [{"id": a.0, "type": "path", "strokes": []}]});
|
||||
apply_output(&mut d, &[a], decode_json(out).unwrap(), None).unwrap();
|
||||
apply_output(&mut d, &[a], decode_json(out).unwrap(), None, &keep).unwrap();
|
||||
let n = d.node(a).unwrap();
|
||||
assert!(matches!(&n.kind, NodeKind::Path { path, .. } if *path == two));
|
||||
assert!(n.appearance.stroke().is_none());
|
||||
}
|
||||
|
||||
/// A paint handed back as it was keeps its swatch link and any other is unlinked; a pattern paint
|
||||
/// must name a pattern the document has.
|
||||
#[test]
|
||||
fn changed_paints_lose_swatch_links_and_patterns_must_exist() {
|
||||
let (mut d, ids, _) = doc();
|
||||
let a = ids[0];
|
||||
d.node_mut(a).unwrap().appearance.set_fill(Paint::Solid { color: Color::rgb(1.0, 0.0, 0.0), swatch: Some("Red".into()), tint: 0.5 });
|
||||
let linked = json!({"type": "solid", "color": {"model": "rgb", "r": 1.0, "g": 0.0, "b": 0.0}, "swatch": "Red", "tint": 0.5});
|
||||
apply_output(&mut d, &[a], decode_json(json!({"objects": [{"id": a.0, "fills": [linked]}]})).unwrap(), None).unwrap();
|
||||
apply_output(&mut d, &[a], decode_json(json!({"objects": [{"id": a.0, "fills": [linked]}]})).unwrap(), None, &keep).unwrap();
|
||||
assert!(matches!(d.node(a).unwrap().appearance.fill_paint(), Paint::Solid { swatch: Some(_), .. }), "unchanged: kept");
|
||||
let other = json!({"type": "solid", "color": {"model": "rgb", "r": 0.0, "g": 1.0, "b": 0.0}, "swatch": "Red", "tint": 0.5});
|
||||
apply_output(&mut d, &[a], decode_json(json!({"objects": [{"id": a.0, "fills": [other]}]})).unwrap(), None).unwrap();
|
||||
apply_output(&mut d, &[a], decode_json(json!({"objects": [{"id": a.0, "fills": [other]}]})).unwrap(), None, &keep).unwrap();
|
||||
assert_eq!(d.node(a).unwrap().appearance.fill_paint(), Paint::solid(Color::rgb(0.0, 1.0, 0.0)));
|
||||
let pattern = json!({"objects": [{"id": a.0, "fills": [{"type": "pattern", "pattern": "Dots"}]}]});
|
||||
assert!(apply_output(&mut d, &[a], decode_json(pattern.clone()).unwrap(), None).is_err());
|
||||
assert!(apply_output(&mut d, &[a], decode_json(pattern.clone()).unwrap(), None, &keep).is_err());
|
||||
d.patterns.push(serde_json::from_value(json!({"name": "Dots", "tile": {"x0": 0, "y0": 0, "x1": 10, "y1": 10}, "art": []})).unwrap());
|
||||
assert!(apply_output(&mut d, &[a], decode_json(pattern).unwrap(), None).is_ok());
|
||||
assert!(apply_output(&mut d, &[a], decode_json(pattern).unwrap(), None, &keep).is_ok());
|
||||
}
|
||||
|
||||
/// Output the host can't read as objects is refused, whatever is wrong with it.
|
||||
#[test]
|
||||
fn bad_outputs_are_refused() {
|
||||
let (d, ids, _) = doc();
|
||||
@@ -153,8 +194,78 @@ fn bad_outputs_are_refused() {
|
||||
json!({"error": "nothing to do"}),
|
||||
] {
|
||||
let mut d = d.clone();
|
||||
let r = decode_json(bad.clone()).and_then(|out| apply_output(&mut d, &ids, out, None));
|
||||
let r = decode_json(bad.clone()).and_then(|out| apply_output(&mut d, &ids, out, None, &keep));
|
||||
assert!(r.is_err(), "{bad}");
|
||||
}
|
||||
assert!(decode(b"\xff\xfe").is_err());
|
||||
}
|
||||
|
||||
/// Strokes come with their join, cap and miter limit and objects with their effect records; both go
|
||||
/// back the same way, the records only as the host admits them.
|
||||
#[test]
|
||||
fn stroke_styles_and_effect_records_round_trip() {
|
||||
let (mut d, ids, _) = doc();
|
||||
let a = ids[0];
|
||||
let roughen = Effect { id: "distort.roughen".into(), params: json!({"size": 5.0}), visible: true };
|
||||
d.node_mut(a).unwrap().appearance.effects.push(roughen.clone());
|
||||
let input: Value = serde_json::from_slice(&encode_input(&d, &[a])).unwrap();
|
||||
let (stroke, effects) = (&input["objects"][0]["strokes"][0], &input["objects"][0]["effects"]);
|
||||
assert_eq!((&stroke["join"], &stroke["cap"], &stroke["miterLimit"]), (&json!("miter"), &json!("butt"), &json!(10.0)));
|
||||
assert_eq!(*effects, json!([{"id": "distort.roughen", "params": {"size": 5.0}, "visible": true}]));
|
||||
// Handed back unchanged, nothing changes; the host sees the records and what the object had.
|
||||
let seen = std::cell::RefCell::new(vec![]);
|
||||
let admit = |fx: &[Effect], n: &Node| -> std::result::Result<Vec<Effect>, String> {
|
||||
seen.borrow_mut().push((fx.to_vec(), n.appearance.effects.clone()));
|
||||
Ok(fx.to_vec())
|
||||
};
|
||||
let before = d.clone();
|
||||
apply_output(&mut d, &[a], decode(&serde_json::to_vec(&input).unwrap()).unwrap(), None, &admit).unwrap();
|
||||
assert_eq!(d, before);
|
||||
assert_eq!(*seen.borrow(), [(vec![roughen.clone()], vec![roughen.clone()])]);
|
||||
// A round join, a square cap, a miter limit past the range; the effects replaced.
|
||||
let out = json!({"objects": [{"id": a.0, "strokes": [{"paint": null, "join": "round", "cap": "square", "miterLimit": 900}],
|
||||
"effects": [{"id": "x.y", "params": {"k": 1}, "visible": false}, {"id": "z"}]}]});
|
||||
apply_output(&mut d, &[a], decode_json(out).unwrap(), None, &admit).unwrap();
|
||||
let n = d.node(a).unwrap();
|
||||
let st = n.appearance.stroke().unwrap();
|
||||
assert_eq!((st.join, st.cap, st.miter_limit, st.width), (LineJoin::Round, LineCap::Square, *MITER_LIMIT.end(), 1.0), "the weight kept");
|
||||
let z = Effect { id: "z".into(), params: Value::Null, visible: true };
|
||||
assert_eq!(n.appearance.effects, [Effect { id: "x.y".into(), params: json!({"k": 1}), visible: false }, z]);
|
||||
// A new object's stroke takes what it is given; the rest is a new stroke's default.
|
||||
let out = json!({"objects": [{"path": square(0.0), "strokes": [{"paint": null, "cap": "round"}]}]});
|
||||
let layer = d.layers[0].id;
|
||||
let new = apply_output(&mut d, &[], decode_json(out).unwrap(), Some(layer), &admit).unwrap();
|
||||
let st = d.node(new[0]).unwrap().appearance.stroke().unwrap().clone();
|
||||
assert_eq!((st.cap, st.join, st.width, st.miter_limit), (LineCap::Round, LineJoin::Miter, 1.0, 10.0));
|
||||
// What the host refuses changes nothing.
|
||||
let before = d.clone();
|
||||
let refuse = |_: &[Effect], _: &Node| -> std::result::Result<Vec<Effect>, String> { Err("not an effect".into()) };
|
||||
let out = json!({"objects": [{"id": a.0, "effects": [{"id": "x.y"}]}]});
|
||||
let e = apply_output(&mut d, &[a], decode_json(out).unwrap(), None, &refuse).unwrap_err();
|
||||
assert_eq!((e.to_string().contains("objects[0].effects: not an effect"), &d), (true, &before), "{e}");
|
||||
}
|
||||
|
||||
/// Stroke styles and effect records in a form the host doesn't read are refused.
|
||||
#[test]
|
||||
fn bad_stroke_styles_and_effect_records_are_refused() {
|
||||
let a = doc().1[0].0;
|
||||
for bad in [json!({"join": "pointy"}), json!({"cap": 3}), json!({"miterLimit": "x"}), json!({"width": "wide"})] {
|
||||
let mut stroke = json!({"paint": null});
|
||||
stroke.as_object_mut().unwrap().extend(bad.as_object().unwrap().clone());
|
||||
assert!(decode_json(json!({"objects": [{"id": a, "strokes": [stroke]}]})).is_err(), "{bad}");
|
||||
}
|
||||
let long = "x".repeat(MAX_EFFECT_ID + 1);
|
||||
for bad in [
|
||||
json!(3),
|
||||
json!([3]),
|
||||
json!([{}]),
|
||||
json!([{"id": ""}]),
|
||||
json!([{"id": 5}]),
|
||||
json!([{"id": long}]),
|
||||
json!([{"id": "a\nb"}]),
|
||||
json!([{"id": "a", "params": [1]}]),
|
||||
json!([{"id": "a", "visible": "yes"}]),
|
||||
] {
|
||||
assert!(decode_json(json!({"objects": [{"id": a, "effects": bad}]})).is_err(), "{bad}");
|
||||
}
|
||||
}
|
||||
+53
-26
@@ -37,6 +37,8 @@ struct Ctx<'a> {
|
||||
/// a quarter turn back (see [`stands_upright`]); [`TextLayout::line_xf`] then stands the lines
|
||||
/// up as columns.
|
||||
vertical: bool,
|
||||
/// Character panel menu › System Layout. On: positive advances are whole points.
|
||||
system_layout: bool,
|
||||
/// Character panel menu › Fractional Widths. Off, positive advances are whole points.
|
||||
fractional_widths: bool,
|
||||
out: TextLayout,
|
||||
@@ -54,7 +56,10 @@ impl Ctx<'_> {
|
||||
let levels = bidi.map_or(&[][..], |b| &b.levels);
|
||||
shape_range(self.db, self.text, r, &self.runs, &self.inlines, &self.opts.features, levels, &mut v);
|
||||
if self.vertical {
|
||||
tate_chu_yoko(&mut v, |g| self.style_at(g.byte).size);
|
||||
tate_chu_yoko(&mut v, |g| {
|
||||
let st = self.style_at(g.byte);
|
||||
(st.size, st.tate_chu_yoko)
|
||||
});
|
||||
// An upright glyph advances down the column by its vertical advance (the font's vertical
|
||||
// metrics; without them at least one em, as CJK fonts' is), centred across it: a narrow
|
||||
// mark like § must not overlap its neighbours.
|
||||
@@ -73,9 +78,9 @@ impl Ctx<'_> {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Fractional Widths off: whole-point advances, after tate-chu-yoko and the upright cell
|
||||
// have set the widths the line breaker will use. A zero advance stays zero.
|
||||
if !self.fractional_widths {
|
||||
// System Layout or Fractional Widths off: whole-point advances, after tate-chu-yoko and the
|
||||
// upright cell have set the widths the line breaker will use. A zero advance stays zero.
|
||||
if self.system_layout || !self.fractional_widths {
|
||||
whole_character_widths(&mut v);
|
||||
}
|
||||
v
|
||||
@@ -387,6 +392,7 @@ fn layout_once(db: &FontDb, t: &TextObject, opts: &LayoutOptions) -> TextLayout
|
||||
default: CharStyle::default(),
|
||||
opts,
|
||||
vertical,
|
||||
system_layout: t.system_layout,
|
||||
fractional_widths: t.fractional_widths,
|
||||
out: TextLayout::default(),
|
||||
};
|
||||
@@ -454,9 +460,9 @@ fn layout_once(db: &FontDb, t: &TextObject, opts: &LayoutOptions) -> TextLayout
|
||||
cx.out
|
||||
}
|
||||
|
||||
/// Fractional Widths off: each character that takes space advances by a whole number of points,
|
||||
/// at least one, so small type does not collapse onto itself. A zero advance (a tate-chu-yoko
|
||||
/// continuation, a zero-width mark) stays zero.
|
||||
/// System Layout on or Fractional Widths off: each character that takes space advances by a whole
|
||||
/// number of points, at least one, so small type does not collapse onto itself. A zero advance (a
|
||||
/// tate-chu-yoko continuation, a zero-width mark) stays zero.
|
||||
fn whole_character_widths(glyphs: &mut [SGlyph]) {
|
||||
for g in glyphs {
|
||||
if g.adv.is_finite() && g.adv > 0.0 {
|
||||
@@ -465,38 +471,59 @@ fn whole_character_widths(glyphs: &mut [SGlyph]) {
|
||||
}
|
||||
}
|
||||
|
||||
/// Tate-chu-yoko: a run of two or three half-width digits (`10`月, `100`年) stands upright across
|
||||
/// the column as one block one em long, squeezed to the em when wider; longer numbers (`2026`)
|
||||
/// stay on their side.
|
||||
fn tate_chu_yoko(g: &mut [SGlyph], size: impl Fn(&SGlyph) -> f64) {
|
||||
let digits: Vec<bool> = g.iter().map(|g| g.ch.is_ascii_digit()).collect();
|
||||
let digit = |i: usize| digits.get(i).copied().unwrap_or(false);
|
||||
/// Tate-chu-yoko: a horizontal block one em of the column long, squeezed to the em when wider.
|
||||
///
|
||||
/// Automatic: a run of two or three half-width digits (`10`月, `100`年). A single digit and a
|
||||
/// longer number (`2026`) stay on their side.
|
||||
///
|
||||
/// Manual (Character panel menu › Tate-chu-yoko): any characters marked `tateChuYoko`, including
|
||||
/// one character, letters and numbers longer than three digits. Marked characters are taken
|
||||
/// before the automatic digit rule.
|
||||
/// <https://helpx.adobe.com/illustrator/using/formatting-asian-characters.html>
|
||||
fn tate_chu_yoko(g: &mut [SGlyph], style: impl Fn(&SGlyph) -> (f64, bool)) {
|
||||
let manual: Vec<bool> = g.iter().map(|gl| style(gl).1).collect();
|
||||
let digits: Vec<bool> = g.iter().map(|gl| gl.inline.is_none() && gl.ch.is_ascii_digit()).collect();
|
||||
let mut i = 0;
|
||||
while i < g.len() {
|
||||
if !digit(i) {
|
||||
if manual.get(i).copied().unwrap_or(false) {
|
||||
let mut end = i + 1;
|
||||
while manual.get(end).copied().unwrap_or(false) {
|
||||
end += 1;
|
||||
}
|
||||
let em = style(&g[i]).0;
|
||||
place_tcy_block(&mut g[i..end], em);
|
||||
i = end;
|
||||
continue;
|
||||
}
|
||||
if !digits.get(i).copied().unwrap_or(false) {
|
||||
i += 1;
|
||||
continue;
|
||||
}
|
||||
let mut end = i;
|
||||
while digit(end) {
|
||||
let mut end = i + 1;
|
||||
while digits.get(end).copied().unwrap_or(false) && !manual.get(end).copied().unwrap_or(false) {
|
||||
end += 1;
|
||||
}
|
||||
if (2..=3).contains(&(end - i)) {
|
||||
let em = size(&g[i]);
|
||||
let width: f64 = g[i..end].iter().map(|g| g.adv).sum();
|
||||
let squeeze = if width > em && width > 0.0 { em / width } else { 1.0 };
|
||||
let mut ink = 0.0;
|
||||
for (k, gl) in g[i..end].iter_mut().enumerate() {
|
||||
let adv = gl.adv;
|
||||
gl.tcy = Some(Tcy { pen: if k == 0 { 0.0 } else { em }, ink, width, squeeze });
|
||||
gl.adv = if k == 0 { em } else { 0.0 };
|
||||
ink += adv;
|
||||
}
|
||||
let em = style(&g[i]).0;
|
||||
place_tcy_block(&mut g[i..end], em);
|
||||
}
|
||||
i = end;
|
||||
}
|
||||
}
|
||||
|
||||
/// Lay `g` across one em of the column. The first glyph takes the em; the rest share its cell.
|
||||
fn place_tcy_block(g: &mut [SGlyph], em: f64) {
|
||||
let width: f64 = g.iter().map(|gl| gl.adv).sum();
|
||||
let squeeze = if width > em && width > 0.0 { em / width } else { 1.0 };
|
||||
let mut ink = 0.0;
|
||||
for (k, gl) in g.iter_mut().enumerate() {
|
||||
let adv = gl.adv;
|
||||
gl.tcy = Some(Tcy { pen: if k == 0 { 0.0 } else { em }, ink, width, squeeze });
|
||||
gl.adv = if k == 0 { em } else { 0.0 };
|
||||
ink += adv;
|
||||
}
|
||||
}
|
||||
|
||||
/// Half an em of `g`'s size when it is full-width Japanese punctuation of kind `kind` (its
|
||||
/// advance an em, give or take a tenth), the space that mojikumi can take off.
|
||||
fn punct_half(g: &SGlyph, kind: Punct) -> Option<f64> {
|
||||
|
||||
@@ -470,6 +470,7 @@ fn shapes_alike(a: &CharStyle, b: &CharStyle) -> bool {
|
||||
small_caps,
|
||||
char_align: _,
|
||||
proportional_metrics,
|
||||
tate_chu_yoko,
|
||||
digits,
|
||||
no_break,
|
||||
} = a;
|
||||
@@ -485,6 +486,7 @@ fn shapes_alike(a: &CharStyle, b: &CharStyle) -> bool {
|
||||
&& *position == b.position
|
||||
&& *small_caps == b.small_caps
|
||||
&& *proportional_metrics == b.proportional_metrics
|
||||
&& *tate_chu_yoko == b.tate_chu_yoko
|
||||
&& *digits == b.digits
|
||||
&& *no_break == b.no_break
|
||||
&& ligatures_suppressed_by(*tracking) == ligatures_suppressed_by(b.tracking)
|
||||
|
||||
@@ -67,6 +67,34 @@ fn add_font_rejects_garbage_and_duplicates() {
|
||||
assert_eq!(db().add_font(bytes), 0, "already bundled");
|
||||
}
|
||||
|
||||
/// Character panel menu › System Layout: each character that takes space advances by a whole
|
||||
/// number of points, at least one. Off (the default) keeps the font's fractional advances. A
|
||||
/// tate-chu-yoko continuation stays at zero.
|
||||
/// <https://helpx.adobe.com/illustrator/desktop/design-with-text/edit-format-text/turn-fractional-character-widths-off-or-on.html>
|
||||
#[test]
|
||||
fn system_layout_rounds_positive_advances_to_whole_points() {
|
||||
let mut off = point("Hi", style(13.0));
|
||||
off.runs[0].style.tracking = 50.0;
|
||||
assert!(!off.system_layout);
|
||||
let fractional: Vec<f64> = layout(db(), &off).glyphs.iter().map(|g| g.advance).collect();
|
||||
assert!(fractional.iter().any(|a| (a - a.round()).abs() > 1e-6), "{fractional:?}");
|
||||
let mut on = off.clone();
|
||||
on.system_layout = true;
|
||||
let whole: Vec<f64> = layout(db(), &on).glyphs.iter().map(|g| g.advance).collect();
|
||||
assert!(whole.iter().all(|a| *a >= 1.0 && (a - a.round()).abs() < 1e-9), "{whole:?}");
|
||||
assert!(fractional.iter().zip(&whole).any(|(a, b)| (a - b).abs() > 0.05), "{fractional:?} {whole:?}");
|
||||
let mut tiny = point("i", style(0.4));
|
||||
tiny.system_layout = true;
|
||||
let laid = layout(db(), &tiny);
|
||||
assert!(laid.glyphs.iter().any(|g| (g.advance - 1.0).abs() < 1e-9), "{:?}", laid.glyphs.iter().map(|g| g.advance).collect::<Vec<_>>());
|
||||
let mut tcy = point("10", style(20.0));
|
||||
tcy.vertical = true;
|
||||
tcy.system_layout = true;
|
||||
let adv: Vec<f64> = layout(db(), &tcy).glyphs.iter().map(|g| g.advance).collect();
|
||||
assert!(adv.contains(&0.0), "a tate-chu-yoko continuation stays at zero: {adv:?}");
|
||||
assert!(adv.iter().all(|a| *a == 0.0 || (a - a.round()).abs() < 1e-9), "{adv:?}");
|
||||
}
|
||||
|
||||
/// Character panel menu › Fractional Widths, off: each character that takes space advances by a
|
||||
/// whole number of points, at least one. On (the default) keeps the font's fractional advances,
|
||||
/// including tracking. A tate-chu-yoko continuation stays at zero.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//! Japanese text only with craft-fonts' faces, skipped without them).
|
||||
use super::*;
|
||||
use kurbo::Shape;
|
||||
use vectorcraft_doc::{CharStyle, Justify, TextKind};
|
||||
use vectorcraft_doc::{CharStyle, Justify, TextKind, TextRun};
|
||||
use vectorcraft_geom::PathData;
|
||||
|
||||
fn vertical(text: &str) -> TextObject {
|
||||
@@ -318,6 +318,67 @@ fn tracking_spaces_upright_marks_without_moving_them_off_the_centre_line() {
|
||||
assert!((step - 24.0).abs() < 1e-6, "one em plus 200/1000 em of tracking: {step}");
|
||||
}
|
||||
|
||||
/// Character panel menu › Tate-chu-yoko: a marked run stands across one em of the column, including
|
||||
/// a number longer than three digits and Latin letters. Unmarked text keeps the automatic rule
|
||||
/// (two or three digits only). Horizontal type stores the mark and does not move the letters.
|
||||
#[test]
|
||||
fn manual_tate_chu_yoko_sets_marked_characters_across_one_em() {
|
||||
let marked = CharStyle { size: 20.0, tate_chu_yoko: true, ..CharStyle::default() };
|
||||
let year = layout(FontDb::global(), &vertical_styled("2026", marked.clone()));
|
||||
assert_eq!(year.glyphs.len(), 4);
|
||||
assert!((year.glyphs[0].advance - 20.0).abs() < 1e-6, "{:?}", year.glyphs[0].advance);
|
||||
assert!(year.glyphs[1..].iter().all(|g| g.advance == 0.0));
|
||||
let inks: Vec<Rect> = (0..4).map(|i| ink(&year, i)).collect();
|
||||
for pair in inks.windows(2) {
|
||||
assert!((pair[0].center().y - pair[1].center().y).abs() < 1.0, "one row: {inks:?}");
|
||||
assert!(pair[1].center().x > pair[0].center().x, "left to right: {inks:?}");
|
||||
}
|
||||
let union = inks.iter().copied().reduce(|a, b| a.union(b)).unwrap();
|
||||
assert!(union.width() <= 21.0, "squeezed into the em: {union:?}");
|
||||
assert!(union.center().x.abs() < 1.5, "centred on the column: {union:?}");
|
||||
|
||||
let plain = layout(FontDb::global(), &vertical("2026"));
|
||||
let down: f64 = plain.glyphs.iter().map(|g| g.advance).sum();
|
||||
assert!(down > 30.0 && plain.glyphs.iter().all(|g| g.advance > 0.0), "unmarked 2026 runs down the column: {down}");
|
||||
|
||||
let letters = layout(FontDb::global(), &vertical_styled("AB", marked.clone()));
|
||||
assert!((letters.glyphs[0].advance - 20.0).abs() < 1e-6 && letters.glyphs[1].advance == 0.0);
|
||||
let (a, b) = (ink(&letters, 0), ink(&letters, 1));
|
||||
assert!((a.center().y - b.center().y).abs() < 1.0 && b.center().x > a.center().x, "letters side by side: {a:?} {b:?}");
|
||||
let side = layout(FontDb::global(), &vertical("AB"));
|
||||
assert!(ink(&side, 1).center().y > ink(&side, 0).center().y + 5.0, "unmarked letters run down the column");
|
||||
|
||||
let mut horizontal = TextObject::point(Point::ZERO, "AB", marked);
|
||||
horizontal.xf = Affine::IDENTITY;
|
||||
let row = layout(FontDb::global(), &horizontal);
|
||||
assert!(!row.vertical);
|
||||
assert!(row.glyphs.iter().all(|g| g.advance > 0.0));
|
||||
assert!(ink(&row, 1).center().x > ink(&row, 0).center().x + 5.0, "horizontal type stays a row");
|
||||
}
|
||||
|
||||
/// A marked run is one block; the unmarked digits beside it still follow the automatic rule.
|
||||
/// A column shorter than two ems holds the marked number on one line.
|
||||
#[test]
|
||||
fn manual_tate_chu_yoko_leaves_unmarked_digits_and_stays_on_one_line() {
|
||||
let plain = CharStyle { size: 20.0, ..CharStyle::default() };
|
||||
let marked = CharStyle { tate_chu_yoko: true, ..plain.clone() };
|
||||
let mut t = vertical_styled("", plain.clone());
|
||||
t.runs = vec![TextRun::new("X", plain), TextRun::new("2026", marked), TextRun::new("10", CharStyle { size: 20.0, ..CharStyle::default() })];
|
||||
let l = layout(FontDb::global(), &t);
|
||||
assert_eq!(l.glyphs.len(), 7);
|
||||
assert!(l.glyphs[0].advance > 0.0 && l.glyphs[0].advance < 20.0, "X on its side: {:?}", l.glyphs[0].advance);
|
||||
assert!((l.glyphs[1].advance - 20.0).abs() < 1e-6 && l.glyphs[2].advance == 0.0 && l.glyphs[3].advance == 0.0 && l.glyphs[4].advance == 0.0);
|
||||
assert!((l.glyphs[5].advance - 20.0).abs() < 1e-6 && l.glyphs[6].advance == 0.0, "unmarked 10 stays automatic");
|
||||
|
||||
t.kind = TextKind::Area { frame: PathData::from_bezpath(&Rect::new(0.0, 0.0, 80.0, 30.0).to_path(0.1)) };
|
||||
t.runs = vec![TextRun::new("2026", CharStyle { size: 20.0, tate_chu_yoko: true, ..CharStyle::default() })];
|
||||
let one = layout(FontDb::global(), &t);
|
||||
assert_eq!(one.lines.len(), 1, "the block is one em, so it fits a 30 pt column");
|
||||
t.runs = vec![TextRun::new("2026", CharStyle { size: 20.0, ..CharStyle::default() })];
|
||||
let wrapped = layout(FontDb::global(), &t);
|
||||
assert!(wrapped.lines.len() > 1, "unmarked 2026 is longer than the column");
|
||||
}
|
||||
|
||||
/// Issue #260 as reported, with a Japanese face of craft-fonts (whose own digits are proportional).
|
||||
#[test]
|
||||
fn japanese_numbers_keep_their_own_cells_down_the_column() {
|
||||
|
||||
@@ -33,7 +33,9 @@ vectorcraft-pdf = { workspace = true }
|
||||
vectorcraft-cad = { workspace = true }
|
||||
vectorcraft-eps = { workspace = true }
|
||||
vectorcraft-format = { workspace = true }
|
||||
egui = { workspace = true }
|
||||
egui = { workspace = true, features = ["bytemuck"] }
|
||||
# With egui's `bytemuck`: copies rendered rasters into egui images whole (`canvas::color_image`).
|
||||
bytemuck = "1"
|
||||
egui_extras = { workspace = true }
|
||||
image = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
|
||||
@@ -3114,9 +3114,22 @@ fn kurbo_flatten(p: &BezPath, tol: f64, f: &mut impl FnMut(PathEl)) {
|
||||
vectorcraft_geom::kurbo::flatten(p.elements().iter().copied(), tol, f);
|
||||
}
|
||||
|
||||
/// The rendered raster `img` as an egui image. Both are premultiplied RGBA8, so its bytes are copied
|
||||
/// over whole instead of pixel by pixel, which costs milliseconds for a canvas on a large screen.
|
||||
/// A raster whose bytes don't match its size gives an empty image of that size.
|
||||
pub(crate) fn color_image(img: &vectorcraft_render::Rendered) -> egui::ColorImage {
|
||||
let size = [img.width as usize, img.height as usize];
|
||||
let mut pixels = vec![egui::Color32::TRANSPARENT; size[0] * size[1]];
|
||||
let bytes: &mut [u8] = bytemuck::cast_slice_mut(&mut pixels);
|
||||
if bytes.len() == img.pixels.len() {
|
||||
bytes.copy_from_slice(&img.pixels);
|
||||
}
|
||||
egui::ColorImage::new(size, pixels)
|
||||
}
|
||||
|
||||
/// Upload the art's raster; Pixel Preview's document pixels keep hard edges when magnified.
|
||||
fn upload(app: &mut VectorcraftApp, ctx: &egui::Context, img: &vectorcraft_render::Rendered, pixel: bool) {
|
||||
let color = egui::ColorImage::from_rgba_premultiplied([img.width as usize, img.height as usize], &img.pixels);
|
||||
let color = color_image(img);
|
||||
let options = if pixel { egui::TextureOptions::NEAREST } else { egui::TextureOptions::LINEAR };
|
||||
match &mut app.canvas.texture {
|
||||
Some(tex) => tex.set(color, options),
|
||||
@@ -3433,6 +3446,23 @@ mod tests {
|
||||
use vectorcraft_engine::Session;
|
||||
use vectorcraft_geom::Shape as _;
|
||||
|
||||
/// A rendered raster becomes the image egui's own conversion makes of it, half-transparent
|
||||
/// edges and all; one whose bytes don't match its size becomes an empty image of that size.
|
||||
#[test]
|
||||
fn rendered_rasters_become_the_same_egui_images() {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &serde_json::json!({})).unwrap();
|
||||
s.execute("shape.ellipse", &serde_json::json!({"x": 10, "y": 10, "width": 60, "height": 40})).unwrap();
|
||||
s.execute("paint.setFill", &serde_json::json!({"color": "#3366cc"})).unwrap();
|
||||
let doc = s.active().unwrap().doc.clone();
|
||||
let img = vectorcraft_render::Renderer::new().render(&doc, 97, 61, Affine::IDENTITY, &vectorcraft_render::RenderOptions::default());
|
||||
assert!(img.pixels.as_chunks::<4>().0.iter().any(|p| p[3] != 0 && p[3] != 255), "partly covered pixels");
|
||||
let egui = egui::ColorImage::from_rgba_premultiplied([97, 61], &img.pixels);
|
||||
assert_eq!(color_image(&img), egui);
|
||||
let short = vectorcraft_render::Rendered { width: 3, height: 2, pixels: vec![255; 5] };
|
||||
assert_eq!(color_image(&short), egui::ColorImage::new([3, 2], vec![egui::Color32::TRANSPARENT; 6]));
|
||||
}
|
||||
|
||||
/// With VECTORCRAFT_SYSTEM_CURSORS set the glyphs aren't drawn and the system's cursors stand in: those of
|
||||
/// the Pen and the other drawing tools are the system crosshair already, so Use Precise Cursors makes no
|
||||
/// difference to them there.
|
||||
@@ -5971,6 +6001,18 @@ mod tests {
|
||||
assert!(outlines(&mut app) > 0, "Pixel Preview off again");
|
||||
}
|
||||
|
||||
/// View › Snap to Glyph toggles through the View menu command (#3124).
|
||||
#[test]
|
||||
fn snap_to_glyph_menu_command_toggles_the_view_flag() {
|
||||
let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default());
|
||||
app.run("file.new", json!({"width": 200, "height": 200})).unwrap();
|
||||
assert!(!app.ui.view.snap_to_glyph);
|
||||
app.run("view.snapToGlyph", json!({})).unwrap();
|
||||
assert!(app.ui.view.snap_to_glyph);
|
||||
app.run("view.snapToGlyph", json!({})).unwrap();
|
||||
assert!(!app.ui.view.snap_to_glyph);
|
||||
}
|
||||
|
||||
/// Smart Guides › Object Highlighting (#394): the outline of the object under the pointer
|
||||
/// shows with Smart Guides on and the option on, and not otherwise.
|
||||
#[test]
|
||||
|
||||
@@ -119,7 +119,7 @@ fn preview(ui: &egui::Ui, app: &VectorcraftApp, name: &str, r: egui::Rect) {
|
||||
let px = (r.width() * ui.ctx().pixels_per_point()).round() as u32;
|
||||
let tex = CACHE.with(|c| c.borrow().get(&key).cloned()).or_else(|| {
|
||||
let img = RENDERER.with(|rr| rr.borrow_mut().render_node_thumbnail(&st.doc, &art, px.max(16), Some([255, 255, 255, 255])))?;
|
||||
let color = egui::ColorImage::from_rgba_premultiplied([img.width as usize, img.height as usize], &img.pixels);
|
||||
let color = crate::canvas::color_image(&img);
|
||||
let tex = ui.ctx().load_texture(format!("graph-design-{key}"), color, egui::TextureOptions::LINEAR);
|
||||
CACHE.with(|c| {
|
||||
let mut c = c.borrow_mut();
|
||||
|
||||
@@ -3004,6 +3004,7 @@
|
||||
Snapping Tolerance Толеранс на прилепване
|
||||
Social Square Post 1080×1080 Публикация за квадрат в социални мрежи 1080×1080
|
||||
Soft Light Мека светлина
|
||||
Soft Mix Мека смес
|
||||
Solid Плътен
|
||||
Sort by Kind Сортиране по вид
|
||||
Sort by Name Сортиране по име
|
||||
@@ -5240,6 +5241,8 @@ theme Appearance Външен вид
|
||||
Sketch Скица
|
||||
Halftone Pattern… Полутонов шаблон…
|
||||
Halftone Pattern Полутонов шаблон
|
||||
Torn Edges… Разкъсани краища…
|
||||
Torn Edges Разкъсани краища
|
||||
Pattern Type Тип шаблон
|
||||
Dot Точка
|
||||
# User Interface › Color Scheme
|
||||
@@ -5323,3 +5326,5 @@ theme Appearance Външен вид
|
||||
Water Paper Мокра хартия
|
||||
Ruby… Руби…
|
||||
Ruby Руби
|
||||
Fresco… Фреска…
|
||||
Fresco Фреска
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2913,6 +2913,7 @@ lighting Light Světlo
|
||||
Luminosity Světlost
|
||||
Overlay Překrýt
|
||||
Soft Light Měkké světlo
|
||||
Soft Mix Měkké míchání
|
||||
Crosshatch Křížové šrafování
|
||||
Fine Dots Jemné tečky
|
||||
|
||||
@@ -5271,6 +5272,8 @@ mark-style Japanese Japonské
|
||||
Sketch Skica
|
||||
Halftone Pattern… Polotónový vzorek…
|
||||
Halftone Pattern Polotónový vzorek
|
||||
Torn Edges… Roztržené okraje…
|
||||
Torn Edges Roztržené okraje
|
||||
Pattern Type Typ vzorku
|
||||
Dot Tečka
|
||||
# User Interface › Color Scheme
|
||||
@@ -5366,3 +5369,5 @@ mark-style Japanese Japonské
|
||||
Water Paper Mokrý papír
|
||||
Ruby… Ruby…
|
||||
Ruby Ruby
|
||||
Fresco… Freska…
|
||||
Fresco Freska
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2686,6 +2686,7 @@ lighting Light Lys
|
||||
Luminosity Luminans
|
||||
Overlay Overlejring
|
||||
Soft Light Blødt lys
|
||||
Soft Mix Blød blanding
|
||||
Crosshatch Krydsskravering
|
||||
Fine Dots Fine prikker
|
||||
|
||||
@@ -5132,6 +5133,8 @@ swatch Bright Violet Kraftig violet
|
||||
Sketch Skitse
|
||||
Halftone Pattern… Rastermønster…
|
||||
Halftone Pattern Rastermønster
|
||||
Torn Edges… Flængede kanter…
|
||||
Torn Edges Flængede kanter
|
||||
Pattern Type Mønstertype
|
||||
Dot Prik
|
||||
Export Type: Eksporttype:
|
||||
@@ -5339,3 +5342,5 @@ swatch Bright Violet Kraftig violet
|
||||
Water Paper Vådt papir
|
||||
Ruby… Ruby…
|
||||
Ruby Ruby
|
||||
Fresco… Fresko…
|
||||
Fresco Fresko
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3040,6 +3040,7 @@ effect Points Punkte
|
||||
Snapping Tolerance Einrasttoleranz
|
||||
Social Square Post 1080×1080 Quadratischer Social-Media-Beitrag 1080×1080
|
||||
Soft Light Weiches Licht
|
||||
Soft Mix Weiche Mischung
|
||||
Solid Gefüllt
|
||||
Sort by Kind Nach Art sortieren
|
||||
Sort by Name Nach Name sortieren
|
||||
@@ -4850,6 +4851,8 @@ effect Soft Weich
|
||||
Sketch Zeichenfilter
|
||||
Halftone Pattern… Rasterungseffekt…
|
||||
Halftone Pattern Rasterungseffekt
|
||||
Torn Edges… Zerrissene Kanten…
|
||||
Torn Edges Zerrissene Kanten
|
||||
Pattern Type Musterart
|
||||
Dot Punkt
|
||||
# User Interface › Color Scheme
|
||||
@@ -4947,3 +4950,5 @@ effect Soft Weich
|
||||
Water Paper Feuchtes Papier
|
||||
Ruby… Ruby…
|
||||
Ruby Ruby
|
||||
Fresco… Fresko…
|
||||
Fresco Fresko
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -1866,6 +1866,7 @@
|
||||
Snap to Point Προσκόλληση σε σημείο
|
||||
Snap to Unit Προσκόλληση σε μονάδα
|
||||
Soft Light Απαλό φως
|
||||
Soft Mix Απαλή ανάμειξη
|
||||
Solid Συνεχές
|
||||
Spacing: Απόσταση:
|
||||
Total: Σύνολο:
|
||||
@@ -5223,6 +5224,8 @@ effect Points Σημεία
|
||||
Sketch Σκίτσο
|
||||
Halftone Pattern… Μοτίβο ημιτόνου…
|
||||
Halftone Pattern Μοτίβο ημιτόνου
|
||||
Torn Edges… Ξεσκισμένες άκρες…
|
||||
Torn Edges Ξεσκισμένες άκρες
|
||||
Pattern Type Τύπος μοτίβου
|
||||
Dot Κουκκίδα
|
||||
# User Interface › Color Scheme
|
||||
@@ -5318,3 +5321,5 @@ effect Points Σημεία
|
||||
Water Paper Βρεγμένο χαρτί
|
||||
Ruby… Ruby…
|
||||
Ruby Ruby
|
||||
Fresco… Νωπογραφία…
|
||||
Fresco Νωπογραφία
|
||||
|
Can't render this file because it contains an unexpected character in line 2039 and column 19.
|
@@ -3070,6 +3070,7 @@
|
||||
Snapping Tolerance Tolerancia de ajuste
|
||||
Social Square Post 1080×1080 Publicación cuadrada para redes 1080×1080
|
||||
Soft Light Luz suave
|
||||
Soft Mix Mezcla suave
|
||||
Solid Sólido
|
||||
Sort by Kind Ordenar por tipo
|
||||
Sort by Name Ordenar por nombre
|
||||
@@ -5213,6 +5214,8 @@ mark-style Japanese Japonesas
|
||||
Sketch Bosquejar
|
||||
Halftone Pattern… Trama de semitonos…
|
||||
Halftone Pattern Trama de semitonos
|
||||
Torn Edges… Bordes desgarrados…
|
||||
Torn Edges Bordes desgarrados
|
||||
Pattern Type Tipo de trama
|
||||
Dot Punto
|
||||
# User Interface › Color Scheme
|
||||
@@ -5308,3 +5311,5 @@ mark-style Japanese Japonesas
|
||||
Water Paper Papel mojado
|
||||
Ruby… Ruby…
|
||||
Ruby Ruby
|
||||
Fresco… Fresco…
|
||||
Fresco Fresco
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2859,6 +2859,7 @@ lighting Light Valo
|
||||
Luminosity Luminanssi
|
||||
Overlay Sulautus
|
||||
Soft Light Pehmeä valo
|
||||
Soft Mix Pehmeä sekoitus
|
||||
Crosshatch Ristiviivoitus
|
||||
Fine Dots Hienot pisteet
|
||||
|
||||
@@ -5235,6 +5236,8 @@ mark-style Japanese Japanilainen
|
||||
Sketch Luonnos
|
||||
Halftone Pattern… Rasterikuvio…
|
||||
Halftone Pattern Rasterikuvio
|
||||
Torn Edges… Repeytyneet reunat…
|
||||
Torn Edges Repeytyneet reunat
|
||||
Pattern Type Kuviotyyppi
|
||||
Dot Piste
|
||||
# User Interface › Color Scheme
|
||||
@@ -5397,3 +5400,5 @@ swatch Bright Violet Kirkas violetti
|
||||
Water Paper Märkä paperi
|
||||
Ruby… Ruby…
|
||||
Ruby Ruby
|
||||
Fresco… Fresko…
|
||||
Fresco Fresko
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3067,6 +3067,7 @@
|
||||
Snapping Tolerance Tolérance du magnétisme
|
||||
Social Square Post 1080×1080 Publication carrée pour réseaux sociaux 1080×1080
|
||||
Soft Light Lumière tamisée
|
||||
Soft Mix Fusion douce
|
||||
Solid Plein
|
||||
Sort by Kind Trier par type
|
||||
Sort by Name Trier par nom
|
||||
@@ -5270,6 +5271,8 @@ theme Appearance Apparence
|
||||
Sketch Esquisse
|
||||
Halftone Pattern… Trame de demi-teintes…
|
||||
Halftone Pattern Trame de demi-teintes
|
||||
Torn Edges… Bords déchirés…
|
||||
Torn Edges Bords déchirés
|
||||
Pattern Type Type de motif
|
||||
Dot Point
|
||||
# User Interface › Color Scheme
|
||||
@@ -5365,3 +5368,5 @@ theme Appearance Apparence
|
||||
Water Paper Papier humide
|
||||
Ruby… Ruby…
|
||||
Ruby Ruby
|
||||
Fresco… Fresque…
|
||||
Fresco Fresque
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3702,6 +3702,7 @@ mark-style Japanese Japán
|
||||
Social Tall Post 1000×1500 Magas közösségimédia-bejegyzés 1000×1500
|
||||
Soft Lágy
|
||||
Soft Light Lágy fény
|
||||
Soft Mix Lágy keverés
|
||||
Solid Kitöltött
|
||||
Sort Rendezés
|
||||
Sort by Hue Rendezés színárnyalat szerint
|
||||
@@ -5257,6 +5258,8 @@ imageTrace Outline Körvonal
|
||||
Sketch Vázlat
|
||||
Halftone Pattern… Féltónus minta…
|
||||
Halftone Pattern Féltónus minta
|
||||
Torn Edges… Szaggatott szélek…
|
||||
Torn Edges Szaggatott szélek
|
||||
Pattern Type Mintatípus
|
||||
Dot Pont
|
||||
# User Interface › Color Scheme
|
||||
@@ -5352,3 +5355,5 @@ imageTrace Outline Körvonal
|
||||
Water Paper Nedves papír
|
||||
Ruby… Ruby…
|
||||
Ruby Ruby
|
||||
Fresco… Freskó…
|
||||
Fresco Freskó
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2686,6 +2686,7 @@ lighting Light Cahaya
|
||||
Luminosity Luminositas
|
||||
Overlay Menimpa
|
||||
Soft Light Cahaya lembut
|
||||
Soft Mix Campuran lembut
|
||||
Crosshatch Arsir silang
|
||||
Fine Dots Titik halus
|
||||
|
||||
@@ -5132,6 +5133,8 @@ swatch Bright Violet Violet cerah
|
||||
Sketch Sketsa
|
||||
Halftone Pattern… Pola halftone…
|
||||
Halftone Pattern Pola halftone
|
||||
Torn Edges… Tepi robek…
|
||||
Torn Edges Tepi robek
|
||||
Pattern Type Jenis pola
|
||||
Dot Titik
|
||||
Export Type: Jenis ekspor:
|
||||
@@ -5339,3 +5342,5 @@ swatch Bright Violet Violet cerah
|
||||
Water Paper Kertas Basah
|
||||
Ruby… Ruby…
|
||||
Ruby Ruby
|
||||
Fresco… Fresko…
|
||||
Fresco Fresko
|
||||
|
Can't render this file because it contains an unexpected character in line 3809 and column 19.
|
@@ -3104,6 +3104,7 @@ mark-style Japanese Giapponese
|
||||
Snapping Tolerance Tolleranza di aggancio
|
||||
Social Square Post 1080×1080 Post quadrato per social 1080×1080
|
||||
Soft Light Luce soffusa
|
||||
Soft Mix Miscela soffice
|
||||
Solid Pieno
|
||||
Sort by Kind Ordina per tipo
|
||||
Sort by Name Ordina per nome
|
||||
@@ -4885,6 +4886,8 @@ lighting Light Luce
|
||||
Sketch Schizzo
|
||||
Halftone Pattern… Pattern mezzetinte…
|
||||
Halftone Pattern Pattern mezzetinte
|
||||
Torn Edges… Bordi strappati…
|
||||
Torn Edges Bordi strappati
|
||||
Pattern Type Tipo di pattern
|
||||
Dot Punto
|
||||
# User Interface › Color Scheme
|
||||
@@ -4981,3 +4984,5 @@ lighting Light Luce
|
||||
Water Paper Carta bagnata
|
||||
Ruby… Ruby…
|
||||
Ruby Ruby
|
||||
Fresco… Affresco…
|
||||
Fresco Affresco
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2872,6 +2872,7 @@ mark-style Japanese 日本式
|
||||
Snap to Unit 単位にスナップ
|
||||
Snapping Tolerance スナップ許容値
|
||||
Soft Light ソフトライト
|
||||
Soft Mix ソフトミックス
|
||||
Solid 実線
|
||||
Sort by Kind 種類順に並べ替え
|
||||
Sort by Name 名前順に並べ替え
|
||||
@@ -4925,6 +4926,8 @@ lighting Light ライト
|
||||
Sketch スケッチ
|
||||
Halftone Pattern… ハーフトーンパターン…
|
||||
Halftone Pattern ハーフトーンパターン
|
||||
Torn Edges… 破れたエッジ…
|
||||
Torn Edges 破れたエッジ
|
||||
Pattern Type パターンタイプ
|
||||
Dot ドット
|
||||
# User Interface › Color Scheme
|
||||
@@ -5028,3 +5031,5 @@ lighting Light ライト
|
||||
Yonroku-ban 四六判
|
||||
Ruby… ルビ…
|
||||
Ruby ルビ
|
||||
Fresco… フレスコ…
|
||||
Fresco フレスコ
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2498,6 +2498,7 @@ lighting Light სინათლე
|
||||
Luminosity ნათება
|
||||
Overlay გადაფარვა
|
||||
Soft Light რბილი სინათლე
|
||||
Soft Mix რბილი შერევა
|
||||
Crosshatch ჯვარედინი დაშტრიხვა
|
||||
Fine Dots წვრილი წერტილები
|
||||
|
||||
@@ -4987,6 +4988,8 @@ imageTrace Outline კონტური
|
||||
Sketch ესკიზი
|
||||
Halftone Pattern… ნახევარტონური პატერნი…
|
||||
Halftone Pattern ნახევარტონური პატერნი
|
||||
Torn Edges… დაგვერძნილი კიდეები…
|
||||
Torn Edges დაგვერძნილი კიდეები
|
||||
Pattern Type პატერნის ტიპი
|
||||
Dot წერტილი
|
||||
Color Scheme ფერის სქემა
|
||||
@@ -5276,3 +5279,5 @@ imageTrace Outline კონტური
|
||||
selects several, or draws one inside an artboard) რამდენიმეს მონიშნავს ან ახალს სამუშაო დაფის შიგნით ხატავს)
|
||||
Ruby… რუბი…
|
||||
Ruby რუბი
|
||||
Fresco… ფრესკა…
|
||||
Fresco ფრესკა
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2866,6 +2866,7 @@ mark-style Japanese 일본식
|
||||
Snap to Unit 단위에 스냅
|
||||
Snapping Tolerance 스냅 허용 오차
|
||||
Soft Light 소프트 라이트
|
||||
Soft Mix 소프트 혼합
|
||||
Solid 단색
|
||||
Sort by Kind 종류별 정렬
|
||||
Sort by Name 이름별 정렬
|
||||
@@ -4848,6 +4849,8 @@ lighting Light 광원
|
||||
Sketch 스케치
|
||||
Halftone Pattern… 하프톤 패턴…
|
||||
Halftone Pattern 하프톤 패턴
|
||||
Torn Edges… 찢어진 가장자리…
|
||||
Torn Edges 찢어진 가장자리
|
||||
Pattern Type 패턴 유형
|
||||
Dot 점
|
||||
# User Interface › Color Scheme
|
||||
@@ -4944,3 +4947,5 @@ lighting Light 광원
|
||||
Water Paper 물 종이
|
||||
Ruby… 루비…
|
||||
Ruby 루비
|
||||
Fresco… 프레스코…
|
||||
Fresco 프레스코
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2700,6 +2700,7 @@ lighting Light Licht
|
||||
Luminosity Luminositeit
|
||||
Overlay Bedekken
|
||||
Soft Light Zacht licht
|
||||
Soft Mix Zachte menging
|
||||
Crosshatch Kruisarcering
|
||||
Fine Dots Fijne stippen
|
||||
|
||||
@@ -5143,6 +5144,8 @@ swatch Bright Violet Felviolet
|
||||
Sketch Schets
|
||||
Halftone Pattern… Rasterpatroon…
|
||||
Halftone Pattern Rasterpatroon
|
||||
Torn Edges… Gescheurde randen…
|
||||
Torn Edges Gescheurde randen
|
||||
Pattern Type Patroontype
|
||||
Dot Punt
|
||||
Export Type: Exporttype:
|
||||
@@ -5381,3 +5384,5 @@ swatch Bright Violet Felviolet
|
||||
Water Paper Nat papier
|
||||
Ruby… Ruby…
|
||||
Ruby Ruby
|
||||
Fresco… Fresco…
|
||||
Fresco Fresco
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2791,6 +2791,7 @@ lighting Light Światło
|
||||
Luminosity Jasność
|
||||
Overlay Nakładka
|
||||
Soft Light Łagodne światło
|
||||
Soft Mix Miękkie mieszanie
|
||||
Crosshatch Kreskowanie krzyżowe
|
||||
Fine Dots Drobne kropki
|
||||
|
||||
@@ -5123,6 +5124,8 @@ mark-style Japanese Japońskie
|
||||
Sketch Szkic
|
||||
Halftone Pattern… Wzór rastra…
|
||||
Halftone Pattern Wzór rastra
|
||||
Torn Edges… Postrzępione krawędzie…
|
||||
Torn Edges Postrzępione krawędzie
|
||||
Pattern Type Typ wzoru
|
||||
Dot Kropka
|
||||
# User Interface › Color Scheme
|
||||
@@ -5218,3 +5221,5 @@ mark-style Japanese Japońskie
|
||||
Water Paper Mokry papier
|
||||
Ruby… Ruby…
|
||||
Ruby Ruby
|
||||
Fresco… Fresk…
|
||||
Fresco Fresk
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -2542,6 +2542,7 @@
|
||||
Snap to Unit Ajustar à Unidade
|
||||
Snapping Tolerance Tolerância de Ajuste
|
||||
Soft Light Luz Suave
|
||||
Soft Mix Mistura suave
|
||||
Solid Sólido
|
||||
Sort by Kind Ordenar por Tipo
|
||||
Sort by Name Ordenar por Nome
|
||||
@@ -5190,6 +5191,8 @@ mark-style Japanese Japonesas
|
||||
Sketch Esboço
|
||||
Halftone Pattern… Padrão de meio-tom…
|
||||
Halftone Pattern Padrão de meio-tom
|
||||
Torn Edges… Bordas rasgadas…
|
||||
Torn Edges Bordas rasgadas
|
||||
Pattern Type Tipo de padrão
|
||||
Dot Ponto
|
||||
# User Interface › Color Scheme
|
||||
@@ -5283,3 +5286,5 @@ mark-style Japanese Japonesas
|
||||
Water Paper Papel molhado
|
||||
Ruby… Ruby…
|
||||
Ruby Ruby
|
||||
Fresco… Afresco…
|
||||
Fresco Afresco
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -3100,6 +3100,7 @@ mark-style Japanese Японский
|
||||
Snapping Tolerance Допуск привязки
|
||||
Social Square Post 1080×1080 Квадратный пост для соцсетей 1080×1080
|
||||
Soft Light Мягкий свет
|
||||
Soft Mix Мягкое смешение
|
||||
Solid Сплошной
|
||||
Sort by Kind Сортировать по типу
|
||||
Sort by Name Сортировать по имени
|
||||
@@ -4881,6 +4882,8 @@ lighting Light Свет
|
||||
Sketch Эскиз
|
||||
Halftone Pattern… Полутоновый узор…
|
||||
Halftone Pattern Полутоновый узор
|
||||
Torn Edges… Рваные края…
|
||||
Torn Edges Рваные края
|
||||
Pattern Type Тип узора
|
||||
Dot Точка
|
||||
# User Interface › Color Scheme
|
||||
@@ -4977,3 +4980,5 @@ lighting Light Свет
|
||||
Water Paper Мокрая бумага
|
||||
Ruby… Руби…
|
||||
Ruby Руби
|
||||
Fresco… Фреска…
|
||||
Fresco Фреска
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3004,6 +3004,7 @@
|
||||
Snapping Tolerance Fästtolerans
|
||||
Social Square Post 1080×1080 Kvadratiskt inlägg för sociala medier 1080×1080
|
||||
Soft Light Mjukt ljus
|
||||
Soft Mix Mjuk blandning
|
||||
Solid Enfärgad
|
||||
Sort by Kind Sortera efter typ
|
||||
Sort by Name Sortera efter namn
|
||||
@@ -5227,6 +5228,8 @@ theme Appearance Utseende
|
||||
Sketch Skiss
|
||||
Halftone Pattern… Rastermönster…
|
||||
Halftone Pattern Rastermönster
|
||||
Torn Edges… Riviga kanter…
|
||||
Torn Edges Riviga kanter
|
||||
Pattern Type Mönstertyp
|
||||
Dot Punkt
|
||||
# User Interface › Color Scheme
|
||||
@@ -5322,3 +5325,5 @@ theme Appearance Utseende
|
||||
Water Paper Vått papper
|
||||
Ruby… Ruby…
|
||||
Ruby Ruby
|
||||
Fresco… Fresk…
|
||||
Fresco Fresk
|
||||
|
Can't render this file because it contains an unexpected character in line 5 and column 25.
|
@@ -3097,6 +3097,7 @@ effect Points Точки
|
||||
Snapping Tolerance Допуск прив’язки
|
||||
Social Square Post 1080×1080 Квадратний пост для соцмереж 1080×1080
|
||||
Soft Light М’яке світло
|
||||
Soft Mix М’яке змішування
|
||||
Solid Суцільний
|
||||
Sort by Kind Сортувати за типом
|
||||
Sort by Name Сортувати за назвою
|
||||
@@ -4865,6 +4866,8 @@ lighting Light Світло
|
||||
Sketch Ескіз
|
||||
Halftone Pattern… Напівтоновий візерунок…
|
||||
Halftone Pattern Напівтоновий візерунок
|
||||
Torn Edges… Порвані краї…
|
||||
Torn Edges Порвані краї
|
||||
Pattern Type Тип візерунка
|
||||
Dot Крапка
|
||||
# User Interface › Color Scheme
|
||||
@@ -4961,3 +4964,5 @@ lighting Light Світло
|
||||
Water Paper Мокрий папір
|
||||
Ruby… Рубі…
|
||||
Ruby Рубі
|
||||
Fresco… Фреска…
|
||||
Fresco Фреска
|
||||
|
Can't render this file because it contains an unexpected character in line 733 and column 40.
|
@@ -3432,6 +3432,7 @@ mark-style Japanese Kiểu Nhật
|
||||
Social Square Post 1080×1080 Bài đăng vuông mạng xã hội 1080×1080
|
||||
Soft Mềm
|
||||
Soft Light Ánh sáng mềm
|
||||
Soft Mix Trộn mềm
|
||||
Solid Đặc
|
||||
Sort Sắp xếp
|
||||
Sort by Kind Sắp xếp theo loại
|
||||
@@ -4865,6 +4866,8 @@ theme Appearance Giao diện
|
||||
Sketch Phác thảo
|
||||
Halftone Pattern… Mẫu bán sắc…
|
||||
Halftone Pattern Mẫu bán sắc
|
||||
Torn Edges… Cạnh rách…
|
||||
Torn Edges Cạnh rách
|
||||
Pattern Type Loại mẫu
|
||||
Dot Chấm
|
||||
# User Interface › Color Scheme
|
||||
@@ -4961,3 +4964,5 @@ theme Appearance Giao diện
|
||||
Water Paper Giấy ướt
|
||||
Ruby… Ruby…
|
||||
Ruby Ruby
|
||||
Fresco… Bích họa…
|
||||
Fresco Bích họa
|
||||
|
Can't render this file because it contains an unexpected character in line 4021 and column 10.
|
@@ -2938,6 +2938,7 @@ font-script Japanese 汉字
|
||||
Snapping Tolerance 吸附容差
|
||||
Social Square Post 1080×1080 社交方形帖子 1080×1080
|
||||
Soft Light 柔光
|
||||
Soft Mix 柔和混合
|
||||
Solid 实心
|
||||
Sort by Kind 按类型排序
|
||||
Sort by Name 按名称排序
|
||||
@@ -5106,6 +5107,8 @@ lighting Light 光源
|
||||
Sketch 素描
|
||||
Halftone Pattern… 半调图案…
|
||||
Halftone Pattern 半调图案
|
||||
Torn Edges… 撕边…
|
||||
Torn Edges 撕边
|
||||
Pattern Type 图案类型
|
||||
Dot 网点
|
||||
# User Interface › Color Scheme
|
||||
@@ -5205,3 +5208,5 @@ lighting Light 光源
|
||||
Water Paper 水彩画纸
|
||||
Ruby… 注音…
|
||||
Ruby 注音
|
||||
Fresco… 壁画…
|
||||
Fresco 壁画
|
||||
|
Can't render this file because it contains an unexpected character in line 2 and column 73.
|
@@ -3844,6 +3844,7 @@ font-script Japanese 漢字
|
||||
Snapping Tolerance 靠齊容許度
|
||||
Social Square Post 1080×1080 社群正方形貼文 1080×1080
|
||||
Soft Light 柔光
|
||||
Soft Mix 柔和混合
|
||||
Solid 實心
|
||||
Sort by Kind 依類型排序
|
||||
Sort by Name 依名稱排序
|
||||
@@ -4916,6 +4917,8 @@ lighting Light 光源
|
||||
Sketch 素描
|
||||
Halftone Pattern… 半色調圖樣…
|
||||
Halftone Pattern 半色調圖樣
|
||||
Torn Edges… 撕裂邊緣…
|
||||
Torn Edges 撕裂邊緣
|
||||
Pattern Type 圖樣類型
|
||||
Dot 網點
|
||||
# User Interface › Color Scheme
|
||||
@@ -5000,3 +5003,5 @@ lighting Light 光源
|
||||
Water Paper 水彩畫紙
|
||||
Ruby… 注音…
|
||||
Ruby 注音
|
||||
Fresco… 壁畫…
|
||||
Fresco 壁畫
|
||||
|
Can't render this file because it contains an unexpected character in line 6 and column 47.
|
@@ -77,7 +77,7 @@ pub(crate) fn paint_thumb(ui: &Ui, st: &DocState, a: &ExportAsset, r: Rect) {
|
||||
rr.borrow_mut().render_node_thumbnail_with(&st.doc, &group, px, None, &opts)
|
||||
}
|
||||
})?;
|
||||
let color = egui::ColorImage::from_rgba_premultiplied([img.width as usize, img.height as usize], &img.pixels);
|
||||
let color = crate::canvas::color_image(&img);
|
||||
let tex = ui.ctx().load_texture(format!("asset-thumb-{}", a.id), color, egui::TextureOptions::LINEAR);
|
||||
CACHE.with(|c| {
|
||||
let mut c = c.borrow_mut();
|
||||
|
||||
@@ -769,6 +769,11 @@ pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
if menu_item(ui, tl!("Proportional Metrics"), has, proportional) {
|
||||
format(app, json!({"proportionalMetrics": !proportional}));
|
||||
}
|
||||
// Tate-chu-yoko: the selected characters stand side by side across one em of a vertical column.
|
||||
let tcy = s.as_ref().is_some_and(|s| s.tate_chu_yoko);
|
||||
if menu_item(ui, tl!("Tate-chu-yoko"), has, tcy) {
|
||||
format(app, json!({"tateChuYoko": !tcy}));
|
||||
}
|
||||
ui.separator();
|
||||
}
|
||||
// Digits: the numeral system the selected characters' digits are drawn in, with the Middle
|
||||
@@ -807,9 +812,14 @@ pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
}
|
||||
app.run("type.fractionalWidths", p).ok();
|
||||
}
|
||||
for l in ["Standard Vertical Roman Alignment", "Tate-chu-yoko", "System Layout"] {
|
||||
menu_item(ui, tl!(l), false, false);
|
||||
// System Layout: whole-point spacing for every text object in the document. It does not need
|
||||
// a type selection; a document is enough.
|
||||
let open = app.session.active().is_some();
|
||||
let system = app.session.active().is_some_and(|st| st.doc.setup.system_layout);
|
||||
if menu_item(ui, tl!("System Layout"), open, system) {
|
||||
app.run("type.systemLayout", json!({})).ok();
|
||||
}
|
||||
menu_item(ui, tl!("Standard Vertical Roman Alignment"), false, false);
|
||||
ui.separator();
|
||||
// The installed fonts are always listed; this picks up fonts installed since the app started.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
@@ -837,7 +847,7 @@ fn fractional_widths_on(app: &VectorcraftApp) -> bool {
|
||||
/// Reset Panel: the characters the panel acts on ([`char_cmd`]) take tracking 0, Auto leading and
|
||||
/// kerning, no baseline shift, 100% scales, no rotation, no underline or strikethrough, All Caps
|
||||
/// and Small Caps off, the normal position (neither superscript nor subscript), Roman Baseline
|
||||
/// character alignment, Proportional Metrics and No Break off and the Default digits, whether
|
||||
/// character alignment, Proportional Metrics, Tate-chu-yoko and No Break off and the Default digits, whether
|
||||
/// or not Show East Asian Options and Show Indic Options are on.
|
||||
fn reset_panel(app: &mut VectorcraftApp) {
|
||||
let d = CharStyle::default();
|
||||
@@ -847,7 +857,7 @@ fn reset_panel(app: &mut VectorcraftApp) {
|
||||
json!({
|
||||
"kerning": "auto", "baselineShift": 0, "hScale": 100, "vScale": 100, "rotation": 0, "underline": false, "strikethrough": false,
|
||||
"allCaps": false, "smallCaps": d.small_caps.is_some(), "position": d.position.id(), "charAlign": d.char_align,
|
||||
"proportionalMetrics": d.proportional_metrics, "noBreak": d.no_break, "digits": d.digits
|
||||
"proportionalMetrics": d.proportional_metrics, "tateChuYoko": d.tate_chu_yoko, "noBreak": d.no_break, "digits": d.digits
|
||||
}),
|
||||
);
|
||||
}
|
||||
@@ -1163,6 +1173,38 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
/// Character panel menu › System Layout is off for a new document, and a click turns whole-point
|
||||
/// spacing on and back off for every text object.
|
||||
#[test]
|
||||
fn system_layout_menu_item_toggles_the_document() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.run("file.new", json!({"width": 300, "height": 200})).unwrap();
|
||||
let id = app.run("text.create", json!({"x": 20, "y": 50, "text": "Hi", "size": 13})).unwrap()["id"].as_u64().unwrap();
|
||||
let ctx = egui::Context::default();
|
||||
let on = |app: &VectorcraftApp| {
|
||||
let st = app.session.active().unwrap();
|
||||
let object = match &st.doc.node(NodeId(id)).unwrap().kind {
|
||||
NodeKind::Text(t) => t.system_layout,
|
||||
_ => panic!("text"),
|
||||
};
|
||||
(st.doc.setup.system_layout, object)
|
||||
};
|
||||
let row = |app: &mut VectorcraftApp| {
|
||||
let texts = super::super::tests_appearance::frame_events(&ctx, app, vec![], menu);
|
||||
texts.into_iter().find(|(t, _)| t.trim_start_matches(['✓', ' ']) == "System Layout")
|
||||
};
|
||||
assert_eq!(on(&app), (false, false));
|
||||
assert!(row(&mut app).is_some_and(|(t, _)| !t.starts_with('✓')));
|
||||
let at = row(&mut app).unwrap().1;
|
||||
super::super::tests_appearance::click(&ctx, &mut app, at.center(), menu);
|
||||
assert_eq!(on(&app), (true, true));
|
||||
assert!(row(&mut app).is_some_and(|(t, _)| t.starts_with('✓')));
|
||||
let at = row(&mut app).unwrap().1;
|
||||
super::super::tests_appearance::click(&ctx, &mut app, at.center(), menu);
|
||||
assert_eq!(on(&app), (false, false));
|
||||
assert!(row(&mut app).is_some_and(|(t, _)| !t.starts_with('✓')));
|
||||
}
|
||||
|
||||
/// Character panel menu › Fractional Widths is on for new type, and a click turns it off and
|
||||
/// back on for the whole type object.
|
||||
#[test]
|
||||
@@ -1208,6 +1250,34 @@ mod tests {
|
||||
assert_eq!(shown(&mut app), (true, true));
|
||||
}
|
||||
|
||||
/// Tate-chu-yoko is in the panel menu with the East Asian options, and choosing it marks the
|
||||
/// selected characters.
|
||||
#[test]
|
||||
fn tate_chu_yoko_menu_item_shows_with_east_asian_options_and_toggles() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
app.run("file.new", json!({"width": 300, "height": 200})).unwrap();
|
||||
let id = app.session.execute("text.create", &json!({"x": 20, "y": 50, "text": "2026"})).unwrap()["id"].as_u64().unwrap();
|
||||
app.session.execute("select.set", &json!({"ids": [id]})).unwrap();
|
||||
let ctx = egui::Context::default();
|
||||
let painted = |app: &mut VectorcraftApp| crate::tests_labels::painted_text(app, menu);
|
||||
assert!(!painted(&mut app).contains("Tate-chu-yoko"));
|
||||
app.session.prefs.show_east_asian_options = true;
|
||||
let on = |app: &VectorcraftApp| match &app.session.active().unwrap().doc.node(NodeId(id)).unwrap().kind {
|
||||
NodeKind::Text(t) => t.runs.iter().all(|r| r.style.tate_chu_yoko),
|
||||
_ => panic!("text"),
|
||||
};
|
||||
assert!(!on(&app));
|
||||
let texts = super::super::tests_appearance::frame_events(&ctx, &mut app, vec![], menu);
|
||||
let at = texts.iter().find(|(t, _)| t.trim_start_matches(['✓', ' ']) == "Tate-chu-yoko").unwrap_or_else(|| panic!("{texts:?}")).1;
|
||||
super::super::tests_appearance::click(&ctx, &mut app, at.center(), menu);
|
||||
assert!(on(&app));
|
||||
assert!(painted(&mut app).contains("✓ Tate-chu-yoko"));
|
||||
let texts = super::super::tests_appearance::frame_events(&ctx, &mut app, vec![], menu);
|
||||
let at = texts.iter().find(|(t, _)| t.trim_start_matches(['✓', ' ']) == "Tate-chu-yoko").unwrap().1;
|
||||
super::super::tests_appearance::click(&ctx, &mut app, at.center(), menu);
|
||||
assert!(!on(&app));
|
||||
}
|
||||
|
||||
/// Digits is in the panel menu with the Middle Eastern (Indic) options only, as Paragraph
|
||||
/// Direction is in the Paragraph panel.
|
||||
#[test]
|
||||
@@ -1251,8 +1321,8 @@ mod tests {
|
||||
|
||||
/// Reset Panel sets every character attribute the panel shows, except the font family, style
|
||||
/// and size, back to its default (Small Caps, the position, Character Alignment, Proportional
|
||||
/// Metrics, No Break and Digits included), in the selected type and in the text the Type tool
|
||||
/// has selected while it edits.
|
||||
/// Metrics, Tate-chu-yoko, No Break and Digits included), in the selected type and in the text
|
||||
/// the Type tool has selected while it edits.
|
||||
#[test]
|
||||
fn reset_panel_resets_every_attribute_but_the_font() {
|
||||
let mut app = VectorcraftApp::new(Session::new(), Default::default());
|
||||
@@ -1278,6 +1348,7 @@ mod tests {
|
||||
s.position != d.position,
|
||||
s.char_align != d.char_align,
|
||||
s.proportional_metrics != d.proportional_metrics,
|
||||
s.tate_chu_yoko != d.tate_chu_yoko,
|
||||
s.no_break != d.no_break,
|
||||
s.digits != d.digits,
|
||||
]
|
||||
@@ -1288,16 +1359,16 @@ mod tests {
|
||||
json!({
|
||||
"id": id, "tracking": 50, "leading": 30, "kerning": 20, "baselineShift": 3, "hScale": 120, "vScale": 90, "rotation": 15,
|
||||
"underline": true, "strikethrough": true, "allCaps": true, "smallCaps": true, "position": "superscript",
|
||||
"charAlign": "emBoxCenter", "proportionalMetrics": true, "noBreak": true, "digits": "hindi"
|
||||
"charAlign": "emBoxCenter", "proportionalMetrics": true, "tateChuYoko": true, "noBreak": true, "digits": "hindi"
|
||||
}),
|
||||
)
|
||||
.unwrap();
|
||||
};
|
||||
let plain = runs(&app)[0].1.clone();
|
||||
assert_eq!(differs(&plain, &CharStyle::default()), [false; 16]);
|
||||
assert_eq!(differs(&plain, &CharStyle::default()), [false; 17]);
|
||||
custom(&mut app);
|
||||
let styled = runs(&app)[0].1.clone();
|
||||
assert_eq!(differs(&styled, &CharStyle::default()), [true; 16]);
|
||||
assert_eq!(differs(&styled, &CharStyle::default()), [true; 17]);
|
||||
app.run("select.set", json!({"ids": [id]})).unwrap();
|
||||
reset_panel(&mut app);
|
||||
assert_eq!(runs(&app), [("One 12".to_string(), plain.clone())]);
|
||||
|
||||
@@ -349,7 +349,7 @@ fn render(
|
||||
}
|
||||
}
|
||||
}
|
||||
egui::ColorImage::from_rgba_premultiplied([img.width as usize, img.height as usize], &img.pixels)
|
||||
crate::canvas::color_image(&img)
|
||||
}
|
||||
|
||||
pub fn menu(app: &mut VectorcraftApp, ui: &mut Ui) {
|
||||
|
||||
@@ -171,7 +171,7 @@ fn render(app: &VectorcraftApp, paints: Paints, g: &GraphicStyle, preview: Previ
|
||||
let layer = doc.layers[0].id;
|
||||
doc.insert(Some(layer), 0, app.session.styled(&shape, g)).ok()?;
|
||||
let img = RENDERER.with(|r| r.borrow_mut().render_region(&doc, vectorcraft_geom::Rect::new(0.0, 0.0, SIDE, SIDE), px as f64 / SIDE, true));
|
||||
Some(egui::ColorImage::from_rgba_premultiplied([img.width as usize, img.height as usize], &img.pixels))
|
||||
Some(crate::canvas::color_image(&img))
|
||||
}
|
||||
|
||||
/// The thumbnail of style `g` (`look`: its [`look_hash`]) at `size` points.
|
||||
@@ -239,7 +239,7 @@ fn object_preview(app: &VectorcraftApp, ctx: &egui::Context, g: &GraphicStyle, l
|
||||
}
|
||||
let styled = app.session.styled(n, g);
|
||||
let img = RENDERER.with(|r| r.borrow_mut().render_node_thumbnail(&st.doc, &styled, px, Some([255; 4])))?;
|
||||
let color = egui::ColorImage::from_rgba_premultiplied([img.width as usize, img.height as usize], &img.pixels);
|
||||
let color = crate::canvas::color_image(&img);
|
||||
let tex = ctx.load_texture("gs-large-object", color, egui::TextureOptions::LINEAR);
|
||||
ctx.data_mut(|d| d.insert_temp(slot, (key, tex.clone())));
|
||||
Some(tex)
|
||||
|
||||
@@ -1408,7 +1408,7 @@ fn small_node(n: &Node, limit: usize) -> bool {
|
||||
impl Thumbs {
|
||||
/// Keep `img` (None: nothing drawn) as the thumbnail of row `key` showing `node`.
|
||||
fn upload(&mut self, ctx: &egui::Context, key: (u64, NodeId), node: Weak<Node>, px: u32, img: Option<&vectorcraft_render::Rendered>, ms: f64) {
|
||||
let color = img.map(|img| egui::ColorImage::from_rgba_premultiplied([img.width as usize, img.height as usize], &img.pixels));
|
||||
let color = img.map(crate::canvas::color_image);
|
||||
let used = ctx.cumulative_pass_nr();
|
||||
let name = format!("layer-thumb-{}", key.1.0);
|
||||
match self.entries.get_mut(&key) {
|
||||
|
||||
@@ -54,7 +54,7 @@ thread_local! {
|
||||
impl Cache {
|
||||
/// Upload image `r` showing `key` over `region`.
|
||||
fn upload(&mut self, ctx: &egui::Context, key: ImageKey, region: DRect, r: &vectorcraft_render::Rendered, ms: f64) {
|
||||
let img = egui::ColorImage::from_rgba_premultiplied([r.width as usize, r.height as usize], &r.pixels);
|
||||
let img = crate::canvas::color_image(r);
|
||||
match &mut self.tex {
|
||||
Some(tx) => tx.set(img, egui::TextureOptions::LINEAR),
|
||||
None => self.tex = Some(ctx.load_texture("navigator", img, egui::TextureOptions::LINEAR)),
|
||||
|
||||
@@ -194,7 +194,7 @@ fn pattern_thumb(app: &VectorcraftApp, ui: &Ui, r: Rect, paint: &Paint) {
|
||||
);
|
||||
let tex = CACHE.with(|c| c.borrow().get(&key).cloned()).unwrap_or_else(|| {
|
||||
let tex = vectorcraft_render::render_pattern_swatch(&st.doc, pattern, px).map(|img| {
|
||||
let color = egui::ColorImage::from_rgba_premultiplied([img.width as usize, img.height as usize], &img.pixels);
|
||||
let color = crate::canvas::color_image(&img);
|
||||
ui.ctx().load_texture(format!("pattern-swatch-{pattern}-{px}"), color, egui::TextureOptions::LINEAR)
|
||||
});
|
||||
CACHE.with(|c| {
|
||||
|
||||
@@ -38,7 +38,7 @@ fn thumb(ui: &Ui, doc: &Document, name: &str, size: f32) -> Option<egui::Texture
|
||||
let l = d.layers[0].id;
|
||||
d.insert(Some(l), 0, Node::new(id, NodeKind::SymbolInstance { symbol: name.into(), xf })).ok()?;
|
||||
let img = RENDERER.with(|r| r.borrow_mut().render_thumbnail(&d, id, px))?;
|
||||
let color = egui::ColorImage::from_rgba_premultiplied([img.width as usize, img.height as usize], &img.pixels);
|
||||
let color = crate::canvas::color_image(&img);
|
||||
let tex = ui.ctx().load_texture(format!("sym-{name}-{px}"), color, egui::TextureOptions::LINEAR);
|
||||
CACHE.with(|c| {
|
||||
let mut c = c.borrow_mut();
|
||||
|
||||
@@ -263,7 +263,7 @@ fn node_thumb(app: &VectorcraftApp, ui: &Ui, slot: &str, n: &vectorcraft_doc::No
|
||||
let tex = match cached {
|
||||
Some((k, rev, tex)) if k == key && (rev == st.revision || busy) => Some(tex),
|
||||
_ => RENDERER.with(|rr| rr.borrow_mut().render_node_thumbnail_with(&st.doc, n, px, bg, &super::layers::thumb_options())).map(|img| {
|
||||
let color = egui::ColorImage::from_rgba_premultiplied([img.width as usize, img.height as usize], &img.pixels);
|
||||
let color = crate::canvas::color_image(&img);
|
||||
let tex = ui.ctx().load_texture(slot, color, egui::TextureOptions::LINEAR);
|
||||
ui.ctx().data_mut(|d| d.insert_temp(slot_id, (key, st.revision, tex.clone())));
|
||||
tex
|
||||
|
||||
@@ -93,6 +93,7 @@ fn effect_menu_lists_the_artistic_filters_before_blur() {
|
||||
"Cutout…",
|
||||
"Dry Brush…",
|
||||
"Film Grain…",
|
||||
"Fresco…",
|
||||
"Neon Glow…",
|
||||
"Paint Daubs…",
|
||||
"Palette Knife…",
|
||||
@@ -107,7 +108,7 @@ fn effect_menu_lists_the_artistic_filters_before_blur() {
|
||||
);
|
||||
assert!(artistic.iter().all(|e| e.command.as_deref() == Some("effect.dialog")));
|
||||
assert_eq!(artistic[2].params, json!({"effect": "artistic.dryBrush"}));
|
||||
assert_eq!(artistic[4].params, json!({"effect": "artistic.neonGlow"}));
|
||||
assert_eq!(artistic[5].params, json!({"effect": "artistic.neonGlow"}));
|
||||
let at = |name: &str| entries.iter().position(|e| e.path == ["Effect", name]).unwrap();
|
||||
assert!(at("Artistic") < at("Blur"));
|
||||
}
|
||||
@@ -227,6 +228,7 @@ fn effect_menu_lists_the_sketch_filters_between_sharpen_and_stylize() {
|
||||
"Plaster…",
|
||||
"Reticulation…",
|
||||
"Stamp…",
|
||||
"Torn Edges…",
|
||||
"Water Paper…"
|
||||
]
|
||||
);
|
||||
@@ -242,14 +244,15 @@ fn effect_menu_lists_the_sketch_filters_between_sharpen_and_stylize() {
|
||||
assert_eq!(sketch[8].params, json!({"effect": "sketch.plaster"}));
|
||||
assert_eq!(sketch[9].params, json!({"effect": "sketch.reticulation"}));
|
||||
assert_eq!(sketch[10].params, json!({"effect": "sketch.stamp"}));
|
||||
assert_eq!(sketch[11].params, json!({"effect": "sketch.waterPaper"}));
|
||||
assert_eq!(sketch[11].params, json!({"effect": "sketch.tornEdges"}));
|
||||
assert_eq!(sketch[12].params, json!({"effect": "sketch.waterPaper"}));
|
||||
let at = |label: &str| entries.iter().position(|e| e.path[0] == "Effect" && e.label == label).unwrap();
|
||||
assert!(at("Unsharp Mask…") < at("Bas Relief…") && at("Bas Relief…") < at("Chalk & Charcoal…"));
|
||||
assert!(at("Chalk & Charcoal…") < at("Chrome…"));
|
||||
assert!(at("Chrome…") < at("Graphic Pen…") && at("Graphic Pen…") < at("Halftone Pattern…"));
|
||||
assert!(at("Halftone Pattern…") < at("Note Paper…") && at("Note Paper…") < at("Plaster…"));
|
||||
assert!(at("Plaster…") < at("Reticulation…"));
|
||||
assert!(at("Reticulation…") < at("Water Paper…") && at("Water Paper…") < at("Glowing Edges…"));
|
||||
assert!(at("Reticulation…") < at("Torn Edges…") && at("Torn Edges…") < at("Water Paper…") && at("Water Paper…") < at("Glowing Edges…"));
|
||||
}
|
||||
|
||||
/// Effect › Stylize under Raster Effects, between Sharpen and Texture: Glowing Edges opens its
|
||||
|
||||
@@ -2242,7 +2242,7 @@ pub fn doc_preview(ui: &Ui, key: &str, size: Vec2, build: impl FnOnce(f64, f64)
|
||||
}
|
||||
let doc = build(w, h)?;
|
||||
let img = RENDERER.with(|r| r.borrow_mut().render_region(&doc, vectorcraft_geom::Rect::new(0.0, 0.0, w, h), ppp, false));
|
||||
let color = egui::ColorImage::from_rgba_premultiplied([img.width as usize, img.height as usize], &img.pixels);
|
||||
let color = crate::canvas::color_image(&img);
|
||||
let tex = ui.ctx().load_texture(format!("preview-{key}"), color, egui::TextureOptions::LINEAR);
|
||||
CACHE.with(|c| {
|
||||
let mut c = c.borrow_mut();
|
||||
@@ -2469,7 +2469,7 @@ pub fn region_texture(
|
||||
) -> egui::TextureHandle {
|
||||
let scale = px / region.width().max(region.height()).max(1.0);
|
||||
let img = renderer.render_region(doc, region, scale, true);
|
||||
let color = egui::ColorImage::from_rgba_premultiplied([img.width as usize, img.height as usize], &img.pixels);
|
||||
let color = crate::canvas::color_image(&img);
|
||||
ctx.load_texture(name, color, egui::TextureOptions::LINEAR)
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ Part of [target-app-parity.md](target-app-parity.md); open work is in [gaps.md](
|
||||
| Group | Illustrator | VectorCraft | % | Remaining (h) |
|
||||
|---|---:|---:|---:|---:|
|
||||
| Illustrator effects (vector and stylize) | 50 | 46 | 92% | 6–10 |
|
||||
| Photoshop effects (raster, Effect Gallery) | 57 | 52 | 91% | 4–6 |
|
||||
| Photoshop effects (raster, Effect Gallery) | 57 | 54 | 95% | 2–4 |
|
||||
| 3D and Materials | 4 (+3 Classic) | 4 (initial: Extrude & Bevel, Revolve, Inflate, Rotate) | ~25% | 25–45 |
|
||||
| Beyond Illustrator: Effect › Color Adjustments (6), effect plug-ins (WebAssembly) | — | 6 + plug-ins | — | — |
|
||||
|
||||
@@ -23,8 +23,8 @@ Part of [target-app-parity.md](target-app-parity.md); open work is in [gaps.md](
|
||||
| Convert to Shape | Rectangle, Rounded Rectangle, Ellipse | 3/3 | — |
|
||||
| Crop Marks | Crop Marks | 1/1 | — |
|
||||
| Distort & Transform | Free Distort, Pucker & Bloat, Roughen, Transform, Tweak, Twist, Zig Zag | 7/7 | Free Distort's dialog has a handle on each corner of the object's bounds, moved by dragging or with the arrow keys; Transform's Transform Objects/Patterns and Scale Strokes & Effects options, invisible Reflect checkboxes (#885); Zig Zag's ridges are evenly spaced along each segment (#1558), and Smooth points make a continuous wave whose peaks and valleys have handles along the path (#2343); Roughen with Smooth keeps turn-backs smooth instead of cusps that draw as spikes (#1646) |
|
||||
| Path | Offset Path, Outline Object, Outline Stroke | 3/3 | — |
|
||||
| Pathfinder | Add, Intersect, Exclude, Subtract, Minus Back, Divide, Trim, Merge, Crop, Outline, Hard Mix, Soft Mix, Trap | 10/13 | Hard Mix, Soft Mix, Trap |
|
||||
| Path | Offset Path, Outline Object, Outline Stroke | 3/3 | With Use Preview Bounds on, Align, Distribute and the Transform panel still measure type that carries Outline Object by its layout box (preview bounds leave out effects) |
|
||||
| Pathfinder | Add, Intersect, Exclude, Subtract, Minus Back, Divide, Trim, Merge, Crop, Outline, Hard Mix, Soft Mix, Trap | 11/13 | Hard Mix, Trap |
|
||||
| Rasterize | Rasterize… (as a live effect) | 1/1 | — |
|
||||
| Stylize | Drop Shadow, Feather, Inner Glow, Outer Glow, Round Corners, Scribble | 6/6 | Scribble Options' Settings presets |
|
||||
| SVG Filters | Apply SVG Filter… and the filter list | 0/1 | the whole submenu (SVG filters on import round-trip already) |
|
||||
@@ -38,13 +38,13 @@ its resolution, PDF export warns once per object with the requested and the lowe
|
||||
|
||||
| Submenu | Items | Ours | Missing |
|
||||
|---|---|---:|---|
|
||||
| Artistic | Colored Pencil, Cutout, Dry Brush, Film Grain, Fresco, Neon Glow, Paint Daubs, Palette Knife, Plastic Wrap, Poster Edges, Rough Pastels, Smudge Stick, Sponge, Underpainting, Watercolor | 14/15 (approximate Colored Pencil, Cutout, Dry Brush, Film Grain, Neon Glow, Paint Daubs, Palette Knife, Plastic Wrap, Poster Edges, Rough Pastels, Smudge Stick, Sponge, Underpainting, Watercolor) | Fresco |
|
||||
| Artistic | Colored Pencil, Cutout, Dry Brush, Film Grain, Fresco, Neon Glow, Paint Daubs, Palette Knife, Plastic Wrap, Poster Edges, Rough Pastels, Smudge Stick, Sponge, Underpainting, Watercolor | 15/15 (approximate Colored Pencil, Cutout, Dry Brush, Film Grain, Fresco, Neon Glow, Paint Daubs, Palette Knife, Plastic Wrap, Poster Edges, Rough Pastels, Smudge Stick, Sponge, Underpainting, Watercolor) | — |
|
||||
| Blur | Gaussian Blur, Radial Blur, Smart Blur | 3/3 | — |
|
||||
| Brush Strokes | Accented Edges, Angled Strokes, Crosshatch, Dark Strokes, Ink Outlines, Spatter, Sprayed Strokes, Sumi-e | 8/8 | — |
|
||||
| Distort | Diffuse Glow, Glass, Ocean Ripple | 3/3 | — |
|
||||
| Pixelate | Color Halftone, Crystallize, Mezzotint, Pointillize | 4/4 | — |
|
||||
| Sharpen | Unsharp Mask | 1/1 | — |
|
||||
| Sketch | Bas Relief, Chalk & Charcoal, Charcoal, Chrome, Conté Crayon, Graphic Pen, Halftone Pattern, Note Paper, Photocopy, Plaster, Reticulation, Stamp, Torn Edges, Water Paper | 12/14 (approximate Bas Relief, Chalk & Charcoal, Charcoal, Chrome, Graphic Pen, Halftone Pattern, Note Paper, Photocopy, Plaster, Reticulation, Stamp, Water Paper; Chalk & Charcoal, Graphic Pen, Note Paper and Water Paper defaults unverified) | Conté Crayon, Torn Edges |
|
||||
| Sketch | Bas Relief, Chalk & Charcoal, Charcoal, Chrome, Conté Crayon, Graphic Pen, Halftone Pattern, Note Paper, Photocopy, Plaster, Reticulation, Stamp, Torn Edges, Water Paper | 13/14 (approximate Bas Relief, Chalk & Charcoal, Charcoal, Chrome, Graphic Pen, Halftone Pattern, Note Paper, Photocopy, Plaster, Reticulation, Stamp, Torn Edges, Water Paper; Chalk & Charcoal, Graphic Pen, Note Paper and Water Paper defaults unverified) | Conté Crayon |
|
||||
| Stylize | Glowing Edges | 1/1 | — |
|
||||
| Texture | Craquelure, Grain, Mosaic Tiles, Patchwork, Stained Glass, Texturizer | 6/6 | — |
|
||||
| Video | De-Interlace, NTSC Colors | 2/2 | — |
|
||||
@@ -52,7 +52,7 @@ its resolution, PDF export warns once per object with the requested and the lowe
|
||||
|
||||
The pixel-filter pipeline (`vectorcraft_effects::pixel`) is in place: each new filter is one function, a
|
||||
catalogue row, a menu entry and translations. Measured throughput: 0.7–1.2 agent hours per filter
|
||||
(see [calibration](target-app-parity.md#calibration)), so the 5 missing filters are ~4–6 h and the Effect
|
||||
(see [calibration](target-app-parity.md#calibration)), so the 3 missing filters are ~2–4 h and the Effect
|
||||
Gallery dialog another 4–6 h. These parallelize well across agents.
|
||||
|
||||
Film Grain (`artistic.filmGrain`, Effect › Artistic) adds stable monochrome noise to shadows and
|
||||
|
||||
+8
-1
@@ -1,6 +1,6 @@
|
||||
# Gaps
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-21 · **Change:** minor (3D: original Standard, Diffuse, Top Left and Right lighting presets; command access, effective-setting recognition and preview/history; scores and estimates unchanged; G1: one selected clip group's Properties panel has Edit Clipping Path and Edit Contents at its top; the selection tools take a clipping path on its outline, over the art it clips; Polygon and Star exact-size placement remembers the chosen count for later drags and dialog openings; Cancel preserves the previous count; Live trace result bounds and selection highlights exclude the retained bitmap except in source-image views; live-effect plug-ins given their object's fills and strokes and the item they sit on, G17; plug-in parameters: labels, units, groups, help and conditions in their dialogs, text and number-list parameters, up to 256 of them, G17; exporter plug-ins: plug-in file formats in Export As and document.export, G17; G2: Effect › Artistic › Smudge Stick, Sponge and Watercolor; Sketch › Bas Relief, Charcoal, Photocopy and Stamp, #2533; Photoshop filters 45/57, 12 remaining (8–14 h); on-canvas Mirror Repeat axis, #2877; G12: Background Export progress dialog with Cancel, #2564; status-readout sample widths cached by language, document unit and pixels per point; status messages and readouts use stable responsive allocations sized for localized labels and ordinary coordinates; cached canvas dimensions match the renderer limit before cache-key creation, view construction and worker submission; cached canvas reprojection preserves scale during resize, rotation and DPI changes; on-canvas Mirror Repeat axis, #2877; G12: Background Export progress dialog with Cancel, #2564; 3D lighting: one to ten colored lights, smooth colored Inflate, legacy white-light appearance preserved; surface batching and restored seam minimum; scores and estimates unchanged; Blend spine Anchor Point conversions, selection/stacking priority and Shift regression coverage (#2544); scores and hours unchanged; transparency grid visibility saved in native documents, #1968; G6: MCP cancellation, progress notifications and busy answers during long exports, #2165, #2171, #2172; EPS editing data: legacy mesh corners, vector opacity masks and compound member paint retained; raster page comparison filters minification without relaxing limits; scores and hours unchanged; correction: quick Image Trace presets leave the panel as it was, the Image Trace button opens it; batch exporting, #1935; G2: Effect › Sketch › Halftone Pattern; Photoshop filters 45/57, 12 remaining (8–14 h); G5: Symbol Options Export Type (Graphic / Movie Clip); G1: Smart Guides line extension, #2120; G16: Brazilian Portuguese catalog complete under the tests, #1914; Localization 71% → 74%, hours 55–90 → 50–85; G6: image variables landed, estimate 8–14 → 6–12 h; Warp Options controls verified by focused checks and original-image review; estimates unchanged; existing-guide Escape cancellation validated 2026-10-14; scores and hours unchanged; open-path anchor Delete keeps surviving runs separate; estimates unchanged; Artboard tab-switch follow-up historically validated on `a0671777`; scores and hours unchanged; Artboard clean active-tab close/Delete follow-up validated 2026-10-15; G13: Object › Intertwine landed, #1763; no entry closed, estimates unchanged; MCP `add_text` exposes the existing `vertical` option for point, area and path type; horizontal remains the default; scores and hours unchanged; Vertical fullwidth question and exclamation marks keep their nominal glyph upright when the font has no vertical alternate; scores and hours unchanged.; G1: Curvature curve geometry, #1236 in part; Width-point finite-arithmetic follow-up validated; scores and hours unchanged; Image Trace adjustment discovery; G9: legacy `.ai` of version 7 saved with type as text and hidden objects kept, legacy type read, #868; estimate unchanged; Revolve: automatic smooth shading and default-on Cap with continuous rims; later 2026-10-14: G8 untrusted files, #1852, #1862–#1873; G11 anchor X/Y/W/H, #1824, Snap to Grid over Snap to Pixel, #1816, redo during a drag, #1719, Dim Images, #1683, failed-save dialog, #1685; gaps noted for reporters: G1 Warp Options for Effect › Warp, #1760, Color Picker Tab order, #1692, key anchor, #1636; G7 custom toolbars, #1759, workspace panel widths, #1753; G11 Shape Builder gaps between closed shapes, #1691, interior anchor delete; G13 Intertwine, #1763, gradient mesh from an image, #1676, Image Trace radial gradients, #1849; G12 duplicated line removed; no entry closed, estimates unchanged; verified PngSuite downloads, #1729; synthetic control-input budgets, #1709; 2026-10-14 fixes: G11 anchor Align and Distribute, #1636, Delete and selection, #1674, #1666, #1743, #1686, Roughen and Scribble, #1643, #1648; G8 file and input hardening, #1776–#1783, #1786, #1807; G10 Wayland cursors aLine truncated
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-21 · **Change:** minor (filter plug-ins read and set effect records and stroke joins, caps and miter limits, G17; 3D: original Standard, Diffuse, Top Left and Right lighting presets; command access, effective-setting recognition and preview/history; scores and estimates unchanged; G1: one selected clip group's Properties panel has Edit Clipping Path and Edit Contents at its top; the selection tools take a clipping path on its outline, over the art it clips; Polygon and Star exact-size placement remembers the chosen count for later drags and dialog openings; Cancel preserves the previous count; Live trace result bounds and selection highlights exclude the retained bitmap except in source-image views; live-effect plug-ins given their object's fills and strokes and the item they sit on, G17; plug-in parameters: labels, units, groups, help and conditions in their dialogs, text and number-list parameters, up to 256 of them, G17; exporter plug-ins: plug-in file formats in Export As and document.export, G17; G2: Effect › Artistic › Smudge Stick, Sponge and Watercolor; Sketch › Bas Relief, Charcoal, Photocopy and Stamp, #2533; Photoshop filters 45/57, 12 remaining (8–14 h); on-canvas Mirror Repeat axis, #2877; G12: Background Export progress dialog with Cancel, #2564; status-readout sample widths cached by language, document unit and pixels per point; status messages and readouts use stable responsive allocations sized for localized labels and ordinary coordinates; cached canvas dimensions match the renderer limit before cache-key creation, view construction and worker submission; cached canvas reprojection preserves scale during resize, rotation and DPI changes; on-canvas Mirror Repeat axis, #2877; G12: Background Export progress dialog with Cancel, #2564; 3D lighting: one to ten colored lights, smooth colored Inflate, legacy white-light appearance preserved; surface batching and restored seam minimum; scores and estimates unchanged; Blend spine Anchor Point conversions, selection/stacking priority and Shift regression coverage (#2544); scores and hours unchanged; transparency grid visibility saved in native documents, #1968; G6: MCP cancellation, progress notifications and busy answers during long exports, #2165, #2171, #2172; EPS editing data: legacy mesh corners, vector opacity masks and compound member paint retained; raster page comparison filters minification without relaxing limits; scores and hours unchanged; correction: quick Image Trace presets leave the panel as it was, the Image Trace button opens it; batch exporting, #1935; G2: Effect › Sketch › Halftone Pattern; Photoshop filters 45/57, 12 remaining (8–14 h); G5: Symbol Options Export Type (Graphic / Movie Clip); G1: Smart Guides line extension, #2120; G16: Brazilian Portuguese catalog complete under the tests, #1914; Localization 71% → 74%, hours 55–90 → 50–85; G6: image variables landed, estimate 8–14 → 6–12 h; Warp Options controls verified by focused checks and original-image review; estimates unchanged; existing-guide Escape cancellation validated 2026-10-14; scores and hours unchanged; open-path anchor Delete keeps surviving runs separate; estimates unchanged; Artboard tab-switch follow-up historically validated on `a0671777`; scores and hours unchanged; Artboard clean active-tab close/Delete follow-up validated 2026-10-15; G13: Object › Intertwine landed, #1763; no entry closed, estimates unchanged; MCP `add_text` exposes the existing `vertical` option for point, area and path type; horizontal remains the default; scores and hours unchanged; Vertical fullwidth question and exclamation marks keep their nominal glyph upright when the font has no vertical alternate; scores and hours unchanged.; G1: Curvature curve geometry, #1236 in part; Width-point finite-arithmetic follow-up validated; scores and hours unchanged; Image Trace adjustment discovery; G9: legacy `.ai` of version 7 saved with type as text and hidden objects kept, legacy type read, #868; estimate unchanged; Revolve: automatic smooth shading and default-on Cap with continuous rims; later 2026-10-14: G8 untrusted files, #1852, #1862–#1873; G11 anchor X/Y/W/H, #1824, Snap to Grid over Snap to Pixel, #1816, redo during a drag, #1719, Dim Images, #1683, failed-save dialog, #1685; gaps noted for reporters: G1 Warp Options for Effect › Warp, #1760, Color Picker Tab order, #1692, key anchor, #1636; G7 custom toolbars, #1759, workspace panel widths, #1753; G11 Shape Builder gaps between closed shapes, #1691, interior anchor delete; G13 Intertwine, #1763, gradient mesh from an image, #1676, Image Trace radial gradients, #1849; G12 duplicated line removed; no entry closed, estimates unchanged; verified PngSuite downloads, #1729; synthetic control-input budgets, #1709; 2026-10-14 fixes: G11 anchor Align and Distribute, #1636, Delete and selection, #1674, #1666, #1743, #1686, Roughen and Scribble, #16Line truncated
|
||||
|
||||
Every known shortfall against Illustrator, one entry each, **ranked by how much it stops a professional from
|
||||
switching**. This is the work list: unless you were given a task, pick the highest-ranked gap you can make
|
||||
@@ -236,6 +236,8 @@ from G14 and the budget run of G15: **~170–270 h** one agent, ~50–80 h wall
|
||||
- **Done:** Effect › Texture › Texturizer › Load Texture… (stored grayscale `textureImage`, Loaded Texture in the Texture menu), matching Glass.
|
||||
- **Missing:** 8 of 57 filters (5 Artistic, 2 Sketch and 1 more), the Effect Gallery dialog. Measured in
|
||||
[effects-parity.md](effects-parity.md).
|
||||
- **Done:** the pixel-filter pipeline and 46 filters (Artistic: Cutout, Film Grain, Neon Glow, Plastic Wrap, Poster Edges, Smudge Stick, Sponge, Watercolor; Blur, Brush Strokes, Distort, Pixelate, Sharpen; Sketch:
|
||||
Bas Relief, Chalk & Charcoal, Charcoal, Chrome, Graphic Pen, Halftone Pattern, Photocopy, Plaster, Reticulation, Stamp, Torn Edges; Stylize, Texture, Video), with live preview and editable native settings. Smart Blur supports Edge Only and Overlay Edge
|
||||
- **Done:** Effect › Artistic › Colored Pencil (`artistic.coloredPencil`, pencil width, stroke pressure, paper brightness; original visual approximation).
|
||||
- **Done:** the pixel-filter pipeline and 49 filters (Artistic: Colored Pencil, Cutout, Dry Brush, Film Grain, Neon Glow, Plastic Wrap, Poster Edges, Smudge Stick, Sponge, Watercolor; Blur, Brush Strokes, Distort, Pixelate, Sharpen; Sketch:
|
||||
Bas Relief, Chalk & Charcoal, Charcoal, Chrome, Graphic Pen, Halftone Pattern, Note Paper, Photocopy, Plaster, Reticulation, Stamp, Water Paper; Stylize, Texture, Video), with live preview and editable native settings. Smart Blur supports Edge Only and Overlay Edge
|
||||
@@ -353,6 +355,10 @@ from G14 and the budget run of G15: **~170–270 h** one agent, ~50–80 h wall
|
||||
regressions.
|
||||
- **Done:** a live effect is given its object's fills and strokes, read only, as a filter is, and `_context.item`
|
||||
says which fill or stroke it sits on; a change of paint runs it again. Engine and unit regressions.
|
||||
- **Done:** a filter is given its objects' effect records and their strokes' join, cap and miter limit, and may
|
||||
return both: the records are admitted as `effect.apply` admits them (one refused refuses the output), so a tool can
|
||||
set up objects for a live effect in one step. A path a filter hands back unchanged stays a live shape. Engine and
|
||||
unit regressions.
|
||||
- **Estimate:** 20–45 h for the APIs; the ecosystem itself isn't agent work.
|
||||
|
||||
## G18 Generative AI features
|
||||
@@ -378,6 +384,7 @@ from G14 and the budget run of G15: **~170–270 h** one agent, ~50–80 h wall
|
||||
| 2026-10-20 | minor | G1: for the selection tools, a press within the selection tolerance of a clipping path's outline (a clip group's, or a layer's clipping mask) hits the clipping path before the art it clips, so Direct Selection takes its segments and the Selection tool the clip group even where the art lies over the mask's edge; Select Behind lists the same; the eyedropper and the tools that act on what is drawn are unchanged. Doc and tool regression tests. No entry closed, estimates unchanged. |
|
||||
| 2026-10-20 | minor | Polygon and Star exact-size placement remembers the chosen count for later drags and dialog openings; Cancel preserves the previous count; existing opening gestures retained; scores and hours unchanged. |
|
||||
| 2026-10-20 | minor | Live trace result bounds and selection highlights exclude the retained bitmap except in source-image views; scores and hours unchanged. |
|
||||
| 2026-10-19 | minor | G17: filter plug-ins read and set their objects' effect records (admitted as `effect.apply` admits them) and strokes' joins, caps and miter limits; a path handed back unchanged stays a live shape; engine and unit regressions. No entry closed, estimates unchanged. |
|
||||
| 2026-10-19 | minor | G17: live-effect plug-ins are given their object's fills and strokes, read only, and the item they sit on; engine and unit regressions. No entry closed, estimates unchanged. |
|
||||
| 2026-10-19 | minor | G17: plug-in parameters with labels, units, help, groups and conditions (`visibleWhen`), `string` and `numberList` types, up to 256 per plug-in; manifest and kittest dialog regressions. No entry closed, estimates unchanged. |
|
||||
| 2026-10-19 | minor | G17: exporter plug-ins, plug-in file formats that Export As and `document.export` write; engine, ABI and headless Export As regressions. No entry closed, estimates unchanged. |
|
||||
|
||||
+21
-5
@@ -183,7 +183,9 @@ type and `blob` but without their data, which follows the JSON in a saved file;
|
||||
"strokes": [{"paint": {"type": "gradient", "gradient": {"kind": "Linear", "stops": [
|
||||
{"offset": 0, "color": {"model": "gray", "k": 0}},
|
||||
{"offset": 1, "color": {"model": "cmyk", "c": 0, "m": 0.5, "y": 1, "k": 0}}]}, "angle": 0},
|
||||
"width": 2}],
|
||||
"width": 2, "join": "round", "cap": "butt", "miterLimit": 10}],
|
||||
"effects": [{"id": "distort.roughen", "params": {"detail": 10, "points": "smooth", "relative": true, "seed": 0,
|
||||
"size": 5}, "visible": true}],
|
||||
"opacity": 1,
|
||||
"bounds": [10, 0, 75, 60]}
|
||||
]}
|
||||
@@ -192,12 +194,16 @@ type and `blob` but without their data, which follows the JSON in a saved file;
|
||||
- `type`: `"path"` or `"compound"` (a compound path: `path` holds its members' subpaths, painted as one).
|
||||
- `path`: VectorCraft's own path form. Each subpath is a run of anchors; `p` is the anchor, `in` / `out` its handles
|
||||
(absent: no handle), `kind` `"Smooth"` when the handles stay collinear. Coordinates are points, y down.
|
||||
- `fills`, `strokes`: the object's fills and strokes in paint order (bottom first); `null` is no paint. Paints use the
|
||||
- `fills`, `strokes`: the object's fills and strokes in paint order (bottom first); `null` is no paint. A stroke has its
|
||||
`paint`, `width` in points, `join` (`"miter"`, `"round"` or `"bevel"`), `cap` (`"butt"`, `"round"` or `"square"`)
|
||||
and `miterLimit`. Paints use the
|
||||
native file format's form: `{"type": "solid", "color", "swatch"?, "tint"?}`, `{"type": "gradient", "gradient":
|
||||
{"kind": "Linear"|"Radial"|"Freeform", "stops": [{offset, color, opacity, midpoint}]}, "geom"?, "angle",
|
||||
"freeform"?}`, `{"type": "pattern", "pattern", "xf"?}`. Colours are `{"model": "rgb", r, g, b}`, `{"model": "cmyk",
|
||||
c, m, y, k}`, `{"model": "gray", k}` (ink: 0 white, 1 black) or `{"model": "lab", l, a, b}`; components 0–1 except
|
||||
Lab's.
|
||||
- `effects` (filters): the object's own effects in order, as its effect records: `id` (as `effect.list` lists it, or
|
||||
`plugin.<id>` for a live-effect plug-in), `params` and `visible`. Its fills' and strokes' own effects aren't listed.
|
||||
- `bounds`: `[x0, y0, x1, y1]`, the geometric bounds (read only).
|
||||
|
||||
### Parameters
|
||||
@@ -226,17 +232,27 @@ For an **object filter**, the output is the new state of the input objects:
|
||||
|
||||
- An object with the `id` of an input object updates it; keys it leaves out keep their value (`{"id": 12}` keeps the
|
||||
object as it is). `fills` and `strokes` set the object's fills and strokes in order: extra entries add fills (above
|
||||
the last one) or strokes, missing ones are removed; each stroke keeps its weight unless `width` is given (a new one: 1 pt).
|
||||
the last one) or strokes, missing ones are removed; each stroke keeps its weight, join, cap and miter limit unless
|
||||
`width`, `join`, `cap` or `miterLimit` are given (a new one: 1 pt, miter join, butt cap, miter limit 10).
|
||||
- `effects` replaces the object's own effects, in order: each `{id, params?, visible?}`. A record the object already had
|
||||
stays as it is; a new one is admitted as `effect.apply` admits it: an effect `effect.list` lists or an installed
|
||||
live-effect plug-in, with parameters it takes (filled in to their defaults; a plug-in's checked against its
|
||||
manifest), at most one 3D effect (its fills' and strokes' own effects counted), which must fit the object, and a
|
||||
Glass `textureImage` as Glass stores it (base64 of a PNG: a plug-in can't have the host read a file). A tool can
|
||||
then set up objects for a live effect in one step.
|
||||
- An object without an `id` is new and needs a `path`. It goes just above the object listed before it, or, listed
|
||||
before any input object, just below the first one listed after it. New objects take a path's defaults: no fills or
|
||||
strokes, full opacity.
|
||||
- Input objects missing from the output are deleted. The order of the input objects themselves doesn't change.
|
||||
- `type` turns a path into a compound path (one member per subpath) or back; `name: ""` clears the name.
|
||||
- A `path` returned as it was keeps a live shape live (a rectangle keeps its corner widgets); a changed one makes it a
|
||||
plain path.
|
||||
|
||||
The host validates everything before the document changes: coordinates must be finite and within ±4,000,000 pt, at
|
||||
most 100,000 objects and 4,000,000 anchors, 256 fills, strokes or gradient stops; colours, opacities and offsets are
|
||||
clamped into range, stroke weights to 0–1,000 pt; a pattern must exist in the document. A paint returned unchanged
|
||||
keeps its swatch link; any other paint is unlinked.
|
||||
clamped into range, stroke weights to 0–1,000 pt and miter limits to 1–500; a pattern must exist in the document. A
|
||||
paint returned unchanged keeps its swatch link; any other paint is unlinked. One refused effect record refuses the
|
||||
whole output.
|
||||
|
||||
For a **live effect**, the geometry of every returned object's `path` (their subpaths, in order) replaces the
|
||||
object's; the rest is ignored (the object keeps its own appearance). An empty list removes the geometry.
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ Checked 2026-10-10 from the code, tests and open issues; no workflow fails, so V
|
||||
| M6 | Path operations (Pathfinder, Shape Builder, offset…) | ✅ mostly done (single-result Pathfinder names and SVG IDs retained (#1293); Divide open-cutting-path geometry, appearance and history verified (#1307; existing segment cap remains); Simplify preview/counts and rewritten-path component selection verified (#1272; auto/slider/advanced UI remains open); Compound appearance and member fill-rule edits verified (#1197); Boolean precision on almost-horizontal edges fixed and the property tests made deterministic; Shape Builder gap detection, large-offset bug open) | 3–6 |
|
||||
| M7 | Type (point/area/path, editing, styles, OpenType, threading, glyphs) | 🟡 Fullwidth `!` / `?` keep an upright fallback in vertical type; Document-point character controls after object/group scaling (#1034; optional font-size preservation remains separate), Character/Paragraph Styles (explicit Auto-leading resets and local leading overrides), per-paragraph paragraph attributes, mixed paragraph alignment indication (headless regressions, full integration CI and visual review pass), Area Type Options (with Width/Height, Auto Size and Shrink Text to Fit; overflow reported to agents and vertical Align), type areas resized by their handles and reshaped with Direct Selection, threaded text, Fit Headline, Glyphs, OpenType panel, Find Font, installed system fonts in every font menu (fonts registered with Windows outside its font folders, the XDG and Flatpak host font folders on Linux, and fonts installed while the app runs, listed when it comes back to the front; searchable; the Character and Properties menus show each family's sample of the selected text, preview it live under the pointer or ↑/↓, filter by script and kind, list a family's styles, and star favourites; the Glyphs panel and Find Font's Replace With use the same menu without the live preview) and found by name on open/import (full-name aliases and Missing Fonts searches verified, #1258; Windows font-service QA pending), variable fonts' named instances as styles, CJK names in the UI, input methods (marked text in place, candidate window at the caret; Japanese IME), Text Wrap (offset, invert, both sides of an object; follows edits), Type on a Path effects and Options with draggable start/centre/end brackets (slide, flip), tab stops + Tabs panel (Above Text floats it over the selected text, its ruler at the canvas zoom so stops line up with the columns, #729), inline symbols in text (beyond parity), Hebrew/Arabic bidirectional text, Paragraph Direction, Every-line/Single-line Composer per object (ragged text too) done; tab leaders, spell check, vertical type pending | 45–60 |
|
||||
| M8 | Transform & distort (Puppet Warp, Liquify tools, Envelopes, Blends, Perspective Grid) | ✅ done (M8.1–M8.20 on 2026-10-06, fidelity pass): Liquify Tool Options with one shared brush, pen pressure, hold-to-apply, a safe scope and incremental strokes; tool options that last; Puppet Warp rotation, multi-select, Control bar and a rest-shape session that follows Undo; Width tool on compound paths; Envelope dialogs with preview, Reset with Warp/Mesh, full Envelope Options, type/images/symbols/appearance/gradients/patterns distorted on canvas and in every export, warps that keep their frame, Edit Contents, mesh handles and Control bar; Blend Options, anchor-targeted Blend tool, editable spine, keys picked on the canvas, faithful interpolation and knockout; Anchor Point spine conversion/handle editing and selection priority (#2544), with #2425 Shift reshape preserved; Perspective Grid with Define Grid, presets, lock/snap/rulers, widgets, the 1–4 plane switch, movable planes, Perspective Selection scale/copy/perpendicular/Transform Again, and type and symbols truly projected with Edit Text. Left: Anti-Alias and Preserve Shape output, warp-envelope point editing, brush interpolation in blends, Free Transform/Scale/Reflect along a rotated box | 2–4 |
|
||||
| M9 | Live effects (+ 3D & Materials) | 🟡 2D effects done incl. Effect → Pathfinder, Color Adjustments and Document Raster Effects Settings; PDF export warns when the pixel cap lowers raster-effect resolution; Artistic › Colored Pencil, Cutout, Dry Brush, Film Grain, Neon Glow, Paint Daubs, Palette Knife, Poster Edges, Rough Pastels, Smudge Stick, Sponge, Underpainting and Watercolor and Sketch › Halftone Pattern, Bas Relief, Charcoal, Photocopy and Stamp done (52/57 Photoshop filters); Revolve with automatic smooth vector shading, default-on circular caps and continuous rims, Extrude & Bevel, Inflate and Rotate with one to ten colored directional lights and four original lighting presets; SVG Filters, remaining raster effects and 3D materials and shadows pending | 81–130 |
|
||||
| M9 | Live effects (+ 3D & Materials) | 🟡 2D effects done incl. Effect → Pathfinder, Color Adjustments and Document Raster Effects Settings; PDF export warns when the pixel cap lowers raster-effect resolution; Artistic › Colored Pencil, Cutout, Dry Brush, Film Grain, Fresco, Neon Glow, Paint Daubs, Palette Knife, Poster Edges, Rough Pastels, Smudge Stick, Sponge, Underpainting and Watercolor and Sketch › Halftone Pattern, Bas Relief, Charcoal, Photocopy, Stamp, Torn Edges and Water Paper done (54/57 Photoshop filters); Revolve with automatic smooth vector shading, default-on circular caps and continuous rims, Extrude & Bevel, Inflate and Rotate with one to ten colored directional lights and four original lighting presets; SVG Filters, remaining raster effects and 3D materials and shadows pending | 81–130 |
|
||||
| M10 | Brushes, symbols, patterns, Repeat | 🟡 pattern swatches (5 tile types, Pattern Options, editing mode, SVG `<pattern>`/PDF export) and live Repeat (radial/grid/mirror) done; interactive selected mirror axis implemented (focused and native checks passed; full CI blocked by an unrelated text test); brushes/symbols in progress | 23–37 |
|
||||
| M11 | Artboards & views (selected-set deletion shared by Artboards menu, trash and Properties, retaining artboard 1 when all are selected; Artboard deletion keys keep the first of an all-selected set and protect artwork; history prunes invalid indices while preserving valid multiselection (history tests and full workspace CI pass); click-to-fit objects with the Artboard tool (#1227), artboard escape routing and document setup modal handoff done; artboard panel/tool with Move Artwork for X/Y fields and Artboard Options, Trim View, middle-button pan, print tiling and the status bar's artboard navigator with synchronized Artboard tool selection done; multiple windows, presentation polish) (cached canvas reprojection preserves scale during resize, rotation and DPI changes; regression-tested and contributor-confirmed 2026-10-19; estimates unchanged) (cached canvas dimensions match the renderer limit before cache-key creation, view construction and worker submission; regression-tested; estimates unchanged) | 🟡 | 15–25 |
|
||||
| M12 | Advanced color & art (CMYK/ICC, separations, Gradient Mesh, Live Paint, Image Trace, Graphs) | 🟡 Gradient Mesh, Live Paint, Image Trace (junction-returning pieces retain their positioned boundaries; a simpler contour walk with identical output; an edge's sub-pixel shift is the same from either side; notches read only their own piece; collapsed loops keep few segments; large images trace with a warning; Auto Color keeps rare distinct colours; quick presets trace at once and the Image Trace button opens the adjustment controls; Properties reopens them; tiny fitted contours retain islands and holes; Create Strokes: exact crop EDT, Guo–Hall thinning and maximal-disc graph simplification; 15 presets, the 14 documented ones each with an enhanced version; Ignore Color, Shapes, Auto Grouping and Gradients options; measured in `image-trace-quality.md`; closed outlines retain their interior after straightening; the Flat Logo mode places edges to a fraction of a pixel, restores sharp corners, snaps lines and circles, and refuses gradients; live trace result bounds and selection highlights exclude the retained bitmap except in source-image views), Recolor Artwork, colour management (ICC, soft proofing, separations preview), Graphs (all 9 tools, Graph Data/Type, group-selected series colours persist through regenerate/save/open) done; Graph Design and Marker designs, Transpose and Switch x/y, `\|` label line breaks, the pie options, drop shadows, the legend across the top, overlapping widths, First Row/Column in Front, filled lines, kept label formatting and the Graph Data worksheet done; graph Column designs pending | 6–10 |
|
||||
|
||||
+16
-12
@@ -1,6 +1,6 @@
|
||||
# Parity with Adobe Illustrator
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-22 · **Change:** minor (SVG CSS classes survive export and repeated import in all four styling modes (#2480); current-main integration retains event attributes and scripts; ruby (ふりがな) for live text: `type.ruby` sets or removes a reading over a byte range, above or below (right of the column in vertical type), aligned, sized and overhanging or squeezed; saved natively, laid out with line growth and drawn, with SVG/PDF outlines where ruby is present; scores and hours unchanged; previously:; 3D: original Standard, Diffuse, Top Left and Right lighting presets; command access, effective-setting recognition and preview/history; scores and estimates unchanged; one selected clip group's Properties panel has Edit Clipping Path and Edit Contents at its top, G1; the Print dialog's Media list has the Japanese papers: JIS B4 257 × 364 mm, JIS B5 182 × 257 mm and JIS B6 beside the ISO B4/B5, which keep their ISO 216 sizes, and はがき, 往復はがき, 封筒 長形3号/長形4号/角形2号/角形3号 and 四六判; a paper is named by its JSON id or its dialog label, any case and spacing; imported PDF type that is letter-spaced keeps its word spaces and no others; Fractional Widths: Character panel menu, per type object, on by default; System Layout remains a panel stub; scores unchanged; G4: No Break; scores unchanged; the selection tools take a clipping path on its outline, G1; Polygon and Star exact-size placement remembers the chosen count for later drags and dialog openings; Cancel preserves the previous count; Live trace result bounds and selection highlights exclude the retained bitmap except in source-image views; CSS swatch libraries retain fractional gradient stop positions; scores and hours unchanged; live-effect plug-ins given their object's fills and strokes and the item they sit on, G17; plug-in parameters: labels, units, groups, help and conditions in their dialogs, text and number-list parameters, up to 256 of them, G17; exporter plug-ins: plug-in file formats in Export As and document.export, G17; G2: Effect › Artistic › Smudge Stick, Sponge and Watercolor; Sketch › Bas Relief, Charcoal, Photocopy and Stamp, #2533; Photoshop filters 45/57, 12 remaining (8–14 h); interactive Mirror Repeat axis; bounding-box handles take priority over the axis body while the center and end handles retain their move and rotation actions; Libraries panel: the list scrolls, items and groups reorder by dragging, items drag into and out of groups (`library.moveItem` before/after, `library.moveGroup`); scores unchanged; PDF invisible text opens as type with no fill or stroke and is written back invisible, #2675; status-readout sample widths cached by language, document unit and pixels per point; status messages and readouts use stable responsive allocations sized for localized labels and ordinary coordinates; cached canvas dimensions match the renderer limit before cache-key creation, view construction and worker submission; cached canvas reprojection preserves scale during resize, rotation and DPI changes; interactive Mirror Repeat axis; bounding-box handles take priority over the axis body while the center and end handles retain their move and rotation actions; 3D lighting: one to ten colored lights, smooth colored Inflate, legacy white-light appearance preserved; surface batching and restored seam minimum; scores and estimates unchanged; Blend spine Anchor Point conversions, selection/stacking priority and Shift regression coverage (#2544); scores and hours unchanged; Artboard Options' X and Y with a reference point, #1876; Image Trace: Auto Color keeps rare but distinct colours; Image Trace: large images trace with a warning; anchor limit raised to 8,000,000; Image Trace: Raster::new returns an error for a buffer of the wrong length; M12 maximal-disc graph pruning and junction merging measured; M12 crop EDT and Guo–Hall thinning measured; M12 centre-lines baseline measured; scores and hours unchanged; installed plug-ins stay installed after a restart, #2541; Group Selection picks and moves one path of a compound path, #2441 in part; the Move dialog opens on the last move and its last checkboxes; Image Trace: a higher Paths never gives fewer segments on collapsed loops; Image Trace: the notch rule reads only its own piece; Image Trace: an edge's sub-pixel shift is the same from either side; Image Trace Flat Logo traces line art on white paper instead of a blank result; score and hours unchanged; Image Trace: a simpler contour walk with no precomputed direction table; transparency grid visibility saved in native documents, #1968; MCP cancellation, progress and busy answers during long exports, #2165, #2171, #2172; EPS editing data: legacy mesh corners, vector opacity masks and compound member paint retained; raster page comparison filters minification without relaxing limits; scores and hours unchanged; native family-name fallback from EnglLine truncated
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-22 · **Change:** minor (SVG CSS classes survive export and repeated import in all four styling modes (#2480); filter plug-ins read and set effect records and stroke joins, caps and miter limits, G17; the Print dialog's Media list has the Japanese papers: JIS B4 257 × 364 mm, JIS B5 182 × 257 mm and JIS B6 beside the ISO B4/B5, which keep their ISO 216 sizes, and はがき, 往復はがき, 封筒 長形3号/長形4号/角形2号/角形3号 and 四六判; a paper is named by its JSON id or its dialog label, any case and spacing; imported PDF type that is letter-spaced keeps its word spaces and no others; Fractional Widths: Character panel menu, per type object, on by default; System Layout remains a panel stub; scores unchanged; G4: manual Tate-chu-yoko; G4: No Break; scores unchanged; the selection tools take a clipping path on its outline, G1; Polygon and Star exact-size placement remembers the chosen count for later drags and dialog openings; Cancel preserves the previous count; Live trace result bounds and selection highlights exclude the retained bitmap except in source-image views; CSS swatch libraries retain fractional gradient stop positions; scores and hours unchanged; live-effect plug-ins given their object's fills and strokes and the item they sit on, G17; plug-in parameters: labels, units, groups, help and conditions in their dialogs, text and number-list parameters, up to 256 of them, G17; exporter plug-ins: plug-in file formats in Export As and document.export, G17; G2: Effect › Artistic › Smudge Stick, Sponge and Watercolor; Sketch › Bas Relief, Charcoal, Photocopy and Stamp, #2533; Photoshop filters 45/57, 12 remaining (8–14 h); interactive Mirror Repeat axis; bounding-box handles take priority over the axis body while the center and end handles retain their move and rotation actions; Libraries panel: the list scrolls, items and groups reorder by dragging, items drag into and out of groups (`library.moveItem` before/after, `library.moveGroup`); scores unchanged; PDF invisible text opens as type with no fill or stroke and is written back invisible, #2675; status-readout sample widths cached by language, document unit and pixels per point; status messages and readouts use stable responsive allocations sized for localized labels and ordinary coordinates; cached canvas dimensions match the renderer limit before cache-key creation, view construction and worker submission; cached canvas reprojection preserves scale during resize, rotation and DPI changes; interactive Mirror Repeat axis; bounding-box handles take priority over the axis body while the center and end handles retain their move and rotation actions; 3D lighting: one to ten colored lights, smooth colored Inflate, legacy white-light appearance preserved; surface batching and restored seam minimum; scores and estimates unchanged; Blend spine Anchor Point conversions, selection/stacking priority and Shift regression coverage (#2544); scores and hours unchanged; Artboard Options' X and Y with a reference point, #1876; Image Trace: Auto Color keeps rare but distinct colours; Image Trace: large images trace with a warning; anchor limit raised to 8,000,000; Image Trace: Raster::new returns an error for a buffer of the wrong length; M12 maximal-disc graph pruning and junction merging measured; M12 crop EDT and Guo–Hall thinning measured; M12 centre-lines baseline measured; scores and hours unchanged; installed plug-ins stay installed after a restart, #2541; Group Selection picks and moves one path of a compound path, #2441 in part; the Move dialog opens on the last move and its last checkboxes; Image Trace: a higher Paths never gives fewer segments on collapsed loops; Image Trace: the notch rule reads only its own piece; Image Trace: an edge's sub-pixel shift is the same from either side; Image Trace Flat Logo traces line art on white paper instead of a blank result; score and hours unchanged; Image Trace: a simpler contour walk with no precomputed direction table; transparency grid visibility saved in native documents, #1968; MCP cancellation, progress and busy answers during long exports, #2165, #2171, #2172; EPS editing data: legacy mesh corners, vector opacity masks and compound member paint retained; raster page comparison filters minification without relaxing limits; scores and hours unchanged; native family-name fallback from English-only typographic names, #2208; scores unchanged; batch exporting, #1935; G2: Effect › Sketch › Halftone Pattern; Photoshop filters 45/57, 12 remaining (8–14 h); G5: Symbol Options Export Type (Graphic / Movie Clip); Localization: Brazilian Portuguese complete under the tests, #1914, 71% → 74%; G6 image variables: Automation ~60% → ~62% / detail ~65% → ~68%, hours lowered; Warp Options controls verified by focused checks and original-image review; estimates unchanged; G11: Asset Export Art Optimized seam (#983 / #1037) and sLine truncated
|
||||
|
||||
The authoritative parity assessment. [`ROADMAP.md`](../ROADMAP.md) summarizes it; [`gaps.md`](gaps.md) is
|
||||
the work list made from it. Deep areas have their own checklists: [UI and interaction](ui-parity.md),
|
||||
@@ -39,10 +39,10 @@ tests and the CI gate. See [Calibration](#calibration).
|
||||
nothing here is a menu dump or a side-by-side measurement: the numbers come from our own code against
|
||||
Illustrator's public documentation.
|
||||
- **From the code (measured, origin/main `01e165af`):**
|
||||
- Menu tree (`crates/ui-egui/src/menus.rs`, laid out in Illustrator's menu order): 347 items bound to
|
||||
commands, 27 stubs (`todo(…)`/`todos(…)`), so 92.8% of menu items do something (348 and 27 after the
|
||||
- Menu tree (`crates/ui-egui/src/menus.rs`, laid out in Illustrator's menu order): 348 items bound to
|
||||
commands, 26 stubs (`todo(…)`/`todos(…)`), so 93.0% of menu items do something (348 and 26 after Snap to Glyph shipped in #3124; 348 and 27 after the
|
||||
Revolve merge; 350 and 25, 93.3%, after Graph › Design and Marker; 353 and 22, 94.1%, after Extrude & Bevel, Inflate and Rotate). The stubs: Effect › 3D and Materials › Materials, Effect › SVG Filters, Edit › Spelling (3), Graph › Column, Live Paint
|
||||
Gap Options, Optical Margin Alignment, Start Global Edit, global and video rulers (2), Snap to Glyph,
|
||||
Gap Options, Optical Margin Alignment, Start Global Edit, global and video rulers (2),
|
||||
Window › Arrange (4), SVG Interactivity, the library placeholders (3), Other Script…, Help.
|
||||
- Engine commands: ~710 ids registered with `cmd!` across `crates/engine/src/cmd` (plus macro-generated
|
||||
families), and 85 UI-only commands (`UI_COMMANDS`).
|
||||
@@ -79,16 +79,16 @@ dominate; 3D, graphs and automation are specialist). They sum to 105. Feature de
|
||||
| 3D and Materials (and Turntable) | 4 | ~25% | live Revolve with automatic smooth vector shading and default-on continuous circular caps, Extrude & Bevel (twist, taper, caps, five bevel shapes), Inflate and Rotate with Position presets (colored Inflate uses smooth membrane lighting; white-light Inflate retains its existing shading; Extrude & Bevel and Rotate retain planar shading; one to ten colored lights, shared neutral ambient, original lighting presets, painter visibility); materials, shadows, ray tracing, 3D Classic, Turntable views, 3D export | 30–55 | estimated (Extrude & Bevel, Inflate and Rotate added 2026-10-12) |
|
||||
| Type core | 9 | 80% | Auto-leading style resets are implemented; remaining: hyphenation and justification options, Optical Margin Alignment, Middle Eastern features beyond bidi layout, optional group font-size preservation; transformed character controls fixed (#1034), see [type-parity.md](type-parity.md) | 14–19 | estimated; full-name font matches regression-tested (#1258); mixed paragraph alignment indication implemented; headless regressions, full integration CI and visual review pass; localized legacy family-name fallback with loaded/catalog regressions (#2208); Fractional Widths per type object regression-tested; scores and hours unchanged |
|
||||
| Type advanced (CJK, spelling, Touch Type, Retype) | 4 | 50% | CJK vertical composition (mojikumi), variable font axes, tab leaders, spell check, Touch Type, Retype | 20–28 | estimated; No Break keeps marked characters on one line; upright fallback for fullwidth `!` / `?` regression-tested; score and hours unchanged |
|
||||
| Raster effects (Effect Gallery) | 4 | 49% | 5 Photoshop-style filters (Artistic › Fresco among them), the Effect Gallery dialog, Load Texture | 8–14 | measured count 52/57 (Artistic › Colored Pencil, Paint Daubs, Palette Knife, Rough Pastels and Underpainting added); texture redraw distances optimized (#1257), pixels verified; depth estimated |
|
||||
| Raster effects (Effect Gallery) | 4 | 49% | 3 Photoshop-style filters (Sketch › Conté Crayon among them), the Effect Gallery dialog, Load Texture | 8–14 | measured count 54/57 (Artistic complete with Colored Pencil, Fresco, Paint Daubs, Palette Knife, Rough Pastels and Underpainting; Sketch › Torn Edges added); texture redraw distances optimized (#1257), pixels verified; depth estimated |
|
||||
| Symbols, blends, envelopes, Repeat, perspective | 5 | 87% | 30.7's Blend panel with ease in/out, dynamic symbols, symbol libraries, Start Global Edit, envelope Anti-Alias/Preserve Shape; Symbol Options › Registration, Export Type (Graphic / Movie Clip) and 9-slice guide settings (stored, not drawn) are done | 5–9 | estimated; interactive selected mirror axis implemented; bounding-box handles take priority over the axis line (focused regression and native checks passed; full CI blocked by an unrelated text test); #2544 spine Anchor Point conversion and picking regression-tested; scores and hours unchanged |
|
||||
| Image Trace, graphs, image tools | 3 | 75% | graph Column designs, Image Trace Create Strokes depth (Create Object Mosaic is done; junction-returning piece survival has source-generated regressions in `image-trace-quality.md`; simpler contour walk, identical output; an edge's sub-pixel shift is the same from either side; notches read only their own piece; collapsed loops keep few segments, so Paths is monotone on the code-drawn sweep) | 5–8 | estimated (raised from 72%); quick presets reveal adjustment controls, Properties reopens them; Live trace result bounds and selection highlights exclude the retained bitmap except in source-image views (scores/hours unchanged) |
|
||||
| Symbols, blends, envelopes, Repeat, perspective | 5 | 87% | 30.7's Blend panel with ease in/out, dynamic symbols, symbol libraries, Start Global Edit, envelope Anti-Alias/Preserve Shape; Symbol Options › Registration and Export Type (Graphic / Movie Clip) are done | 5–9 | estimated |
|
||||
| Image Trace, graphs, image tools | 3 | 75% | graph Column designs, Image Trace Create Strokes depth (Create Object Mosaic is done; junction-returning piece survival has source-generated regressions in `image-trace-quality.md`; large images trace with a warning; Auto Color keeps rare distinct colours) | 5–8 | estimated (raised from 72%); quick presets reveal adjustment controls, Properties reopens them |
|
||||
| Layers, artboards, document setup | 5 | 78% | Selected-artboard deletion is consistent across panel actions (all-selected retains artboard 1); history prunes removed indices while preserving valid multiselection; remaining: 30.0's artboard locking and colours and managing artboards from the canvas, Layers panel row context menus and Collect for Export (click-to-fit objects is done, #1227) | 5–8 | estimated (lowered from 82%: target moved); Artboard deletion keys keep artwork and the first of an all-selected set |
|
||||
| View & navigation | 3 | 70% | New View/Edit Views, multiple windows and Arrange, Snap to Glyph | 9–14 | estimated; cached canvas reprojection preserves scale during resize, rotation and DPI changes (regression and contributor original-file evidence below; scores/hours unchanged); cached canvas dimensions match the renderer limit before cache-key creation, view construction and worker submission (regression evidence below) |
|
||||
| File formats | 6 | 75% | `.ai` files open with a flattened or wrong layer structure in real cases (#951), guides lost (#779), no writing of Illustrator's editing data (#868), FreeHand/CorelDRAW/DWG/HEIC/JPEG 2000 import, 3D export; see [file-format-parity.md](file-format-parity.md); EPS legacy mesh/opacity-mask and raster comparison follow-up verified | 10–20 | estimated; SVG CSS classes survive export and repeated import in all four styling modes (#2480); current-main integration retains event attributes and scripts (lowered from 85%: open issues); DXF control-point SPLINE import closure regression-tested (#1299 follow-up after #1320); PDF writer metadata, reader streaming and immutable backend checks in `crates/pdf/src/tests.rs`, `crates/pdf/src/tests_reader_streaming.rs` and `xtask/src/pdf_deps.rs`; PDF Place and clipboard paste retain live text (synthetic regressions) |
|
||||
| View & navigation | 3 | 70% | New View/Edit Views, multiple windows and Arrange, Snap to Glyph | 9–14 | estimated; cached canvas reprojection preserves scale during resize, rotation and DPI changes (regression and contributor original-file evidence below; scores/hours unchanged) |
|
||||
| View & navigation | 3 | 70% | New View/Edit Views, multiple windows and Arrange, Snap to Glyph | 9–14 | estimated |
|
||||
| View & navigation | 3 | 70% | New View/Edit Views, multiple windows and Arrange | 9–14 | estimated; cached canvas reprojection preserves scale during resize, rotation and DPI changes (regression and contributor original-file evidence below; scores/hours unchanged); cached canvas dimensions match the renderer limit before cache-key creation, view construction and worker submission (regression evidence below) |
|
||||
| File formats | 6 | 75% | `.ai` files open with a flattened or wrong layer structure in real cases (#951), guides lost (#779), no writing of Illustrator's editing data (#868), FreeHand/CorelDRAW/DWG/HEIC/JPEG 2000 import, 3D export; see [file-format-parity.md](file-format-parity.md); EPS legacy mesh/opacity-mask and raster comparison follow-up verified | 10–20 | estimated (lowered from 85%: open issues); DXF control-point SPLINE import closure regression-tested (#1299 follow-up after #1320); PDF writer metadata, reader streaming and immutable backend checks in `crates/pdf/src/tests.rs`, `crates/pdf/src/tests_reader_streaming.rs` and `xtask/src/pdf_deps.rs`; PDF Place and clipboard paste retain live text (synthetic regressions); SVG CSS classes survive export and repeated import in all four styling modes (#2480); current-main integration retains event attributes and scripts |
|
||||
| View & navigation | 3 | 70% | New View/Edit Views, multiple windows and Arrange | 9–14 | estimated; cached canvas reprojection preserves scale during resize, rotation and DPI changes (regression and contributor original-file evidence below; scores/hours unchanged) |
|
||||
| View & navigation | 3 | 70% | New View/Edit Views, multiple windows and Arrange | 9–14 | estimated |
|
||||
| Guides, grids, smart guides, snapping, rulers | 3 | 80% | 30.0's tangent and perpendicular snapping and its snapping panel, "intersect" smart guides for a moved selection's anchors (drawn points and dragged anchors snap to intersections, #1658), video rulers, distance readouts while drawing | 4–7 | estimated (lowered from 85%: target moved); new ruler-guide Alt orientation implemented |
|
||||
| Guides, grids, smart guides, snapping, rulers | 3 | 80% | 30.0's tangent and perpendicular snapping and its snapping panel, "intersect" smart guides for a moved selection's anchors (drawn points and dragged anchors snap to intersections, #1658), global/artboard ruler mode switch and video rulers, distance readouts while drawing | 4–7 | estimated (lowered from 85%: target moved); new ruler-guide Alt orientation implemented |
|
||||
| Export for Screens, Asset Export, slices, Save for Web | 3 | 85% | anti-aliasing ghost borders (#983); TIFF choices and settings are implemented | 2–4 | estimated |
|
||||
@@ -339,8 +339,8 @@ about 1–1.5 agent-hours each, so the other rows (estimated on the older scale)
|
||||
| Live vector effects | 5 | 85% | Outline Object, Pathfinder Hard/Soft Mix and Trap, SVG Filters, the Transform effect's Transform Objects/Patterns and Scale Strokes & Effects options | 6–10 |
|
||||
| Raster effects (Effect Gallery, Document Raster Effects Settings) | 4 | 35% | ~36 Photoshop-style filters (Artistic, Brush Strokes, Sketch, Stylize), Texturizer's Load Texture and the Effect Gallery; Document Raster Effects Settings, raster effects in PDF, the pixel-filter pipeline, Radial Blur, Smart Blur (Normal, Edge Only and Overlay Edge), Unsharp Mask, Glowing Edges, Distort (Diffuse Glow, Glass, Ocean Ripple), Pixelate (Color Halftone, Crystallize, Mezzotint, Pointillize), Texture (Craquelure, Grain, Mosaic Tiles, Patchwork, Stained Glass, Texturizer) and Video (De-Interlace, NTSC Colors) are done | 8–14 |
|
||||
| 3D and Materials | 4 | ~25% | Initial Revolve, Extrude & Bevel, Inflate and Rotate, with simple lighting and four original lighting presets; materials, shadows, ray tracing, 3D Classic and more complete visibility remain | 25–45 |
|
||||
| Type advanced | 4 | 50% | CJK composition for vertical type (mojikumi beyond Line-end Punctuation Half Width — the other sets (and their paragraph-start bracket and indent rules), custom kinsoku sets (beyond Hard, Soft and None) and the Mojikumi Settings dialog —, manual tate-chu-yoko; No Break is done), variable font axis sliders (named instances are styles), tab leaders, spell check (open dictionary), Touch Type, Retype; vertical point/area/path type and Type Orientation have initial support (beyond parity, not scored: inline symbols in text) | 20–28 |
|
||||
| Type core | 9 | 80% | Middle Eastern features beyond bidi layout and Paragraph Direction (Character Direction, kashidas, the Middle Eastern composers, editable bidirectional SVG text, a split caret where directions meet); Hyphenation… and Justification… options (Every-line Composer for justified and ragged text, per object, is done; it is tuned by eye, not yet compared side by side with Illustrator; mixed type sizes in a paragraph still break single-line in non-rectangular area type and with text wrap), Optical Margin Alignment, paragraph spacing limit for vertically justified area type, hidden characters, paragraph attributes in the Type tool's copy and paste (the characters keep their styles, the paragraphs take the destination's), mixed-value display in the Paragraph panel for a selection across differing paragraphs, partial selection of type-area anchors by marquee, optional font-size preservation during group scaling (scaled character controls fixed in #1034). Fractional Widths is done; System Layout remains a panel stub | 14–19 |
|
||||
| Type advanced | 4 | 50% | CJK composition for vertical type (mojikumi beyond Line-end Punctuation Half Width — the other sets (and their paragraph-start bracket and indent rules), custom kinsoku sets (beyond Hard, Soft and None) and the Mojikumi Settings dialog —, manual tate-chu-yoko is done, its up/down settings remain; No Break is done), variable font axis sliders (named instances are styles), tab leaders, spell check (open dictionary), Touch Type, Retype; vertical point/area/path type and Type Orientation have initial support (beyond parity, not scored: inline symbols in text) | 20–28 |
|
||||
| Type core | 9 | 80% | Middle Eastern features beyond bidi layout and Paragraph Direction (Character Direction, kashidas, the Middle Eastern composers, editable bidirectional SVG text, a split caret where directions meet); Hyphenation… and Justification… options (Every-line Composer for justified and ragged text, per object, is done; it is tuned by eye, not yet compared side by side with Illustrator; mixed type sizes in a paragraph still break single-line in non-rectangular area type and with text wrap), Optical Margin Alignment, paragraph spacing limit for vertically justified area type, hidden characters, paragraph attributes in the Type tool's copy and paste (the characters keep their styles, the paragraphs take the destination's), mixed-value display in the Paragraph panel for a selection across differing paragraphs, partial selection of type-area anchors by marquee, optional font-size preservation during group scaling (scaled character controls fixed in #1034). Fractional Widths and System Layout are done | 14–19 |
|
||||
| Symbols, blends, envelopes, Repeat, perspective | 5 | 90% | symbol libraries (original), dynamic symbols, envelope Anti-Alias/Preserve Shape output and warp point editing, brush interpolation in blends (M8 fidelity pass done); Symbol Options › Registration and Export Type done (9-slice guides remain) | 4–7 |
|
||||
| Image Trace, graphs, image tools | 3 | 72% | graph Column designs (Graph Design, Marker designs and series colours set with Group Selection are done), Create Object Mosaic, per-feature stroke/fill choice and varying widths in Image Trace's Create Strokes (Vector Halftone and the Image Trace View modes, Palette and Create Strokes are done) | 6–10 |
|
||||
| Layers, artboards, document setup | 5 | 82% | Layers panel: a confirmation before deleting layers that hold art, Collect for Export, row context menus, the Layer Options dialog for several rows with mixed values, Paste Remembers Layers for sublayers, drag-scrolling a long panel while dragging rows; artboard preset polish (artboard escape routing and document setup modal handoff done; Move Artwork for artboard X/Y edits, Rearrange All Artboards, Document Setup, New Document and the rest of the Layers panel are done) | 4–7 |
|
||||
@@ -906,6 +906,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
|
||||
- **Plug-in parameters as their manifest presents them (G17):** each parameter may have a `label`, a `unit` shown after its value, `help` on its label and a `helpUrl` page opened from a button, a `group` (sections that fold, after the parameters outside any group) and a `visibleWhen` that shows it only while the checkboxes and choices it names have one of the listed values (a hidden parameter still goes to the plug-in). `string` and `numberList` parameters join number, int, bool and choice, and a plug-in declares up to 256 parameters, at most 64 outside groups. The filter, live-effect and exporter dialogs use these keys, and the Appearance panel's effect editor the labels, units, help and conditions; hosts from before them ignore them. Regressions: `crates/plugins/src/dialog.rs`, `crates/plugins/src/manifest.rs`, `crates/ui-egui/src/dialogs/tests_plugin_fields.rs`, `crates/ui-egui/src/panels/appearance.rs`. Scores and hours unchanged.
|
||||
- **Live-effect plug-ins read their object's paints (G17):** a live effect is given the object's `fills` and `strokes` as a filter gets them, read only, and `_context.item` (`"object"`, or the fill or stroke whose own effects hold it); the result is cached by paint too, so a change of paint runs it again. Regressions: `crates/engine/src/tests_plugins.rs`, `crates/plugins/src/effect.rs`. Scores and hours unchanged.
|
||||
- **Filter plug-ins set effects and stroke styles (G17):** a filter is given each object's effect records and its strokes' `join`, `cap` and `miterLimit`, and may return them; the records are admitted as `effect.apply` admits them (a known effect or installed live-effect plug-in, parameters it takes, one 3D effect that fits, no texture read from a file), and one refused refuses the output. Regressions: `crates/engine/src/tests_plugins.rs`, `crates/plugins/src/objects/tests.rs`. Scores and hours unchanged.
|
||||
|
||||
- **Plug-in effects after a plug-in changes:** when a plug-in is installed for the first time, installed again or removed (`plugin.install`, `plugin.reload`, `plugin.remove`, File › Open of a `.wasm` file, the Additional Plug-ins Folder preference), the next frame the canvas draws uses the plug-ins then installed for objects with a plug-in effect and their raster effects, for the blends, envelopes and repeats that show such objects, and for pattern tiles and symbol instances whose art holds one.
|
||||
|
||||
@@ -923,14 +924,17 @@ Evidence for the shared light Color: geometry tests in `tests_lighting`, effect
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-10-21 | minor | SVG CSS classes survive export and repeated import in all four styling modes (#2480); current-main integration retains event attributes and scripts. Scores and estimates unchanged. |
|
||||
| 2026-10-21 | minor | Snap to Glyph (#3124) removed from View navigation missing lists and menu stubs; scores and hours unchanged at this rounding |
|
||||
| 2026-10-21 | minor | Type core: System Layout (Character panel menu, whole document, off by default) is done; scores and hours unchanged |
|
||||
| 2026-10-22 | minor | Ruby (ふりがな) for live text: `type.ruby` sets/removes a reading over a byte range, above or below (right of the column in vertical type), aligned, sized and overhanging or squeezed; saved natively, laid out with line growth, drawn on the canvas and in SVG/PDF (outlines where ruby is present); scores and hours unchanged |
|
||||
| 2026-10-21 | minor | 3D: original Standard, Diffuse, Top Left and Right lighting presets; command access, effective-setting recognition and preview/history; scores and estimates unchanged |
|
||||
| 2026-10-21 | minor | Properties: one selected clip group has Edit Clipping Path and Edit Contents at the top of the panel (public doc cited) (G1). Scores and hours unchanged. |
|
||||
| 2026-10-21 | minor | Print: the Print dialog's Media list carries the Japanese papers — JIS B4 (257 × 364 mm), JIS B5 (182 × 257 mm) and JIS B6 next to the ISO B4/B5, which keep their ISO 216 sizes, plus はがき, 往復はがき, 封筒 長形3号/長形4号/角形2号/角形3号 and 四六判; the JSON id or the dialog label names a paper, any case and spacing. Print score and hours unchanged. |
|
||||
| 2026-10-21 | minor | Type core: Fractional Widths (Character panel menu, per type object, on by default) is done; System Layout remains a panel stub; scores and hours unchanged |
|
||||
| 2026-10-21 | minor | Type core: Fractional Widths (Character panel menu, per type object, on by default) is done; scores and hours unchanged |
|
||||
| 2026-10-20 | minor | Polygon and Star exact-size placement remembers the chosen count for later drags and dialog openings; Cancel preserves the previous count; existing opening gestures retained; scores and hours unchanged. |
|
||||
| 2026-10-20 | minor | Live trace result bounds and selection highlights exclude the retained bitmap except in source-image views; scores and hours unchanged. |
|
||||
| 2026-10-20 | minor | M3.57: CSS swatch libraries preserve fractional stop positions in linear and radial gradients; synthetic color-crate regression. Scores and hours unchanged. |
|
||||
| 2026-10-19 | minor | Plug-ins: filters read and set effect records and stroke joins, caps and miter limits (G17); a path handed back unchanged stays a live shape; engine and unit regressions. Scores and hours unchanged. |
|
||||
| 2026-10-19 | minor | Plug-ins: live effects are given their object's fills and strokes, read only, and the item they sit on (G17); engine and unit regressions. Scores and hours unchanged. |
|
||||
| 2026-10-19 | minor | Plug-ins: parameters with labels, units, help, groups and conditions in their dialogs, `string` and `numberList` types, up to 256 per plug-in (G17); manifest and kittest dialog regressions. Scores and hours unchanged. |
|
||||
| 2026-10-19 | minor | Plug-ins: exporter plug-ins add write-only file formats to Export As and `document.export` (G17); engine, ABI and headless Export As regressions. Scores and hours unchanged. |
|
||||
|
||||
+10
-4
@@ -1,6 +1,6 @@
|
||||
# Type parity
|
||||
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-22 · **Change:** minor (ruby (ふりがな) for live text: `type.ruby` sets or removes a reading over a byte range, above or below (right of the column in vertical type), start/centre/end aligned, sized and overhanging or squeezed; saved natively, laid out with its line growing, drawn on the canvas and in SVG/PDF (outlines where ruby is present); scores unchanged; previously:; Fractional Widths: Character panel menu turns whole-point advances on or off per type object, on by default; scores unchanged; type on a path threads, mixed with area type in one thread; scores unchanged; No Break keeps marked characters on one line; scores unchanged; a click on the out port threads the text into a closed path, a new frame at the click or a dragged rectangle, #2572 in part; scores unchanged; native family labels fall back to localized legacy names when typographic names are English-only, #2208; scores unchanged; Cmd+Shift+C aligns centre off the Mac, #1940; tab leaders are drawn in the tab's gap, #1877; type in symbols, pattern tiles, graph designs and opacity masks gets its layout bounds back on opening a native file, #1738; score unchanged; Escape while typing ends the edit, #1686; Select › Same on type, #1737; `justify` when creating point type, #1748; scores unchanged; OpenType stylistic sets, alternates, figure styles, superscript and subscript as character features, #1607; a wide word in non-rectangular area type moves down, #1615; scores unchanged; Character Styles New/Redefine capture the first selected character at run boundaries and end prior typing before capture; boundary and typing-history input tests and full workspace CI pass; scores and hours unchanged; Character styles retain explicit Auto leading, propagate resets and preserve local leading overrides; scores and hours unchanged; Linux font folders from fontconfig, #1529; commands and MCP `add_text` report area type that does not fit its frame, #1471; Tabs panel stop drags, #1458; Fit Headline in a frame one line tall, #1444; frames and paths beyond a billion points hold no text, #1451; scores unchanged; missing glyphs are looked for again after a font rescan, #1376; scores unchanged; Full-name font matching (#1258); Windows font-service QA pending; scores unchanged; Middle Eastern digit types: Character panel menu › Digits, `{digits}`; the font menu's script filter lists Thai fonts; Thai, Lao, Khmer and Myanmar lines break between words; the caret steps over whole clusters such as Thai consonants with their marks; Thai typed in a font without Thai falls back to a font made for Thai; earlier: Proportional Metrics in vertical type, `vpal`, #966; Cmd+Shift+C aligns centre off the Mac, a double-click on area type's bottom handle turns on Auto Size, #1940; MCP `add_text` exposes the existing `vertical` option for point, area and path type; horizontal remains the default; scores and hours unchanged; Vertical fullwidth question and exclamation marks keep their nominal glyph upright when the font has no vertical alternate; scores and hours unchanged. tab leaders are drawn in the tab's gap, #1877; type in symbols, pattern tiles, graph designs and opacity masks gets its layout bounds back on opening a native file, #1738; score unchanged; Escape while typing ends the edit, #1686; Select › Same on type, #1737; `justify` when creating point type, #1748; scores unchanged; OpenType stylistic sets, alternates, figure styles, superscript and subscript as character features, #1607; a wide word in non-rectangular area type moves down, #1615; scores unchanged; Character Styles New/Redefine capture the first selected character at run boundaries and end prior typing before capture; boundary and typing-history input tests and full workspace CI pass; scores and hours unchanged; Character styles retain explicit Auto leading, propagate resets and preserve local leading overrides; scores and hours unchanged; Linux font folders from fontconfig, #1529; commands and MCP `add_text` report area type that does not fit its frame, #1471; Tabs panel stop drags, #1458; Fit Headline in a frame one line tall, #1444; frames and paths beyond a billion points hold no text, #1451; scores unchanged; missing glyphs are looked for again after a font rescan, #1376; scores unchanged; Full-name font matching (#1258); Windows font-service QA pending; scores unchanged; Middle Eastern digit types: Character panel menu › Digits, `{digits}`; the font menu's script filter lists Thai fonts; Thai, Lao, Khmer and Myanmar lines break between words; the caret steps over whole clusters such as Thai consonants with their marks; Thai typed in a font without Thai falls back to a font made for Thai; earlier: Proportional Metrics in vertical type, `vpal`, #966) · **Target:** Adobe Illustrator 2026 (30.x)
|
||||
> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-22 · **Change:** minor (manual Tate-chu-yoko marks characters across one em of a vertical column; System Layout: Character panel menu sets whole-point advances for every text object in the document (off by default); ruby (ふりがな) for live text: `type.ruby` sets or removes a reading over a byte range, above or below (right of the column in vertical type), start/centre/end aligned, sized and overhanging or squeezed; saved natively, laid out with its line growing, drawn on the canvas and in SVG/PDF (outlines where ruby is present); scores unchanged; previously:; Fractional Widths: Character panel menu turns whole-point advances on or off per type object, on by default; scores unchanged; type on a path threads, mixed with area type in one thread; scores unchanged; No Break keeps marked characters on one line; scores unchanged; a click on the out port threads the text into a closed path, a new frame at the click or a dragged rectangle, #2572 in part; scores unchanged; native family labels fall back to localized legacy names when typographic names are English-only, #2208; scores unchanged; Cmd+Shift+C aligns centre off the Mac, #1940; tab leaders are drawn in the tab's gap, #1877; type in symbols, pattern tiles, graph designs and opacity masks gets its layout bounds back on opening a native file, #1738; score unchanged; Escape while typing ends the edit, #1686; Select › Same on type, #1737; `justify` when creating point type, #1748; scores unchanged; OpenType stylistic sets, alternates, figure styles, superscript and subscript as character features, #1607; a wide word in non-rectangular area type moves down, #1615; scores unchanged; Character Styles New/Redefine capture the first selected character at run boundaries and end prior typing before capture; boundary and typing-history input tests and full workspace CI pass; scores and hours unchanged; Character styles retain explicit Auto leading, propagate resets and preserve local leading overrides; scores and hours unchanged; Linux font folders from fontconfig, #1529; commands and MCP `add_text` report area type that does not fit its frame, #1471; Tabs panel stop drags, #1458; Fit Headline in a frame one line tall, #1444; frames and paths beyond a billion points hold no text, #1451; scores unchanged; missing glyphs are looked for again after a font rescan, #1376; scores unchanged; Full-name font matching (#1258); Windows font-service QA pending; scores unchanged; Middle Eastern digit types: Character panel menu › Digits, `{digits}`; the font menu's script filter lists Thai fonts; Thai, Lao, Khmer and Myanmar lines break between words; the caret steps over whole clusters such as Thai consonants with their marks; Thai typed in a font without Thai falls back to a font made for Thai; earlier: Proportional Metrics in vertical type, `vpal`, #966; Cmd+Shift+C aligns centre off the Mac, a double-click on area type's bottom handle turns on Auto Size, #1940; MCP `add_text` exposes the existing `vertical` option for point, area and path type; horizontal remains the default; scores and hours unchanged; Vertical fullwidth question and exclamation marks keep their nominal glyph upright when the font has no vertical alternate; scores and hours unchanged. tab leaders are drawn in the tab's gap, #1877; type in symbols, pattern tiles, graph designs and opacity masks gets its layout bounds back on opening a native file, #1738; score unchanged; Escape while typing ends the edit, #1686; Select › Same on type, #1737; `justify` when creating point type, #1748; scores unchanged; OpenType stylistic sets, alternates, figure styles, superscript and subscript as character features, #1607; a wide word in non-rectangular area type moves down, #1615; scores unchanged; Character Styles New/Redefine capture the first selected character at run boundaries and end prior typing before capture; boundary and typing-history input tests and full workspace CI pass; scores and hours unchanged; Character styles retain explicit Auto leading, propagate resets and preserve local leading overrides; scores and hours unchanged; Linux font folders from fontconfig, #1529; commands and MCP `add_text` report area type that does not fit its frame, #1471; Tabs panel stop drags, #1458; Fit Headline in a frame one line tall, #1444; frames and paths beyond a billion points hold no text, #1451; scores unchanged; missing glyphs are looked for again after a font rescan, #1376; scores unchanged; Full-name font matching (#1258); Windows font-service QA pending; scores unchanged; Middle Eastern digit types: Character panel menu › Digits, `{digits}`; the font menu's script filter lists Thai fonts; Thai, Lao, Khmer and Myanmar lines break between words; the caret steps over whole clusters such as Thai consonants with their marks; Thai typed in a font without Thai falls back to a font made for Thai; earlier: Proportional Metrics in vertical type, `vpal`, #Line truncated
|
||||
|
||||
Type is Illustrator's largest single area by use (weight 13 of 105 across "Type core" and "Type advanced" in
|
||||
[target-app-parity.md](target-app-parity.md)). This checklist lists the features one by one. Status is from the
|
||||
@@ -35,8 +35,9 @@ against Illustrator's public documentation; **estimated** unless noted.
|
||||
| Fallback glyphs keep the text's weight and slant | done | #2491: a character from a fallback face is set in that family's face nearest the run's weight and slant; Bold Italic of a missing family is drawn Bold (Source Sans 3 has no Bold Italic) rather than Italic |
|
||||
| Colour fonts (OpenType SVG / COLR) | partial | |
|
||||
| Every-line and Single-line composers | done | tuned by eye, never compared side by side |
|
||||
| Fractional Widths | done | Character panel menu › Fractional Widths, `type.fractionalWidths`: per type object, and every frame of its threads. On by default and for documents from before it; saved only when off. Off, each character that takes space advances by a whole number of points, at least one, so small type does not run together. System Layout (the document-wide whole-pixel setting) remains a panel stub. Evidence: `tests::fractional_widths_off_rounds_positive_advances_to_whole_points`, `typecmd::area_tests::fractional_widths_is_set_per_object_and_saved_only_when_off`, `panels::character::tests::fractional_widths_menu_item_toggles_the_type_object` |
|
||||
| Optical Margin Alignment | done | Type › Optical Margin Alignment, `type.opticalMarginAlignment`: per type object, with one setting for all the frames of a thread, in point and area type of left-to-right and right-to-left paragraphs, and at the brackets of type on a path |
|
||||
| Optical Margin Alignment | done | Type › Optical Margin Alignment, `type.opticalMarginAlignment`: per type object, with one setting for all the frames of a thread, in point and area type of left-to-right paragraphs, and at the brackets of type on a path whose first paragraph runs left to right; right-to-left paragraphs of point and area type, and type on a path whose first paragraph runs right to left, do not hang |
|
||||
| System Layout | done | Character panel menu › System Layout, `type.systemLayout`: the whole document, off by default and for documents from before it, saved only when on. On, every text object advances by whole points (at least one when a character takes space). New point, area and path type, threaded frames, placed text, graph and dimension labels and pasted plain text inherit it. Evidence: `tests::system_layout_rounds_positive_advances_to_whole_points`, `typecmd::area_tests::system_layout_sets_the_document_and_every_text_object`, `panels::character::tests::system_layout_menu_item_toggles_the_document` |
|
||||
| Fractional Widths | done | Character panel menu › Fractional Widths, `type.fractionalWidths`: per type object, and every frame of its threads. On by default and for documents from before it; saved only when off. Off, each character that takes space advances by a whole number of points, at least one, so small type does not run together. Evidence: `tests::fractional_widths_off_rounds_positive_advances_to_whole_points`, `typecmd::area_tests::fractional_widths_is_set_per_object_and_saved_only_when_off`, `panels::character::tests::fractional_widths_menu_item_toggles_the_type_object` |
|
||||
| Roman Hanging Punctuation | done | Paragraph panel menu › Roman Hanging Punctuation, `text.setFormat {romanHangingPunctuation}` (#2756): per paragraph, Optical Margin Alignment's punctuation and amounts without the letters; paragraph styles carry it. Evidence: `tests::roman_hanging_punctuation_hangs_punctuation_but_not_letters`, `typecmd::area_tests::roman_hanging_punctuation_is_set_per_paragraph_and_saved_only_when_on` |
|
||||
| Hyphenation… and Justification… options | done | Hyphenation… (`ui.hyphenation`, `text.setFormat`) sets each paragraph's Words Longer Than, After First, Before Last, Hyphen Limit, Hyphenation Zone (Single-line Composer only) and Hyphenate Capitalized Words, and paragraph styles carry them (#2310). Justification… (`ui.justification`, `text.setFormat`, #2755) sets Word Spacing, Letter Spacing and Glyph Scaling (Minimum, Desired, Maximum), Auto Leading and Single Word Justification; Desired applies to every line, justified lines and the Every-line Composer use the ranges. Vertical type isn't glyph scaled; type on a path doesn't use them. Evidence: `crates/text/src/tests_justify.rs`, `dialogs::justification::tests` |
|
||||
| Tab stops and leaders; Tabs panel | partial | Tabs panel and stops with leaders in the model (`text.tabs.set`); a stop drags from where the press landed (#1458); leaders fill the tab's gap, repeated on a grid so they line up from line to line (#1877) |
|
||||
@@ -46,7 +47,7 @@ against Illustrator's public documentation; **estimated** unless noted.
|
||||
| Caret: the arrows and Delete step over whole clusters (Thai consonant with its marks, combining accents, emoji); Backspace removes one character | done | in text with right-to-left characters the arrows move in visual order and stop on both sides of a character drawn with no width, such as a zero width non-joiner |
|
||||
| Touch Type tool | done | moves, scales and rotates one character through its kerning, baseline shift, scales and rotation (`text.touchType`); the first character of a line and right-to-left characters move only up and down |
|
||||
| Retype (identify fonts in outlines/images) | missing | Illustrator's uses a cloud model |
|
||||
| Snap to Glyph | missing | menu stub |
|
||||
| Snap to Glyph | done | View › Snap to Glyph (`view.snapToGlyph`): with Smart Guides on, new point type and drawing tools snap to live-text baselines and glyph bounds (`Targets::for_drawing`, `tools::text_tests::snap_to_glyph_lines_up_new_point_type_with_a_baseline`) |
|
||||
| Thai, Lao, Khmer, Myanmar: shaping (marks, reordering), lines broken between words, word-by-word caret and double-click | done | words found by ICU4X's line segmenter: dictionaries on the desktop, LSTM models on the web |
|
||||
| Middle Eastern: bidirectional layout, Paragraph Direction | done | |
|
||||
| Middle Eastern: digit types (Character panel menu › Digits: Default, Arabic, Hindi, Farsi) | done | `text.setFormat` / `text.setRangeStyle {digits}`; the text keeps the typed digits, the glyphs and SVG export follow the style |
|
||||
@@ -54,8 +55,10 @@ against Illustrator's public documentation; **estimated** unless noted.
|
||||
| CJK: input methods (marked text, candidate window) | done | |
|
||||
| CJK: kinsoku (Hard, Soft, None), Line-end Punctuation Half Width, tate-chu-yoko (auto) | done / partial | custom kinsoku sets, the Mojikumi Settings dialog and the other mojikumi sets missing |
|
||||
| CJK: Proportional Metrics (`palt` in horizontal type, `vpal` in vertical type) | done | #966 |
|
||||
| CJK: manual tate-chu-yoko | done | Character panel menu › Tate-chu-yoko (`text.setFormat` / `text.setRangeStyle {tateChuYoko}`), with Show East Asian Options: marked characters stand side by side across one em of a vertical column, squeezed to the em when wider; two or three half-width digits still do so without the mark; horizontal type keeps the mark and does not move them. Up/Down and Left/Right settings remain. Evidence: `tests_vertical::manual_tate_chu_yoko_sets_marked_characters_across_one_em`, `typecmd::tate_chu_yoko_is_a_character_attribute_saved_only_when_on` |
|
||||
| CJK: ruby, manual tate-chu-yoko | partial | ruby (ふりがな) for live text (`type.ruby`): a reading over a byte range, above (right of the column in vertical type) or below, start/centre/end alignment, size, overhang or squeeze; saved natively, laid out with its line growing, drawn on the canvas, in SVG and PDF (as outlines where ruby is present); manual tate-chu-yoko missing | #633 |
|
||||
| No Break | done | Character panel menu (`text.setFormat` / `text.setRangeStyle {noBreak}`): the marked characters stay on one line, including across a space; a run that does not fit after earlier text moves together, and a run longer than the line stays together. Evidence: `layout::wrapping_tests::no_break_keeps_marked_characters_on_one_line`, `tests::no_break_keeps_marked_words_on_one_line`, `typecmd::no_break_is_a_character_attribute_saved_only_when_on` |
|
||||
| CJK: ruby | missing | #633 |
|
||||
| Inline symbols in text | beyond Illustrator | not scored |
|
||||
| Align Stroke (inside, outside) on live type's character stroke | beyond Illustrator | not scored; `stroke.set {align}` and `text.setRangeStyle {strokeOptions: {align}}`; saved natively, drawn around the glyphs on the canvas and in PDF, EPS and SVG (live text, stroke on the glyph outlines); visual bounds grow with it (#2294) |
|
||||
|
||||
@@ -65,6 +68,9 @@ Character Styles menu New/Redefine and footer New capture the first selected cha
|
||||
|
||||
| Date | Change | Summary |
|
||||
|---|---|---|
|
||||
| 2026-10-21 | minor | Snap to Glyph marked done in the checklist (#3124); scores unchanged at this rounding |
|
||||
| 2026-10-21 | minor | Manual Tate-chu-yoko: Character panel menu marks characters that stand across one em of a vertical column; ruby and the up/down settings remain; scores unchanged |
|
||||
| 2026-10-21 | minor | System Layout: Character panel menu sets whole-point advances for every text object in the document (off by default); scores and hours unchanged |
|
||||
| 2026-10-22 | minor | Ruby (ふりがな) for live text: `type.ruby` sets/removes a reading over a byte range, above or below (right/left of the column in vertical type), aligned, sized and overhanging or squeezed; saved natively, laid out with line growth, drawn on the canvas and in SVG/PDF (outlines where ruby is present); scores unchanged |
|
||||
| 2026-10-21 | minor | Fractional Widths: Character panel menu turns whole-point advances on or off per type object (on by default); System Layout remains a stub; scores and hours unchanged |
|
||||
| 2026-10-21 | minor | Type on a path threads, mixed with area type in one thread: its text that doesn't fit flows on into the next frame, and its red out port, just past its end bracket, loads the Selection tool with that text as area type's does; a new frame threaded from it at a point is type on a path of its shape; scores unchanged |
|
||||
|
||||
+2
-1
@@ -111,7 +111,7 @@ tools, never checked side by side) isn't captured row by row.
|
||||
| Spacing guides (equal distances) | partial | for moves and bounding-box resizes (#394); not while drawing |
|
||||
| Snapping tolerance preference | done | |
|
||||
| Snap to Point, Snap to Grid, Snap to Pixel; Pixel Preview | done | #1840: with Snap to Grid on, anchors and objects snap to the grid even when Snap to Pixel is also ticked (#1816 waits for the reporter) |
|
||||
| Snap to Glyph | missing | menu stub |
|
||||
| Snap to Glyph | done | View › Snap to Glyph (`view.snapToGlyph`); new type and drawing snap to live-text baselines and glyph bounds when Smart Guides are on (#3124) |
|
||||
| Tangent and perpendicular snapping for line endpoints (new in 30.0) | missing | |
|
||||
| Snapping panel/popover consolidating the snap options (30.0) | missing | |
|
||||
| Customisable rotation snap angle (#973) | missing | Illustrator: Constrain Angle and construction angles only |
|
||||
@@ -274,6 +274,7 @@ re-measure of the panels added since. Slider rails show on Medium Dark (#1808, #
|
||||
| 2026-10-21 | minor | 3D: original Standard, Diffuse, Top Left and Right lighting presets; command access, effective-setting recognition and preview/history; scores and estimates unchanged |
|
||||
| 2026-10-21 | minor | G1: one selected clip group's Properties panel has Edit Clipping Path and Edit Contents at its top (public doc cited in target-app-parity.md). Scores unchanged. |
|
||||
| 2026-10-19 | minor | Distribute Objects and Distribute Spacing space the selected ruler guides across the axis with the objects, as items with no size, and two or more guides selected alone (#1597 in part); with a key guide and a spacing, the guide stays put and the other items are spaced from it (key guide from #3165); the Distribute Spacing value is enabled for a key guide; scores unchanged |
|
||||
| 2026-10-21 | minor | Snap to Glyph marked done (#3124); scores unchanged |
|
||||
| 2026-10-20 | minor | The selection tools (Selection, Direct Selection, Group Selection) take a clipping path on its outline, within the selection tolerance, before the art it clips, so its segments can be dragged where the art covers the mask's edge; Select Behind lists the same, and the eyedropper and the tools that act on what is drawn are unchanged. Doc and tool regression tests. Scores unchanged. |
|
||||
| 2026-10-20 | minor | Polygon and Star exact-size placement remembers the chosen count for later drags and dialog openings; Cancel preserves the previous count; existing opening gestures retained; scores and hours unchanged. |
|
||||
| 2026-10-20 | minor | Live trace result bounds and selection highlights exclude the retained bitmap except in source-image views; scores and hours unchanged. |
|
||||
|
||||
Reference in new issue
Block a user