Skip to content

dwgx/SmartCLI / skills/cmd-art

cmd-art

Verified

Design and render terminal/CMD visual effects and ASCII art from a one-line request via the pluggable `fx` engine (30 effects, hot-swappable and themeable, plus scripted shows). Effects include donut, matrix rain, plasma, fire, a spinning 3D ball, a solar-system orrery, Game of Life, wireframe cube, 3D text banners, rainbow/lolcat gradient text, starfield, tunnel, fireworks, image-to-ASCII, and more. Use when the request is for a terminal animation, ANSI/CLI art, or a new console effect. Pure Python stdlib; truecolor.

fx/_noiselib.py

View on GitHub
"""_noiselib.py — noise-composition primitives shared by the field effects.

Builds on perlin.py's improved-noise kernel (reused verbatim, no second impl)
and adds the techniques that lift plain fBm to "natural material" quality:
  * fbm(x,y,z)          — the base fractal Brownian motion (from perlin.py)
  * ridged(x,y,z)       — 1 - |2·fbm - 1|, the bright-filament / caustic ridge
  * domain_warp(x,y,t)  — Inigo Quilez's fbm(p + fbm(p + fbm(p))): warp the
                          noise by itself so smooth turbulence becomes flowing
                          filaments (fire, clouds, nebula). Returns (f, qx, qy)
                          so callers can drive multi-color mixing off q.
  * black_body(k)       — Tanner Helland's temperature(Kelvin)->RGB, the physical
                          fire/incandescence ramp (black->red->orange->white).

The leading underscore keeps the effect registry (which scans effects/*.py) from
treating this as an Effect module.

Sources:
  domain warping   https://iquilezles.org/articles/warp/
  black-body ramp  https://tannerhelland.com/2012/09/18/convert-temperature-rgb-algorithm-code.html
"""
from __future__ import annotations

import math

from .effects.perlin import _noise  # reuse the improved-noise kernel


def fbm(x, y, z, octaves=4, lacunarity=2.0, gain=0.5):
    """Fractal Brownian motion — sum of noise octaves. Output ~[-1, 1]."""
    total = 0.0
    freq = 1.0
    amp = 1.0
    norm = 0.0
    for _ in range(octaves):
        total += _noise(x * freq, y * freq, z * freq) * amp
        norm += amp
        freq *= lacunarity
        amp *= gain
    return total / norm if norm else 0.0


def ridged(x, y, z, octaves=4):
    """Ridged noise: 1 - |2·fbm - 1| in [0,1]. Sharp bright ridges — the basis
    of water caustic nets and nebula filaments."""
    n = (fbm(x, y, z, octaves) + 1.0) * 0.5   # -> [0,1]
    return 1.0 - abs(2.0 * n - 1.0)


def domain_warp(x, y, t, warp=4.0, octaves=3):
    """IQ domain warping: f(p) = fbm(p + warp·q), q = fbm(p + offsets).

    Returns (f, qx, qy) in roughly [-1,1] each. q is the first warp field —
    callers use its magnitude/components to mix extra colors (nebula), or just
    take f for a flowing scalar field (fire/clouds). t animates the field.

    ``octaves`` is passed to each of the 5 inner fbm calls; it defaults to 3
    (not 4) because the warping already adds so much structure that the top
    octave is barely visible — dropping it cuts per-pixel noise cost by ~25%,
    which matters on large terminals (this is called once per cell per frame).
    """
    qx = fbm(x, y, t, octaves)
    qy = fbm(x + 5.2, y + 1.3, t, octaves)
    rx = fbm(x + warp * qx + 1.7, y + warp * qy + 9.2, t, octaves)
    ry = fbm(x + warp * qx + 8.3, y + warp * qy + 2.8, t, octaves)
    f = fbm(x + warp * rx, y + warp * ry, t, octaves)
    return f, qx, qy


# --- black-body / fire color ramp -----------------------------------------
def black_body(kelvin):
    """Temperature (K) -> (r,g,b), 0..255. Tanner Helland's fit, ~1000-40000K.
    Black at low K, deep red, orange, yellow-white toward ~6500K+."""
    t = max(1000.0, min(40000.0, kelvin)) / 100.0
    # red
    if t <= 66:
        r = 255.0
    else:
        r = 329.698727446 * ((t - 60) ** -0.1332047592)
    # green
    if t <= 66:
        g = 99.4708025861 * math.log(t) - 161.1195681661
    else:
        g = 288.1221695283 * ((t - 60) ** -0.0755148492)
    # blue
    if t >= 66:
        b = 255.0
    elif t <= 19:
        b = 0.0
    else:
        b = 138.5177312231 * math.log(t - 10) - 305.0447927307
    return (int(max(0, min(255, r))),
            int(max(0, min(255, g))),
            int(max(0, min(255, b))))
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 322kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 197kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 197kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 197kUpdated Claude CodeCodexVerifiedInstall