# twertybog/gamma_control architecture

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

- Interactive diagram: https://gitdiagram.com/twertybog/gamma_control
- Repository: https://github.com/twertybog/gamma_control

## Overview

gamma-control is a Windows desktop utility that adjusts a selected visible window’s gamma according to its captured brightness. The workflow runs from the eframe application UI through window selection and Direct3D-backed frame capture, then samples each frame’s average luminance and applies a calculated gamma ramp to that window. The source also supports window refresh, manual gamma reset, and stopping capture. Relationships shown are limited to calls and setup visible in the excerpts; no README documentation or additional product subsystems were provided.

Main entry points: [`src/app.rs`](https://github.com/twertybog/gamma_control/blob/main/src/app.rs) (Gamma controls), [`src/d3d_device.rs`](https://github.com/twertybog/gamma_control/blob/main/src/d3d_device.rs) (Direct3D device), [`src/window.rs`](https://github.com/twertybog/gamma_control/blob/main/src/window.rs) (Window capture item), [`src/main.rs`](https://github.com/twertybog/gamma_control/blob/main/src/main.rs) (Application entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Desktop UI"]
  node_entry["Application entry<br/>[main.rs]"]
  node_app["Gamma controls<br/>[app.rs]"]
  node_eframe_error["UI runtime errors<br/>[error.rs]"]
end

subgraph group_capture["Capture and analysis"]
  node_capture_session["Frame capture session<br/>[capture.rs]"]
  node_d3d_device["Direct3D device<br/>[d3d_device.rs]"]
  node_brightness["Brightness sampling<br/>[d3d_device.rs]"]
end

subgraph group_windows["Windows integration"]
  node_window_list["Visible windows<br/>[window.rs]"]
  node_window_gamma["Window gamma ramp<br/>[window.rs]"]
  node_window_item["Window capture item<br/>[window.rs]"]
  node_errors["Windows errors<br/>[error.rs]"]
end

node_user(("User"))

node_user -->|"launches"| node_entry
node_entry -->|"creates"| node_app
node_app -->|"loads and refreshes"| node_window_list
node_app -->|"initializes"| node_d3d_device
node_app -->|"selects"| node_window_item
node_app -->|"creates and controls"| node_capture_session
node_window_list -->|"enumerates"| node_window_item
node_window_item -->|"creates capture target"| node_capture_session
node_d3d_device -->|"backs capture"| node_capture_session
node_app -->|"samples each frame"| node_brightness
node_brightness -->|"reads texture"| node_d3d_device
node_app -->|"applies calculated gamma"| node_window_gamma
node_app -->|"resets gamma"| node_window_gamma
node_d3d_device -->|"returns"| node_errors
node_window_item -->|"returns"| node_errors
node_entry -->|"maps runtime failure"| node_eframe_error

click node_entry "https://github.com/twertybog/gamma_control/blob/main/src/main.rs"
click node_app "https://github.com/twertybog/gamma_control/blob/main/src/app.rs"
click node_window_list "https://github.com/twertybog/gamma_control/blob/main/src/window.rs"
click node_window_gamma "https://github.com/twertybog/gamma_control/blob/main/src/window.rs"
click node_window_item "https://github.com/twertybog/gamma_control/blob/main/src/window.rs"
click node_capture_session "https://github.com/twertybog/gamma_control/blob/main/src/capture.rs"
click node_d3d_device "https://github.com/twertybog/gamma_control/blob/main/src/d3d_device.rs"
click node_brightness "https://github.com/twertybog/gamma_control/blob/main/src/d3d_device.rs"
click node_errors "https://github.com/twertybog/gamma_control/blob/main/src/error.rs"
click node_eframe_error "https://github.com/twertybog/gamma_control/blob/main/src/error.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_app,node_eframe_error,node_user toneBlue
class node_capture_session,node_d3d_device,node_brightness toneAmber
class node_window_list,node_window_gamma,node_window_item,node_errors toneMint
```

## Components

### Desktop UI

- [Application entry](https://github.com/twertybog/gamma_control/blob/main/src/main.rs): `src/main.rs`
- [Gamma controls](https://github.com/twertybog/gamma_control/blob/main/src/app.rs): `src/app.rs`
- [UI runtime errors](https://github.com/twertybog/gamma_control/blob/main/src/error.rs): `src/error.rs`

### Capture and analysis

- [Frame capture session](https://github.com/twertybog/gamma_control/blob/main/src/capture.rs): `src/capture.rs`
- [Direct3D device](https://github.com/twertybog/gamma_control/blob/main/src/d3d_device.rs): `src/d3d_device.rs`
- [Brightness sampling](https://github.com/twertybog/gamma_control/blob/main/src/d3d_device.rs): `src/d3d_device.rs`

### Windows integration

- [Visible windows](https://github.com/twertybog/gamma_control/blob/main/src/window.rs): `src/window.rs`
- [Window gamma ramp](https://github.com/twertybog/gamma_control/blob/main/src/window.rs): `src/window.rs`
- [Window capture item](https://github.com/twertybog/gamma_control/blob/main/src/window.rs): `src/window.rs`
- [Windows errors](https://github.com/twertybog/gamma_control/blob/main/src/error.rs): `src/error.rs`

### Other components

- **User**

## Connections

- User → Application entry: launches (evidence: `src/main.rs`)
- Application entry → Gamma controls: creates (evidence: `src/main.rs`)
- Gamma controls → Visible windows: loads and refreshes (evidence: `src/app.rs`)
- Gamma controls → Direct3D device: initializes (evidence: `src/app.rs`)
- Gamma controls → Window capture item: selects (evidence: `src/app.rs`)
- Gamma controls → Frame capture session: creates and controls (evidence: `src/app.rs`)
- Visible windows → Window capture item: enumerates (evidence: `src/window.rs`)
- Window capture item → Frame capture session: creates capture target (evidence: `src/window.rs`)
- Direct3D device → Frame capture session: backs capture (evidence: `src/capture.rs`)
- Gamma controls → Brightness sampling: samples each frame (evidence: `src/app.rs`)
- Brightness sampling → Direct3D device: reads texture (evidence: `src/d3d_device.rs`)
- Gamma controls → Window gamma ramp: applies calculated gamma (evidence: `src/app.rs`)
- Gamma controls → Window gamma ramp: resets gamma (evidence: `src/app.rs`)
- Direct3D device → Windows errors: returns (evidence: `src/d3d_device.rs`)
- Window capture item → Windows errors: returns (evidence: `src/window.rs`)
- Application entry → UI runtime errors: maps runtime failure (evidence: `src/main.rs`)
