# andresit1524/vector_display_2d architecture

> Architecture diagram of the GitHub repository andresit1524/vector_display_2d, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-03-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/andresit1524/vector_display_2d
- Repository: https://github.com/andresit1524/vector_display_2d

## Overview

##### What this project is (type + purpose)

So your “system” is not a web service; it’s a **Godot addon module** composed of:
- **Editor integration layer** (registering the plugin, adding the node type, handling shortcut)
- **Runtime node/component layer** (the actual node drawing vectors in-game)
- **Configuration/presets layer** (Resource for settings/presets)
- **Demo content** (example scenes/assets to show usage)

##### Read the file tree as architecture
From the tree:

- `addons/vector_display_2d/plugin.cfg`
Godot plugin manifest: tells Godot “this is an editor plugin”, name, script entrypoint, etc.

- `addons/vector_display_2d/plugin.gd`
**EditorPlugin** script: registers/unregisters custom types, may install input actions/shortcuts, and wires editor tooling.

- `addons/vector_display_2d/vector_display_2d.gd`
The core **`VectorDisplay2D` Node** implementation: binds to a target node + property (Vector2), draws it, applies settings, responds to toggle visibility.

- `addons/vector_display_2d/vector_display_settings.gd`

- `addons/vector_display_2d/vector_display_functions.gd`
Shared **pure functions / utilities**: vector math, arrowhead geometry, drawing helpers—used by the node and possibly by settings validation.

- `addons/vector_display_2d/display_shortcut.tres`
A **Resource** storing the shortcut binding; user edits it in the editor to change the toggle key.

- `demo_content/`
Non-core: sample scenes/images (README references `demo.png`, `demo_2.png`) to demonstrate the addon.

This is a classic Godot addon layout: **plugin entrypoint + node script + resource + helpers + editor-configurable assets**.

##### Godot host environment (external container)
- **Godot Editor (4.0+)**
- **Godot Runtime/Game (4.0+)**
These are “external systems” your addon plugs into.

##### Addon package (your system)
Inside a boundary labeled `addons/vector_display_2d`:

##### Editor Plugin Layer
- `plugin.cfg` (Plugin Manifest)
- `plugin.gd` (EditorPlugin: registers node type, installs shortcut resource, editor integration)

##### Runtime Node Layer
- `vector_display_2d.gd` (`VectorDisplay2D` Node: draws vectors in 2D)

##### Configuration / Presets Layer
- `vector_display_settings.gd` (`VectorDisplay2DSettings` Resource: parameters + preset saving)

##### Utilities Layer
- `vector_display_functions.gd` (math/drawing/arrowhead helpers)

##### Input/Shortcut Asset
- `display_shortcut.tres` (toggle visibility shortcut definition)

##### User project integration points (other “actors”)
Outside the addon boundary:
- **User Scene Tree** (their game scenes)
- **Target Node** (any node with a `Vector2` property, e.g., player with `velocity: Vector2`)
- **Property Binding** (the chosen property name/path)

- `demo_content` as “Example Scenes/Assets” connected to addon usage.

##### Godot Editor → plugin.cfg
- “discovers plugin metadata”

##### Godot Editor → plugin.gd
- “loads EditorPlugin on enable”

##### plugin.gd → Godot Editor APIs
- “register custom type: VectorDisplay2D”
- “expose node in Create Node dialog”
- (optionally) “register shortcut/action using display_shortcut.tres”

##### plugin.gd → display_shortcut.tres
- “reads shortcut resource / installs binding”
- and “user edits this resource in editor”

##### User Scene → VectorDisplay2D Node (`vector_display_2d.gd`)
- “node exists in scene tree; configured with target + property”

##### VectorDisplay2D → Target Node
- “reads Vector2 property each frame / on process”
- This is the key dependency: VectorDisplay2D is an observer of another node’s state.

##### VectorDisplay2D → vector_display_functions.gd
- “uses helper math to compute line/arrowhead geometry, scaling, transformations”

##### Input event (Shift+V) → VectorDisplay2D visibility state
- “toggles display on/off”
- Source of truth for the binding is `display_shortcut.tres` (edited in editor), but effect occurs at runtime.

##### Left: Godot Editor
- `display_shortcut.tres` editable in editor

##### Center: Addon boundary (`addons/vector_display_2d`)
- `VectorDisplay2D` + `VectorDisplay2DSettings` + `vector_display_functions` together as runtime core
- keep `plugin.*` slightly separated as editor-only

##### Right: User Project
- User Scene Tree containing `VectorDisplay2D`
- Target Node with `velocity: Vector2` (example)

## Diagram (Mermaid)

