CommunityImagegithub.com

krita-flat-colouring

Segment clean Krita lineart into watertight semantic material regions using connected-component topology, Voronoi EDT attribution, contour polygon selections, +0.58 px Krita 6.0.4 brush fills, and non-destructive alpha-locked layer hierarchies. Strictly terminates at uniform flat base colours with zero shading, lighting, gradients, or autonomous rendering.

What is krita-flat-colouring?

krita-flat-colouring is a Claude Code agent skill that segment clean Krita lineart into watertight semantic material regions using connected-component topology, Voronoi EDT attribution, contour polygon selections, +0.58 px Krita 6.0.4 brush fills, and non-destructive alpha-locked layer hierarchies. Strictly terminates at uniform flat base colours with zero shading, lighting, gradients, or autonomous rendering.

Works with~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ashdawgthegoat/krita-illustration-skills/tree/HEAD/skills/krita-flat-colouring

Installed? Explore more Image skills: steipete/songsee, affaan-m/frontend-design, mattpocock/improve-codebase-architecture · View all 6 →

Ask in your favorite AI

Open a new chat with this agent skill pre-loaded.

Documentation

Krita Uniform Flat-Colouring Skill

Transform clean, finished Krita lineart into an editable, production-ready Krita illustration organized into semantic, uniform single-hex flat-colour layers ready for immediate human artist handoff.

This skill is agent-agnostic: topological segmentation, contour polygon extraction, and uniformity validation are decoupled from Krita transport inside scripts/krita_adapter.py.

Hard Production Scope Boundaries (Stop at Flats)

  • Strict Flat-Only Guarantee: Outputs exactly one single target hex RGB per leaf layer (alpha == 255, opacity = 1.0).
  • Strictly Forbidden Operations (enforced by configs/default_config.json and KritaAdapter):
    • NO shading, shadows, ambient occlusion, highlights, rim light, or subsurface blush.
    • NO gradients, soft airbrushing, painterly blending (Atsunuri), or specular eye catchlights.
    • NO global lighting layer stacks (multiply, lighten, overlay, add, screen, soft_light, color_dodge).
    • NO lineart colour-hold recolouring.
  • Lineart Preservation: Clones original lineart to a locked, hidden backup layer before adding colour groups. When solid-black garment/accessory silhouettes contain flat interior colours, uses a reversible transparencymask rather than erasing or redrawing lineart pixels.

Core Pipeline Workflow

  1. Lineart Ingestion & Connected-Component Labeling (scripts/region_segmentation.py):

    • Thresholds ink (gray < 200), closes 1-px stroke pinholes (3x3 binary closing), and labels interior regions.
    • Identifies the exterior silhouette automatically from border-touching background labels (or declarative exterior_bg_labels in --spec).
  2. Semantic & Topological Partitioning (scripts/region_segmentation.py):

    • Ink-Corridor Material Regions: Isolates dark apparel/accessory bands/straps bounded by ink & geometry & silhouette, optionally eroding 2 px to produce a reversible Fill_Window transparency mask over dark interiors.
    • Pre/Post Overlays: Isolates bounded sclera, iris, or small cap regions.
    • Voronoi EDT Competition: Resolves borderline shadow pockets between adjacent materials (e.g., hair vs. skin, main hair vs. back braid) via Euclidean distance transform.
    • 1-px Ink Trapping: Dilates fills 1 px underneath bordering ink contours so anti-aliased stroke edges leave zero white halos.
    • Generic Fallback: Without a semantic --spec, auto-labels enclosed interior components >= 16 px into isolated Flats/Region_NN layers and logs smaller/unmapped regions.
  3. Non-Destructive Hierarchy & Polygon-Contained Brush Sweeps (scripts/layer_setup.py, scripts/polygon_selection.py, scripts/flat_fill_planner.py):

    • Builds independent blending_mode = "normal", inherit_alpha = false layer groups underneath Lineart/.
    • Converts masks into Krita select_polygon outer (replace/add) + hole (subtract) calls using the calibrated +0.58 px shift (SUBPX = 0.58).
    • Paints solid full-pressure (1.0), full-opacity (1.0) serpentine brush sweeps using "b) Basic-5 Size" packed into <= 60-edit edit_batch chunks (under Krita's 64-edit cap).
    • Sets alpha_locked = true on leaf flat layers after filling so artists can immediately shade within boundaries.
  4. Validation & Artist Handoff Report (scripts/validate_flat_color.py):

    • Confirms 100% single-hex RGB uniformity across exported opaque pixels.
    • Verifies zero exterior spill outside the character silhouette.
    • Documents any semi-open or ambiguous anatomical regions (e.g., faint unenclosed fingernails, semi-open tiny nail rims) for manual artist review instead of guessing.

Quick CLI Invocation

python3 skills/krita-flat-colouring/scripts/apply_flat_colors.py \
  --lineart path/to/clean_lineart.png \
  --spec skills/krita-flat-colouring/examples/sample_region_spec.json \
  --batch-dir work/flat_batches \
  --diag-out work/flat_diag.png \
  --audit-out work/flat_audit.json \
  --setup-layers \
  --mode dry_run

Execute directly against a live Krita 6.0.4 document:

python3 skills/krita-flat-colouring/scripts/apply_flat_colors.py \
  --lineart path/to/clean_lineart.png \
  --spec skills/krita-flat-colouring/examples/sample_region_spec.json \
  --batch-dir work/flat_batches \
  --setup-layers \
  --mode http_bridge

Reference Guides & Configs

Individual skills in this repo

This repo contains 1 individual skill — each has its own dedicated page.

Related Skills