mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-26 04:51:52 +00:00
Transform: Align New Objects to Pixel Grid makes new paths pixel-aligned
Document Setup gains alignNewObjectsToPixelGrid. When it is on, every path or compound path drawn in the document (shape tools, Pen, Curvature, Pencil, Paintbrush, Blob Brush, grids, flares and add-on shapes) gets the pixel-aligned property and snaps in the same undo step. Text, paste, duplicate, Place and import are not affected. - The Transform panel menu has an Align New Objects to Pixel Grid item for the active document. - New Document's Advanced Options has the checkbox; the Mobile and Web presets turn it on, other presets and older saved presets leave it off, and file.new, Save Preset and Recent keep it. - The setting is saved with the document only when it is on. https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/pixel-preview-mode-for-web-graphics.html Docs: docs/mcp.md, docs/target-app-parity.md, docs/ui-parity.md.
This commit is contained in:
@@ -22,6 +22,16 @@ pub(crate) fn can_align(n: &Node) -> bool {
|
||||
matches!(n.kind, NodeKind::Path { guide: false, .. } | NodeKind::Compound { .. })
|
||||
}
|
||||
|
||||
/// For an object being drawn into `d`: when the document's Align New Objects to Pixel Grid is on
|
||||
/// and [`can_align`] accepts `n`, turn `n`'s pixel-aligned property on. The edit that adds it snaps
|
||||
/// it to the pixel grid ([`refresh`]). Pasted, duplicated, placed and imported objects do not come
|
||||
/// through here.
|
||||
pub(crate) fn align_new_object(d: &Document, n: &mut Node) {
|
||||
if d.setup.align_new_objects_to_pixel_grid && can_align(n) {
|
||||
n.extras_mut().pixel_aligned = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// `object.setPixelAligned`: turn the pixel-aligned property of the objects given (or the selected
|
||||
/// objects) on or off. Turning it on snaps them to the pixel grid at once. Every object must be
|
||||
/// one [`can_align`] accepts, else nothing changes. When every object already has the value, the
|
||||
|
||||
Reference in New Issue
Block a user