You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The items we used in programmatic animation engine often involve subtypes and supertypes.
For example, an Sphere is actually expressed with a Surface, while a Surface is actually a MeshItem.
In OOP languages, this is often described with inheriting, but Rust is not OOP.
So, instead, in ranim-items, this is expressed by using From/Into conversions:
All item types are individual, flattened structs with From/Into impls to convert from subtypes to supertypes semantically.
1. Massive boilerplate
VItems like Arc, Circle, Ellipse all share the same fields (basis, fill_rgba, stroke_rgba, stroke_width) and the same trait impls (FillColor, StrokeColor, Opacity, ShiftTransform, etc.). Each type must redeclare these fields and re-derive/re-impl the same traits, plus all the From/Into and Extract logic.
2. Missing interpolation levels
All items can only interpolate with themselves at the low-level point data (VPointVec). There is no parameter-level interpolation (e.g., interpolating radius or angle directly).
3. Tedious type conversions
Subtype → supertype requires manually implementing a large number of From/Into conversions.
4. Atomic vs. Compound items at the same level
Some items convert 1:1 into a CoreItem (e.g., VItem), while others produce multiple CoreItems via Extract (e.g., TextItem, TypstText, SvgItem). These are conceptually different levels of abstraction but are treated at the same level in the current design.
Note
Latest thinking: #154 (comment)
Problem
The items we used in programmatic animation engine often involve subtypes and supertypes.
For example, an
Sphereis actually expressed with aSurface, while aSurfaceis actually aMeshItem.In OOP languages, this is often described with inheriting, but Rust is not OOP.
So, instead, in ranim-items, this is expressed by using
From/Intoconversions:graph LR Square --> Rectangle Square --> RegularPolygon Square --> Parallelogram Rectangle --> Parallelogram Rectangle --> Polygon Parallelogram --> Polygon RegularPolygon --> Polygon Circle --> Ellipse Circle --> Arc Circle --> EllipticArc Ellipse --> EllipticArc Arc --> EllipticArc ArcBetweenPoints --> Arc Polygon --> VItem Parallelogram --> VItem EllipticArc --> VItem Ellipse --> VItem Arc --> VItem Circle --> VItem Line --> VItem Square --> VItem Rectangle --> VItem VItem --> CoreVItem Sphere --> Surface Surface --> MeshItem MeshItem --> CoreMeshItem TextItem --> VecVItem TypstText --> VecVItem SvgItem --> VecVItem -.- VItemAll item types are individual, flattened structs with
From/Intoimpls to convert from subtypes to supertypes semantically.1. Massive boilerplate
VItems likeArc,Circle,Ellipseall share the same fields (basis,fill_rgba,stroke_rgba,stroke_width) and the same trait impls (FillColor,StrokeColor,Opacity,ShiftTransform, etc.). Each type must redeclare these fields and re-derive/re-impl the same traits, plus all theFrom/IntoandExtractlogic.2. Missing interpolation levels
All items can only interpolate with themselves at the low-level point data (
VPointVec). There is no parameter-level interpolation (e.g., interpolatingradiusorangledirectly).3. Tedious type conversions
Subtype → supertype requires manually implementing a large number of
From/Intoconversions.4. Atomic vs. Compound items at the same level
Some items convert 1:1 into a
CoreItem(e.g.,VItem), while others produce multipleCoreItems viaExtract(e.g.,TextItem,TypstText,SvgItem). These are conceptually different levels of abstraction but are treated at the same level in the current design.