fire

fire

fire

reset

Texturing

MyComp : Compositor ∀ (a, b) >> a + b × (1 - a.a)

129 LOC

Jeff Amelang

execute

reset

MyFill : Texture ⇒ TransformPoints((1,0,0,1,-120,-120)) → RadialGradient((0,0), 50) → ReflectGradient → ApplyColorSpans( ColorSpan((0.8,0,1,0), (0.3,0,-1,1), 1)) MyComp : Compositor ⇒ CompositeInvert Main (bg: Texture, write: Texture) : Bezier >> Color ⇒ TransformBeziers((1,0,0,1,120,120)) → Rasterize → ApplyTexture(CompositeTextures(MyFill, bg, MyComp)) → write

CompositeOverlay : Compositor ∀ (a, b) c = 2 × a × b + (a ⊕ b) d = a.a × b.a - 2 × (b.a - b) × (a.a - a) + (a ⊕ b) >> {c if 2 × b < b.a, d} CompositeDarken : Compositor ∀ (a, b) >> (a × b.a) ◁ (b × a.a) + (a ⊕ b) CompositeLighten : Compositor ∀ (a, b) >> (a × b.a) ▷ (b × a.a) + (a ⊕ b) CompositeColorDodge : Compositor ∀ (a, b) c = a.a × b.a + (a ⊕ b) d = (b × a.a / (1 - a / a.a) + (a ⊕ b)) ◁ 1 >> {c if a × b.a + b × a.a ≥ a.a × b.a, d} CompositeColorBurn : Compositor ∀ (a, b) c = a.a × (a × b.a + b × a.a - a.a × b.a) / a + (a ⊕ b) >> {a ⊕ b if a × b.a + b × a.a ≤ a.a × b.a, c} CompositeHardLight : Compositor ∀ (a, b) c = 2 × a × b + (a ⊕ b) d = a.a × b.a - 2 × (b.a - b) × (a.a - a) + (a ⊕ b) >> {c if 2 × a < a.a, d} CompositeSoftLight : Compositor ∀ (a, b) c = (1 - b / b.a) × (2 × a - a.a) d = b × (a.a - c) + (a ⊕ b) e = b × (a.a - c × (3 - 8 × b / b.a)) + (a ⊕ b) f = b × a.a + (√(b / b.a) × b.a - b) × (2 × a - a.a) + (a ⊕ b) >> {d if 2 × a < a.a, e if b × 8 ≤ b.a, f} CompositeDifference : Compositor ∀ (a, b) c = a + b - 2 × ((a × b.a) ◁ (b × a.a)) >> (c.a + a.a × b.a, c.r, c.g, c.b) CompositeExclusion : Compositor ∀ (a, b) c = a × b.a + b × a.a - 2 × a × b + (a ⊕ b) >> (c.a + a.a × b.a, c.r, c.g, c.b) CompositeSubtract : Compositor ∀ (a, b) >> (a + b - 1) ▷ 0 CompositeInvert : Compositor ∀ (a, b) >> (b.a, 1 - b.r, 1 - b.g, 1 - b.b)

reset

reset

fire

(a : Color) ⊕ (b : Color) : Color a × (1 - b.a) + b × (1 - a.a) CompositeClear : Compositor ∀ (a, b) >> 0 CompositeSrc : Compositor ∀ (a, b) >> a CompositeDst : Compositor ∀ (a, b) >> b CompositeOver : Compositor ∀ (a, b) >> a + b × (1 - a.a) CompositeDstOver : Compositor ∀ (a, b) >> b + a × (1 - b.a) CompositeSrcIn : Compositor ∀ (a, b) >> a × b.a CompositeDstIn : Compositor ∀ (a, b) >> b × a.a CompositeSrcOut : Compositor ∀ (a, b) >> a × (1 - b.a) CompositeDstOut : Compositor ∀ (a, b) >> b × (1 - a.a) CompositeSrcAtop : Compositor ∀ (a, b) >> a × b.a + b × (1 - a.a) CompositeDstAtop : Compositor ∀ (a, b) >> b × a.a + a × (1 - b.a) CompositeXor : Compositor ∀ (a, b) >> a ⊕ b CompositePlus : Compositor ∀ (a, b) >> (a + b) ◁ 1 CompositeMultiply : Compositor ∀ (a, b) >> a × b + (a ⊕ b) CompositeScreen : Compositor ∀ (a, b) >> a + b - a × b

~ incl. Clipping and Transformation

Bilinear, bicubic, gaussian filters.

Nile Total 457 LOC

reset

used by Flash/SVG,

Rasterization

fire

Main (bg: Texture, write: Texture) : Bezier >> Color ⇒ TransformBeziers((1,0,0,1,120,120)) → Rasterize → ApplyTexture(CompositeTextures(MyFill, bg, MyComp)) → write

Main (bg: Texture, write: Texture) : Bezier >> Color ⇒ TransformBeziers((1,0,0,1,120,120)) → Rasterize → ApplyTexture(CompositeTextures(MyFill, bg, MyComp)) → write

95 LOC

MyFill : Texture ⇒ TransformPoints((1,0,0,1,-120,-120)) → RadialGradient((0,0), 50) → ReflectGradient → ApplyColorSpans( ColorSpan((0.8,0,1,0), (0.3,0,-1,1), 1))

Core Graphics, WPF

The 26 compositing ops

45 LOC

Pen Stroking

MyFill : Texture ⇒ TransformPoints((1,0,0,1,-120,-120)) → RadialGradient((0,0), 50) → ReflectGradient → ApplyColorSpans( ColorSpan((0.8,0,1,0), (0.3,0,-1,1), 1)) MyComp : Compositor ⇒ CompositeDstOut Main (bg: Texture, write: Texture) : Bezier >> Color ⇒ TransformBeziers((1,0,0,1,120,120)) → Rasterize → ApplyTexture(CompositeTextures(MyFill, bg, MyComp)) → write

reset

71 LOC

3 kinds of caps and joins

Compositing

95 LOC

Bitmap filters

For outlines, drawings

Gradients, bitmaps, extend modes

MyFill : Texture ⇒ TransformPoints((1,0,0,1,-120,-120)) → RadialGradient((0,0), 50) → ReflectGradient → ApplyColorSpans( ColorSpan((0.8,0,1,0), (0.3,0,-1,1), 1)) MyComp : Compositor ⇒ CompositeSubtract Main (bg: Texture, write: Texture) : Bezier >> Color ⇒ TransformBeziers((1,0,0,1,120,120)) → Rasterize → ApplyTexture(CompositeTextures(MyFill, bg, MyComp)) → write

reset

close

execute

reset

execute