Code review previous commit, and improve G/R/S hints

This commit is contained in:
Keavon Chambers 2023-03-26 11:49:25 -07:00
parent 959e790cdf
commit d6ab417bcb
18 changed files with 135 additions and 83 deletions

View file

@ -39,4 +39,3 @@ node-macro = {path = "../node-macro"}
specta.workspace = true
specta.optional = true
once_cell = { version = "1.17.0", default-features = false, optional = true }
# forma = { version = "0.1.0", package = "forma-render" }

View file

@ -20,8 +20,7 @@ fn unit_square(_input: ()) -> VectorData {
super::VectorData::from_subpaths(vec![Subpath::new_ellipse(DVec2::ZERO, DVec2::ONE)])
}
// TODO: I removed the Arc requirement we shouuld think about when it makes sense to use its
// vs making a generic value node
// TODO(TrueDoctor): I removed the Arc requirement we should think about when it makes sense to use it vs making a generic value node
#[derive(Debug, Clone)]
pub struct PathGenerator<Mirror> {
mirror: Mirror,

View file

@ -1,9 +1,8 @@
use crate::uuid::ManipulatorGroupId;
use super::consts::ManipulatorType;
use super::id_vec::IdBackedVec;
use super::manipulator_group::ManipulatorGroup;
use super::manipulator_point::ManipulatorPoint;
use crate::uuid::ManipulatorGroupId;
use alloc::string::String;
use alloc::vec;

View file

@ -3,6 +3,7 @@ use crate::{uuid::ManipulatorGroupId, Color};
use bezier_rs::ManipulatorGroup;
use dyn_any::{DynAny, StaticType};
use glam::{DAffine2, DVec2};
/// [VectorData] is passed between nodes.
@ -17,7 +18,7 @@ pub struct VectorData {
}
impl VectorData {
/// An empty subpath with no data, an identity transform and a black fill.
/// An empty subpath with no data, an identity transform, and a black fill.
pub const fn empty() -> Self {
Self {
subpaths: Vec::new(),
@ -77,15 +78,15 @@ impl VectorData {
}
/// Compute the pivot of the layer in layerspace (the coordinates of the subpaths)
pub fn layerspace_pivot(&self, normalised_pivot: DVec2) -> DVec2 {
pub fn layerspace_pivot(&self, normalized_pivot: DVec2) -> DVec2 {
let [bounds_min, bounds_max] = self.nonzero_bounding_box();
let bounds_size = bounds_max - bounds_min;
bounds_min + bounds_size * normalised_pivot
bounds_min + bounds_size * normalized_pivot
}
/// Compute the pivot in local space with the current transform applied
pub fn local_pivot(&self, normalised_pivot: DVec2) -> DVec2 {
self.transform.transform_point2(self.layerspace_pivot(normalised_pivot))
pub fn local_pivot(&self, normalized_pivot: DVec2) -> DVec2 {
self.transform.transform_point2(self.layerspace_pivot(normalized_pivot))
}
}