```mermaid
flowchart TD

%% =========================
%% External Platform (Godot)
%% =========================
subgraph "Godot Platform (External)"
direction TB
GE["Godot Editor (4.0+)"]:::platform
GR["Godot Runtime/Game (4.0+)"]:::platform
RC["Godot 2D Rendering\n(CanvasItem draw pipeline)"]:::platform
end

%% =========================
%% Addon Boundary
%% =========================
subgraph "Addon: vector_display_2d (addons/vector_display_2d)"
direction TB

subgraph "Editor Plugin Layer (Editor-time)"
direction TB
PCFG["plugin.cfg\n(Plugin Manifest)"]:::addonFile
PGD["plugin.gd\n(EditorPlugin)\nregisters custom type + shortcut wiring"]:::addonEditor
REG["Registered Custom Type:\nVectorDisplay2D (available in editor)"]:::addonEditor
DSHORT["display_shortcut.tres\n(Shortcut Resource)\nShift+V default"]:::resource
end

subgraph "Runtime Core (In-game)"
direction TB
VD2D["vector_display_2d.gd\n(VectorDisplay2D Node)\ndraws Vector2 properties in 2D"]:::addonRuntime
VSET["vector_display_settings.gd\n(VectorDisplay2DSettings Resource)\ncolors/scale/arrowheads/presets"]:::resource
VFN["vector_display_functions.gd\n(Helpers)\nmath + arrowhead geometry + draw helpers"]:::addonUtil
end

end

%% =========================
%% User Project (External)
%% =========================
subgraph "User Project (External)"
direction TB
UST["User Scene Tree"]:::user
TN["Target Node\n(e.g., Player)"]:::user
PROP["Vector2 Property\n(e.g., velocity: Vector2)"]:::data
INP["Input Event\n(Shift+V)"]:::data
DEMO["demo_content/\n(example scenes/assets)"]:::demo
end

%% =========================
%% Editor-time relationships (dashed)
%% =========================
GE -.->|"discovers_metadata"| PCFG
GE -.->|"loads_on_enable"| PGD
PGD -.->|"registers_custom_type"| REG
REG -.->|"exposes_in_create_node_dialog"| GE
PGD -.->|"reads_installs_binding"| DSHORT
GE -.->|"user_edits_shortcut_resource"| DSHORT

%% =========================
%% Runtime relationships (solid)
%% =========================
GR -->|"runs_scene_tree"| UST
UST -->|"instantiates_node"| VD2D
UST -->|"contains"| TN
TN -->|"owns"| PROP

VD2D -->|"reads_Vector2_property"| PROP
VD2D -->|"reads_settings_preset"| VSET
VD2D -->|"calls_helpers"| VFN
VD2D -->|"draws_lines_arrowheads"| RC

INP -->|"shortcut_triggers_toggle"| VD2D
DSHORT -->|"defines_binding_used_by_toggle"| INP

%% =========================
%% Demo (optional, dashed)
%% =========================
DEMO -.->|"example_usage_of_addon"| VD2D

%% =========================
%% Click Events (mapped paths)
%% =========================
click PCFG "https://github.com/andresit1524/vector_display_2d/blob/main/addons/vector_display_2d/plugin.cfg"
click PGD "https://github.com/andresit1524/vector_display_2d/blob/main/addons/vector_display_2d/plugin.gd"
click VD2D "https://github.com/andresit1524/vector_display_2d/blob/main/addons/vector_display_2d/vector_display_2d.gd"
click VSET "https://github.com/andresit1524/vector_display_2d/blob/main/addons/vector_display_2d/vector_display_settings.gd"
click VFN "https://github.com/andresit1524/vector_display_2d/blob/main/addons/vector_display_2d/vector_display_functions.gd"
click DSHORT "https://github.com/andresit1524/vector_display_2d/blob/main/addons/vector_display_2d/display_shortcut.tres"
click DEMO "https://github.com/andresit1524/vector_display_2d/tree/main/demo_content/"

%% =========================
%% Styles
%% =========================
classDef platform fill:#E5E7EB,stroke:#6B7280,stroke-width:1.5px,color:#111827
classDef addonEditor fill:#DBEAFE,stroke:#1D4ED8,stroke-width:1.8px,color:#0B1B3A
classDef addonRuntime fill:#BFDBFE,stroke:#2563EB,stroke-width:1.8px,color:#0B1B3A
classDef addonUtil fill:#C7D2FE,stroke:#4F46E5,stroke-width:1.6px,color:#111827
classDef addonFile fill:#93C5FD,stroke:#1D4ED8,stroke-width:1.6px,color:#0B1B3A
classDef resource fill:#D1FAE5,stroke:#059669,stroke-width:1.6px,color:#064E3B
classDef user fill:#FED7AA,stroke:#C2410C,stroke-width:1.6px,color:#7C2D12
classDef data fill:#FEF3C7,stroke:#B45309,stroke-width:1.4px,color:#78350F
classDef demo fill:#FBCFE8,stroke:#BE185D,stroke-width:1.4px,color:#831843
```
