# ackermanngue/go-painter architecture

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

- Interactive diagram: https://gitdiagram.com/ackermanngue/go-painter
- Repository: https://github.com/ackermanngue/go-painter

## Overview

go-painter is a CLI that turns a PNG or JPEG into a deterministic, layered brush-stroke painting. The user selects an input, preset, seed, and worker count; the CLI loads the image and invokes the painter, which prepares image structure, places strokes across brush-size passes, renders them onto a canvas, and saves a PNG. The README documents the principal stages and presets. Some implementation files were not sampled, so links for those stages follow documented responsibilities and uncertain internal calls are omitted.

Main entry points: [`internal/painter/painter.go`](https://github.com/ackermanngue/go-painter/blob/main/internal/painter/painter.go) (Painter pipeline), [`cmd/painter/main.go`](https://github.com/ackermanngue/go-painter/blob/main/cmd/painter/main.go) (Painter CLI), [`internal/imageutil/load.go`](https://github.com/ackermanngue/go-painter/blob/main/internal/imageutil/load.go) (Image loading), [`internal/parallel/rows.go`](https://github.com/ackermanngue/go-painter/blob/main/internal/parallel/rows.go) (Row workers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI workflow"]
  node_cli["Painter CLI<br/>[main.go]"]
  node_load["Image loading<br/>[load.go]"]
  node_presets["Style presets<br/>[presets.go]"]
  node_save["PNG saving<br/>[save.go]"]
end

subgraph group_analysis["Image analysis"]
  node_blur["Gaussian blur<br/>[blur.go]"]
  node_gray["Grayscale conversion<br/>[grayscale.go]"]
  node_sobel["Sobel gradients<br/>[sobel.go]"]
end

subgraph group_painting["Stroke painting"]
  node_engine["Painter pipeline<br/>[painter.go]"]
  node_error["Region error<br/>[error.go]"]
  node_strokes["Stroke generation<br/>[strokes.go]"]
  node_canvas["Canvas setup<br/>[canvas.go]"]
end

subgraph group_support["Rendering support"]
  node_brush["Brush rendering<br/>[brush.go]"]
  node_blend["Alpha blending<br/>[blend.go]"]
  node_color["Color sampling<br/>[color.go]"]
  node_parallel["Row workers<br/>[rows.go]"]
  node_model["Image and stroke data<br/>[types.go]"]
end

node_user(("User"))
node_input["Source image"]
node_output["Painting PNG"]

node_user -->|"sets options"| node_cli
node_cli -->|"selects preset"| node_presets
node_cli -->|"loads input"| node_load
node_input -->|"image data"| node_load
node_cli -->|"paints image"| node_engine
node_load -->|"provides image"| node_engine
node_engine -->|"smooths source"| node_blur
node_engine -->|"converts intensity"| node_gray
node_engine -->|"computes gradients"| node_sobel
node_engine -->|"measures regions"| node_error
node_engine -->|"generates marks"| node_strokes
node_strokes -->|"samples color"| node_color
node_engine -->|"initializes canvas"| node_canvas
node_engine -->|"renders strokes"| node_brush
node_brush -->|"blends pixels"| node_blend
node_blur -->|"dispatches rows"| node_parallel
node_gray -->|"dispatches rows"| node_parallel
node_sobel -->|"dispatches rows"| node_parallel
node_engine -->|"saves result"| node_save
node_save -->|"writes PNG"| node_output

click node_cli "https://github.com/ackermanngue/go-painter/blob/main/cmd/painter/main.go"
click node_load "https://github.com/ackermanngue/go-painter/blob/main/internal/imageutil/load.go"
click node_presets "https://github.com/ackermanngue/go-painter/blob/main/internal/painter/presets.go"
click node_engine "https://github.com/ackermanngue/go-painter/blob/main/internal/painter/painter.go"
click node_blur "https://github.com/ackermanngue/go-painter/blob/main/internal/imageutil/blur.go"
click node_gray "https://github.com/ackermanngue/go-painter/blob/main/internal/gradient/grayscale.go"
click node_sobel "https://github.com/ackermanngue/go-painter/blob/main/internal/gradient/sobel.go"
click node_error "https://github.com/ackermanngue/go-painter/blob/main/internal/painter/error.go"
click node_strokes "https://github.com/ackermanngue/go-painter/blob/main/internal/painter/strokes.go"
click node_canvas "https://github.com/ackermanngue/go-painter/blob/main/internal/render/canvas.go"
click node_brush "https://github.com/ackermanngue/go-painter/blob/main/internal/render/brush.go"
click node_blend "https://github.com/ackermanngue/go-painter/blob/main/internal/render/blend.go"
click node_color "https://github.com/ackermanngue/go-painter/blob/main/internal/imageutil/color.go"
click node_parallel "https://github.com/ackermanngue/go-painter/blob/main/internal/parallel/rows.go"
click node_model "https://github.com/ackermanngue/go-painter/blob/main/internal/model/types.go"
click node_save "https://github.com/ackermanngue/go-painter/blob/main/internal/imageutil/save.go"

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_cli,node_load,node_presets,node_save,node_user toneBlue
class node_blur,node_gray,node_sobel toneAmber
class node_engine,node_error,node_strokes,node_canvas toneMint
class node_brush,node_blend,node_color,node_parallel,node_model toneRose
class node_input,node_output toneIndigo
```

## Components

### CLI workflow

- [Painter CLI](https://github.com/ackermanngue/go-painter/blob/main/cmd/painter/main.go): `cmd/painter/main.go`
- [Image loading](https://github.com/ackermanngue/go-painter/blob/main/internal/imageutil/load.go): `internal/imageutil/load.go`
- [Style presets](https://github.com/ackermanngue/go-painter/blob/main/internal/painter/presets.go): `internal/painter/presets.go`
- [PNG saving](https://github.com/ackermanngue/go-painter/blob/main/internal/imageutil/save.go): `internal/imageutil/save.go`

### Image analysis

- [Gaussian blur](https://github.com/ackermanngue/go-painter/blob/main/internal/imageutil/blur.go): `internal/imageutil/blur.go`
- [Grayscale conversion](https://github.com/ackermanngue/go-painter/blob/main/internal/gradient/grayscale.go): `internal/gradient/grayscale.go`
- [Sobel gradients](https://github.com/ackermanngue/go-painter/blob/main/internal/gradient/sobel.go): `internal/gradient/sobel.go`

### Stroke painting

- [Painter pipeline](https://github.com/ackermanngue/go-painter/blob/main/internal/painter/painter.go): `internal/painter/painter.go`
- [Region error](https://github.com/ackermanngue/go-painter/blob/main/internal/painter/error.go): `internal/painter/error.go`
- [Stroke generation](https://github.com/ackermanngue/go-painter/blob/main/internal/painter/strokes.go): `internal/painter/strokes.go`
- [Canvas setup](https://github.com/ackermanngue/go-painter/blob/main/internal/render/canvas.go): `internal/render/canvas.go`

### Rendering support

- [Brush rendering](https://github.com/ackermanngue/go-painter/blob/main/internal/render/brush.go): `internal/render/brush.go`
- [Alpha blending](https://github.com/ackermanngue/go-painter/blob/main/internal/render/blend.go): `internal/render/blend.go`
- [Color sampling](https://github.com/ackermanngue/go-painter/blob/main/internal/imageutil/color.go): `internal/imageutil/color.go`
- [Row workers](https://github.com/ackermanngue/go-painter/blob/main/internal/parallel/rows.go): `internal/parallel/rows.go`
- [Image and stroke data](https://github.com/ackermanngue/go-painter/blob/main/internal/model/types.go): `internal/model/types.go`

### Other components

- **User**
- **Source image**
- **Painting PNG**

## Connections

- User → Painter CLI: sets options
- Painter CLI → Style presets: selects preset
- Painter CLI → Image loading: loads input
- Source image → Image loading: image data
- Painter CLI → Painter pipeline: paints image
- Image loading → Painter pipeline: provides image
- Painter pipeline → Gaussian blur: smooths source
- Painter pipeline → Grayscale conversion: converts intensity
- Painter pipeline → Sobel gradients: computes gradients
- Painter pipeline → Region error: measures regions
- Painter pipeline → Stroke generation: generates marks
- Stroke generation → Color sampling: samples color
- Painter pipeline → Canvas setup: initializes canvas
- Painter pipeline → Brush rendering: renders strokes
- Brush rendering → Alpha blending: blends pixels
- Gaussian blur → Row workers: dispatches rows
- Grayscale conversion → Row workers: dispatches rows
- Sobel gradients → Row workers: dispatches rows
- Painter pipeline → PNG saving: saves result
- PNG saving → Painting PNG: writes PNG
