# all-iver/shapes2d architecture

> Architecture diagram of the GitHub repository all-iver/shapes2d, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/all-iver/shapes2d
- Repository: https://github.com/all-iver/shapes2d

## Overview

##### Main Components Organization

a) Editor Integration Layer
- Unity Editor integration components
- CustomHandles, ShapeEditor, and MenuItems
- How it extends Unity's editor functionality

- PolyMap and Shapes2DPrefs components
- Connection to shader system

c) Shader Processing Layer
- Shader components (Common, Ellipse, Path, Polygon, Rectangle, Triangle)

d) Resource Management Layer
- Prefab management system
- Material management
- Asset template handling

##### Component Relationships

**Editor Layer → Core Layer → Shader Layer → Resource Layer**

Use these visual elements:

##### Specific Component Details

Editor Integration:
**[Unity Editor] ←→ [CustomHandles]**
- [ShapeEditor]
- [MenuItems]

Core System:
- ↓
**[Shapes2DPrefs]**

Shader Pipeline:

##### Demo Integration (Optional Layer)
How the demo scenes integrate with the main system:
- Showcase
- Simple Effect
- Stress Test
- UI Examples

##### Important Elements

- Clear distinction between editor-time and runtime components
- Asset generation pipeline flow
- Prefab template system
- Material management system

##### Notes for Implementation

- The tool's integration with Unity's editor
- The shader-based rendering system
- The resource management system

Remember to indicate that this is a Unity Editor extension, which means it operates primarily within the Unity Editor environment but produces runtime assets for Unity games and applications.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef editor fill:#a8d1f0,stroke:#333
    classDef core fill:#90EE90,stroke:#333
    classDef shader fill:#DDA0DD,stroke:#333
    classDef resource fill:#FFB347,stroke:#333
    classDef demo fill:#FFE4B5,stroke:#333

    %% Editor Integration Layer
    subgraph EditorLayer["Editor Integration Layer"]
        UnityEditor["Unity Editor"]
        CustomHandles["Custom Handles"]
        ShapeEditor["Shape Editor"]
        MenuItems["Menu Items"]
    end

    %% Core Shape Generation Layer
    subgraph CoreLayer["Core Shape Generation Layer"]
        Shape["Shape Component"]
        PolyMap["PolyMap"]
        Shapes2DPrefs["Shapes2D Prefs"]
    end

    %% Shader Processing Layer
    subgraph ShaderLayer["Shader Processing Layer"]
        CommonShader["Common Shader"]
        ShapeShader["Shape Shader"]
        
        subgraph ShapeSpecific["Shape-Specific Shaders"]
            EllipseShader["Ellipse"]
            PathShader["Path"]
            PolygonShader["Polygon"]
            RectangleShader["Rectangle"]
            TriangleShader["Triangle"]
        end
    end

    %% Resource Management Layer
    subgraph ResourceLayer["Resource Management Layer"]
        MaterialMgmt["Material Management"]
        PrefabMgmt["Prefab Management"]
        AssetTemplate["Asset Template"]
    end

    %% Demo Integration Layer
    subgraph DemoLayer["Demo Integration"]
        FlappyShapes["Flappy Shapes"]
        Showcase["Showcase"]
        SimpleEffect["Simple Effect"]
        StressTest["Stress Test"]
        UIExamples["UI Examples"]
    end

    %% Relationships
    UnityEditor --> CustomHandles
    UnityEditor --> ShapeEditor
    UnityEditor --> MenuItems
    
    CustomHandles --> Shape
    ShapeEditor --> Shape
    MenuItems --> Shape
    
    Shape --> PolyMap
    Shape --> Shapes2DPrefs
    PolyMap --> ShapeShader
    
    CommonShader --> ShapeShader
    ShapeSpecific --> ShapeShader
    
    ShapeShader --> MaterialMgmt
    MaterialMgmt --> PrefabMgmt
    PrefabMgmt --> AssetTemplate
    
    Shape --> DemoLayer

    %% Styles Application
    class UnityEditor,CustomHandles,ShapeEditor,MenuItems editor
    class Shape,PolyMap,Shapes2DPrefs core
    class CommonShader,ShapeShader,EllipseShader,PathShader,PolygonShader,RectangleShader,TriangleShader shader
    class MaterialMgmt,PrefabMgmt,AssetTemplate resource
    class FlappyShapes,Showcase,SimpleEffect,StressTest,UIExamples demo

    %% Click Events
    click CustomHandles "https://github.com/all-iver/shapes2d/blob/master/Assets/Shapes2D/Editor/CustomHandles.cs"
    click ShapeEditor "https://github.com/all-iver/shapes2d/blob/master/Assets/Shapes2D/Editor/ShapeEditor.cs"
    click MenuItems "https://github.com/all-iver/shapes2d/blob/master/Assets/Shapes2D/Editor/MenuItems.cs"
    click Shape "https://github.com/all-iver/shapes2d/blob/master/Assets/Shapes2D/Scripts/Shape.cs"
    click PolyMap "https://github.com/all-iver/shapes2d/blob/master/Assets/Shapes2D/Scripts/PolyMap.cs"
    click Shapes2DPrefs "https://github.com/all-iver/shapes2d/blob/master/Assets/Shapes2D/Scripts/Shapes2DPrefs.cs"
    click CommonShader "https://github.com/all-iver/shapes2d/blob/master/Assets/Shapes2D/Shaders/Common.cginc"
    click ShapeShader "https://github.com/all-iver/shapes2d/blob/master/Assets/Shapes2D/Shaders/Shape.shader"
    click EllipseShader "https://github.com/all-iver/shapes2d/blob/master/Assets/Shapes2D/Shaders/Ellipse.cginc"
    click PathShader "https://github.com/all-iver/shapes2d/blob/master/Assets/Shapes2D/Shaders/Path.cginc"
    click PolygonShader "https://github.com/all-iver/shapes2d/blob/master/Assets/Shapes2D/Shaders/Polygon.cginc"
    click RectangleShader "https://github.com/all-iver/shapes2d/blob/master/Assets/Shapes2D/Shaders/Rectangle.cginc"
    click TriangleShader "https://github.com/all-iver/shapes2d/blob/master/Assets/Shapes2D/Shaders/Triangle.cginc"
    click MaterialMgmt "https://github.com/all-iver/shapes2d/blob/master/Assets/Shapes2D/Resources/Shapes2D/Materials/Shape.mat"
    click PrefabMgmt "https://github.com/all-iver/shapes2d/tree/master/Assets/Shapes2D/Resources/Shapes2D/Prefabs"
    click AssetTemplate "https://github.com/all-iver/shapes2d/blob/master/Assets/Shapes2D/Resources/Shapes2D/Sprite Template.prefab"
    click FlappyShapes "https://github.com/all-iver/shapes2d/tree/master/Assets/Shapes2D/Demos/Flappy Shapes"
    click Showcase "https://github.com/all-iver/shapes2d/tree/master/Assets/Shapes2D/Demos/Showcase"
    click SimpleEffect "https://github.com/all-iver/shapes2d/tree/master/Assets/Shapes2D/Demos/Simple Effect"
    click StressTest "https://github.com/all-iver/shapes2d/tree/master/Assets/Shapes2D/Demos/Stress Test"
    click UIExamples "https://github.com/all-iver/shapes2d/tree/master/Assets/Shapes2D/Demos/UI Examples"
```
