Skip to content

Creative Studio: Vector Graphics & 3D Spatial Design Canvas ​

The creative_studio reference application demonstrates Project Strata's capabilities for creative design software, infinite 2D vector drafting canvases, and unified 3D spatial viewports.

Inspired by industry design tools (Figma, Illustrator, Blender), it demonstrates subpixel Bezier curve evaluation, generational state arenas for zero-cost undo/redo snapshots, property inspectors, layer hierarchies, and mixed 2D/3D rendering within a single UI framework.


Architectural Topology ​

text
┌────────────────────────────────────────────────────────────────────────┐
│                        Creative Studio Layout                          │
├────────────────────────────────────────────────────────────────────────┤
│                                                                        │
│   ┌────────────────────────────────────────────────────────────────┐   │
│   │                 Top Bar & Application Menus                    │   │
│   │    (Document Title, Zoom Ratio, History Undo/Redo, Export)     │   │
│   └────────────────────────────────────────────────────────────────┘   │
│                                                                        │
│   ┌───────────────┬────────────────────────────────┬───────────────┐   │
│   │ Layers Panel  │       Infinite Viewport        │  Properties   │   │
│   │               │                                │  Panel        │   │
│   │ - Frame Root  │   ┌────────────────────────┐   │               │   │
│   │   - Card Art  │   │  2D Vector Artboard    │   │ - Position    │   │
│   │   - Vector Pth│   │  (Analytical Béziers)  │   │ - Dimensions  │   │
│   │   - Text Node │   └────────────────────────┘   │ - Fill / Color│   │
│   │ - 3D Mesh     │   ┌────────────────────────┐   │ - Corner R    │   │
│   │               │   │  Unified 3D <Canvas3D> │   │ - Opacity     │   │
│   │               │   │  (PBR Mesh + Shaders)  │   │ - Blend Modes │   │
│   │               │   └────────────────────────┘   │               │   │
│   └───────────────┴────────────────────────────────┴───────────────┘   │
│                                                                        │
│   ┌────────────────────────────────────────────────────────────────┐   │
│   │                 Floating Vector Tool Dock                      │   │
│   │     [Select] [Frame] [Rectangle] [Ellipse] [Text] [Pan]        │   │
│   └────────────────────────────────────────────────────────────────┘   │
│                                                                        │
└────────────────────────────────────────────────────────────────────────┘

1. Reactive State Model & Generational Arenas (state.rs) ​

Design applications handle deeply nested document trees containing tens of thousands of vector shapes, paths, groups, and transforms.

rust
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Tool {
    Select,
    Frame,
    Rectangle,
    Ellipse,
    Text,
    Pan,
}

#[derive(Clone, Debug, PartialEq)]
pub struct Shape {
    pub id: String,
    pub name: String,
    pub shape_type: &'static str,
    pub x: f32,
    pub y: f32,
    pub width: f32,
    pub height: f32,
    pub fill_color: String,
    pub corner_radius: f32,
    pub opacity: f32,
    pub is_locked: bool,
    pub is_visible: bool,
}

#[derive(Clone)]
pub struct StudioState {
    pub active_tool: Signal<Tool>,
    pub zoom_level: Signal<f32>,
    pub pan_offset: Signal<(f32, f32)>,
    pub selected_shape_id: Signal<Option<String>>,
    pub shapes: Signal<Vec<Shape>>,
}

Generational History Snapshots ​

Rather than serializing entire document state on every drag or stroke, Strata utilizes an immutable generational arena. Each mutation generates a shallow structural delta, enabling $O(1)$ instantaneous undo and redo across thousands of historical operations with minimal memory retention.


2. Infinite Vector Viewport (canvas_viewport.rs) ​

The 2D infinite canvas supports fluid multi-touch panning and subpixel zooming from $2%$ up to $6400%$:

  • Analytical GPU Béziers (strata_gpu_path): Evaluates cubic and quadratic Bézier segments directly in fragment shaders, eliminating CPU triangulation bottlenecks and jagged polygon silhouettes at high zoom levels.
  • Dynamic Background Grid: Renders an infinite dot grid using radial gradient shaders (background-size: 24px 24px), maintaining crisp alignment regardless of pan offset.
  • Interactive Selection Rings: Selected shapes display active bounding boxes with glowing focus rings (ring-2 ring-indigo-500) and live dimension pill overlays (Artboard (480x320)).

