patterns — halftone

generator verdict no votes yet
source — gen_b.g09_halftone
def g09_halftone(rng):
    """HALFTONE RELIEF — a synthetic lit surface (lambert term from a tilted
    normal field) resolved through the measured density ramp. The ramp spans the
    full available range, blocks included, so the surface can actually go dark."""
    N = 40
    c = Canvas(N, "GLYPH", "glyph", "halftone", tiles=False)
    NX, NY = c.cols, c.rows
    R = FULL_RAMP
    nz = Value2D(rng, res=rng.choice([3, 4, 6]))
    lx, ly = rng.uniform(-1, 1), rng.uniform(-1, 1)
    lm = math.hypot(lx, ly) + 1e-6
    lx, ly = lx / lm, ly / lm
    amp = rng.uniform(2.5, 6.0)
    gamma = rng.uniform(0.55, 1.05)
    h = 1.0 / NX
    for i in range(NX):
        for j in range(NY):
            u, v = (i + 0.5) / NX, (j + 0.5) / NY
            gx = (nz(u + h, v) - nz(u - h, v)) * amp
            gy = (nz(u, v + h) - nz(u, v - h)) * amp
            lam = clamp(0.55 - (gx * lx + gy * ly) * 1.5)
            k = int(round((1 - clamp(lam ** gamma)) * (len(R) - 1)))
            if R[k] != " ":
                c.glyph(i, j, R[k])
    return c
halftone-glyph-40-3459
halftone-glyph-40-3459
halftone-dots-30-dc50
halftone-dots-30-dc50
halftone-glyph-40-3fc2
halftone-glyph-40-3fc2
halftone-dots-30-734b
halftone-dots-30-734b
halftone-glyph-40-c94e
halftone-glyph-40-c94e
halftone-dots-40-bb46
halftone-dots-40-bb46
halftone-dots-30-835f
halftone-dots-30-835f
halftone-glyph-40-537b
halftone-glyph-40-537b
halftone-dots-40-056d
halftone-dots-40-056d
halftone-glyph-40-4fa0
halftone-glyph-40-4fa0
halftone-glyph-40-5f97
halftone-glyph-40-5f97
halftone-glyph-40-7d91
halftone-glyph-40-7d91
halftone-glyph-40-68ff
halftone-glyph-40-68ff

generator