module
Celestine::Docs::C_DSL_AND_CREATIVE::ROUGH_SKETCHY_GRAPHICS
Overview
Hand-Drawn Sketchy Vector Engine
Celestine includes an algorithmic rough graphics engine that renders organic, hand-drawn lines, rectangles, circles, and polygons with configurable roughness, bowing, and deterministic PRNG seeding.
Executive Summary & Key Topics
| Topic | Method / Anchor | Description |
|---|---|---|
| Using the Rough Builder DSL | .topic_01_rough_dsl |
Block-based hand-drawn vector graphics. |
| Direct Path Sketching | .topic_02_direct_path_sketching |
Applying sketchy primitives to any existing Path drawable. |
Related Guides & Source References
- src/rough/rough.cr
Defined in:
docs/c_dsl_and_creative/rough_sketchy_graphics.crClass Method Summary
-
.topic_01_rough_dsl : Nil
Using the Rough Builder DSL: Block-based hand-drawn vector graphics.
-
.topic_02_direct_path_sketching : Nil
Direct Path Sketching: Applying sketchy primitives to any existing Path drawable.
Class Method Detail
def self.topic_01_rough_dsl : Nil
#
Using the Rough Builder DSL: Block-based hand-drawn vector graphics.
The ctx.rough method configures the sketching engine and provides a convenient
builder block:
roughness: controls degree of jitter and multi-pass displacement (default 1.0)bowing: controls curve bowing deflection (default 1.0)seed: provides deterministic generation across renders
Working Examples
Celestine.draw do |ctx|
ctx.rough(roughness: 1.5, stroke: "#334155", stroke_width: 2) do |r|
r.rect(20, 20, 160, 100)
r.circle(260, 70, 40)
r.line(20, 160, 300, 160)
r.polygon([{40, 200}, {100, 180}, {80, 240}])
end
end
def self.topic_02_direct_path_sketching : Nil
#
Direct Path Sketching: Applying sketchy primitives to any existing Path drawable.
Any Celestine::Path can directly invoke rough_line, rough_rect, rough_circle,
or rough_polygon.
Working Examples
Celestine.draw do |ctx|
ctx.path do |p|
p.stroke = "#e11d48"
p.rough_circle(cx: 100, cy: 100, r: 50, roughness: 1.2)
end
end