3. Unified 3D Spatial Viewport (viewport_3d.rs) ​

A unique capability of Project Strata is its Unified 3D rendering pipeline: high-level Three.js-style PBR components and low-level custom GLSL shaders execute within the exact same scene graph:

rust
#[component]
pub fn Viewport3D(state: StudioState) -> View {
    let rotation = use_signal(0.45);
    let elapsed = use_signal(1.28);

    rsx! {
        <Canvas3D class="w-full h-full rounded-2xl border border-neutral-800/80 bg-neutral-950/80 shadow-2xl overflow-hidden">
            <PerspectiveCamera fov={50.0} position={[0.0, 3.0, 7.0]} target={[0.0, 0.0, 0.0]} />
            <AmbientLight color="#ffffff" intensity={0.4} />
            <DirectionalLight position={[6.0, 10.0, 6.0]} intensity={1.6} cast_shadow={true} />

            {/* 1. High-Level PBR Box Primitive */}
            <Mesh position={[-2.2, 0.0, 0.0]} rotation={[0.0, rotation.get(), 0.0]}>
                <BoxGeometry width={2.0} height={2.0} depth={2.0} />
                <StandardMaterial color="#6366f1" roughness={0.18} metalness={0.82} />
            </Mesh>

            {/* 2. Low-Level Custom GLSL Shader Mesh within the EXACT same scene */}
            <Mesh position={[2.2, 0.0, 0.0]} rotation={[rotation.get(), 0.0, 0.0]}>
                <SphereGeometry radius={1.2} width_segments={36} height_segments={36} />
                <ShaderMaterial
                    glsl_fragment="
                        precision highp float;
                        varying vec3 v_normal;
                        uniform float u_time;
                        void main() {
                            vec3 color = 0.5 + 0.5 * sin(u_time * 2.0 + v_normal * 3.14159);
                            gl_FragColor = vec4(color, 1.0);
                        }
                    "
                    uniforms={dynamic!({ "u_time": elapsed.get() })}
                />
            </Mesh>
        </Canvas3D>
    }
}

The unified pipeline renders both meshes in a single depth-tested GPU draw call, allowing spatial product prototypes and 3D icons to live alongside 2D interface layouts without compositor boundaries.


4. Tool Dock & Inspector Panels ​

Floating Tool Dock (tool_dock.rs) ​

Floating pill dock centered at the bottom of the viewport:

  • Tool triggers: Select (V), Frame (F), Rectangle (R), Ellipse (O), Text (T), and Pan (H).
  • Active tool indicator with spring-animated selection highlights.

Layers Hierarchy Panel (layers_panel.rs) ​

  • Visual tree reflecting the spatial stacking order (z-index) of canvas elements.
  • Per-node visibility toggles and lock states to prevent accidental modification during multi-layer drafting passes.

Property Inspector Panel (properties_panel.rs) ​

Contextual sidebar binding directly to the selected element's signals:

  • Coordinates: $X$ and $Y$ positioning inputs.
  • Geometry: Width, height, and corner radius slider controls.
  • Appearance: Fill color picker hex input, opacity slider ($0%\text{--}100%$), and stroke properties.

Performance Characteristics ​

Measured on Linux (x86_64, Vulkan 1.3, 1440p 120Hz display):

CharacteristicMeasured PerformanceIndustry Standard (Web/Chromium)
Canvas Pan & Zoom LatencySub-1 ms (Native 120 FPS)8-16 ms (occasional dropped frames)
Complex Vector Paths (10k nodes)1.8 ms GPU presentation45 ms (CPU SVG triangulation)
Mixed 2D/3D Swapchain OverheadZero (Shared Vulkan Context)Context copy via WebGL canvas readback
Idle Memory Consumption18.2 MB180-320 MB

Running the Showcase ​

bash
# Launch Creative Studio
cargo run --release --example creative_studio

Zero Chromium. Pure Rust. Native 120 FPS.