# sc-workshop/supercellflash architecture

> Architecture diagram of the GitHub repository sc-workshop/supercellflash, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sc-workshop/supercellflash
- Repository: https://github.com/sc-workshop/supercellflash

## Overview

##### Main Components Identification

a. Core Library Layer (supercell-flash)
- Schema Definitions (FlatBuffers)
- Objects
- Transform System
- File Handling
- Type System

b. Tools Layer
- Test Tool
- Texture Tool

##### Component Relationships

A. Core Components (Top to Bottom):
**┌─ Schema Definitions (.fbs files) ─┐**
- DataStorage                   │
- MovieClips                    │
- Textures                      │
- ┘
- ↓
**┌─ Display Object System ──────────┐**
- MovieClip                    │
- TextField                    │
- ┘
- ↓
**┌─ Transform System ───────────────┐**
- Matrix2D                     │
- ColorTransform               │
- MatrixBank                   │
- ┘
- ↓
**┌─ File Handling ─────────────────┐**
- SupercellSWF                │
- SWFStream                   │
- SWFContainer               │
- ┘

##### Important Details

a. Schema Layer:
- FlatBuffers schema files (.fbs) as the data definition layer
- Schemas to their corresponding C++ implementations

b. Object Hierarchy:
- Inheritance relationships between display objects
- Relationship between MovieClip and MovieClipFrame

c. Transform System:
- Matrix2D and ColorTransform as fundamental transformation components
- MatrixBank's role in optimization

d. File Handling:
- Demonstrate the relationship between SupercellSWF and its components
- How SWFStream and SWFContainer interact

##### Implementation Notes

- The modular nature of the library
- Clear separation between schema definitions and implementations
- The hierarchical structure of display objects
- The relationship between core library and tools

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Schema Definitions Layer
    subgraph Schemas
        DataStorage["DataStorage.fbs"]
        MovieClipsSchema["MovieClips.fbs"]
        ShapesSchema["Shapes.fbs"]
        TexturesSchema["Textures.fbs"]
    end

    %% Display Object System Layer
    subgraph DisplayObjects
        DisplayObject["DisplayObject"]
        MovieClip["MovieClip"]
        Shape["Shape"]
        TextField["TextField"]
    end

    %% Transform System Layer
    subgraph Transform
        Matrix2D["Matrix2D"]
        ColorTransform["ColorTransform"]
        MatrixBank["MatrixBank"]
    end

    %% File Handling Layer
    subgraph FileHandling
        SupercellSWF["SupercellSWF"]
        SWFStream["SWFStream"]
        SWFContainer["SWFContainer"]
    end

    %% Tools Layer
    subgraph Tools
        TestTool["Test Tool"]
        TextureTool["Texture Tool"]
    end

    %% Texture System
    subgraph TextureSystem
        SWFTexture["SWFTexture"]
        ExportName["ExportName"]
    end

    %% Core Interface
    subgraph CoreInterface
        FlashMain["flash.h"]
        FlashTags["flash_tags.h"]
    end

    %% Relationships
    Schemas --> DisplayObjects
    DisplayObjects --> Transform
    Transform --> FileHandling
    FileHandling --> Tools
    TextureSystem --> FileHandling
    CoreInterface --> FileHandling

    %% Inheritance relationships
    DisplayObject --> MovieClip
    DisplayObject --> Shape
    DisplayObject --> TextField

    %% Click events for component mapping
    click DataStorage "https://github.com/sc-workshop/SupercellFlash/blob/main/supercell-flash/sc2_schemas/DataStorage.fbs"
    click MovieClipsSchema "https://github.com/sc-workshop/SupercellFlash/blob/main/supercell-flash/sc2_schemas/MovieClips.fbs"
    click ShapesSchema "https://github.com/sc-workshop/SupercellFlash/blob/main/supercell-flash/sc2_schemas/Shapes.fbs"
    click TexturesSchema "https://github.com/sc-workshop/SupercellFlash/blob/main/supercell-flash/sc2_schemas/Textures.fbs"
    click DisplayObject "https://github.com/sc-workshop/SupercellFlash/blob/main/supercell-flash/source/flash/display_object/DisplayObject.h"
    click MovieClip "https://github.com/sc-workshop/SupercellFlash/blob/main/supercell-flash/source/flash/display_object/MovieClip.h"
    click Shape "https://github.com/sc-workshop/SupercellFlash/blob/main/supercell-flash/source/flash/display_object/Shape.h"
    click TextField "https://github.com/sc-workshop/SupercellFlash/blob/main/supercell-flash/source/flash/display_object/TextField.h"
    click Matrix2D "https://github.com/sc-workshop/SupercellFlash/blob/main/supercell-flash/source/flash/transform/Matrix2D.h"
    click ColorTransform "https://github.com/sc-workshop/SupercellFlash/blob/main/supercell-flash/source/flash/transform/ColorTransform.h"
    click MatrixBank "https://github.com/sc-workshop/SupercellFlash/blob/main/supercell-flash/source/flash/transform/MatrixBank.h"
    click SupercellSWF "https://github.com/sc-workshop/SupercellFlash/blob/main/supercell-flash/source/flash/objects/SupercellSWF.h"
    click SWFStream "https://github.com/sc-workshop/SupercellFlash/blob/main/supercell-flash/source/flash/types/SWFStream.hpp"
    click SWFContainer "https://github.com/sc-workshop/SupercellFlash/blob/main/supercell-flash/source/flash/types/SWFContainer.hpp"
    click TestTool "https://github.com/sc-workshop/SupercellFlash/tree/main/tools/test-tool"
    click TextureTool "https://github.com/sc-workshop/SupercellFlash/tree/main/tools/texture-tool"
    click FlashMain "https://github.com/sc-workshop/SupercellFlash/blob/main/supercell-flash/source/flash/flash.h"
    click FlashTags "https://github.com/sc-workshop/SupercellFlash/blob/main/supercell-flash/source/flash/flash_tags.h"
    click SWFTexture "https://github.com/sc-workshop/SupercellFlash/blob/main/supercell-flash/source/flash/objects/SWFTexture.h"
    click ExportName "https://github.com/sc-workshop/SupercellFlash/blob/main/supercell-flash/source/flash/objects/ExportName.h"

    %% Styling
    classDef schema fill:#FFE873
    classDef display fill:#6495ED
    classDef transform fill:#98FB98
    classDef file fill:#DDA0DD
    classDef tools fill:#F08080
    classDef texture fill:#87CEEB
    classDef core fill:#FFB6C1

    class DataStorage,MovieClipsSchema,ShapesSchema,TexturesSchema schema
    class DisplayObject,MovieClip,Shape,TextField display
    class Matrix2D,ColorTransform,MatrixBank transform
    class SupercellSWF,SWFStream,SWFContainer file
    class TestTool,TextureTool tools
    class SWFTexture,ExportName texture
    class FlashMain,FlashTags core
```
