mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-11 15:21:58 +00:00
The Perspective Selection tool shows the selection's bounding box in perspective; its handles scale in plane space (perspective.transform; Shift proportional, Alt from the centre). Alt-drag moves copies that stay attached, pressing 5 while dragging moves along the plane's normal (ToolKey::Digit, delivered by the canvas and MCP press_key), and the arrow keys nudge in perspective (perspective.nudge). Transform Again repeats the last perspective move or scale in plane space. Attachments (plane and depth) now live on the objects (Node.perspective), so copies, duplicates and pastes keep them; grids from older files hand theirs over. Homography moves to vectorcraft-geom. Hint-bar text for the tool. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
27 lines
1.1 KiB
Rust
27 lines
1.1 KiB
Rust
//! Perspective Grid attachments (Object › Perspective).
|
||
//!
|
||
//! The grid itself is document data (`Document.unknown["perspectiveGrid"]`, modelled by the tools
|
||
//! crate). Which plane an object lies on is kept on the object, so copies, duplicates and pastes
|
||
//! stay attached and deleted objects leave nothing stale behind.
|
||
|
||
use serde::{Deserialize, Serialize};
|
||
|
||
/// The plane an object in perspective lies on.
|
||
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
|
||
#[serde(rename_all = "camelCase")]
|
||
pub struct PerspectiveAttachment {
|
||
/// `left`, `right` or `ground`.
|
||
#[serde(default, skip_serializing_if = "String::is_empty")]
|
||
pub plane: String,
|
||
/// Where along the plane's normal (points) the parallel plane the object lies on is: 0 is the
|
||
/// grid plane in its original place.
|
||
#[serde(default, skip_serializing_if = "crate::skip::is_default")]
|
||
pub depth: f64,
|
||
}
|
||
|
||
impl PerspectiveAttachment {
|
||
pub fn new(plane: &str, depth: f64) -> Self {
|
||
Self { plane: plane.to_string(), depth: if depth.is_finite() { depth } else { 0.0 } }
|
||
}
|
||
}
|