API Reference

Color Generation

Deterministic (Splittable RNG)

Gay.next_colorFunction
next_color(cs::ColorSpace=SRGB(); gr::GayRNG=gay_rng())

Generate the next deterministic random color. Each call splits the RNG for reproducibility.

source
Gay.next_colorsFunction
next_colors(n::Int, cs::ColorSpace=SRGB(); gr::GayRNG=gay_rng())

Generate n deterministic random colors.

source
Gay.next_paletteFunction
next_palette(n::Int, cs::ColorSpace=SRGB(); 
             min_distance::Float64=30.0, gr::GayRNG=gay_rng())

Generate n deterministic visually distinct colors.

source
Gay.color_atFunction
color_at(index::Integer, cs::ColorSpace=SRGB(); seed::Integer=GAY_SEED)

Get the color at a specific invocation index. This allows random access to the deterministic color sequence.

Example

# These will always return the same colors for the same indices
c1 = color_at(1)
c42 = color_at(42)
c1_again = color_at(1)  # Same as c1
source
Gay.colors_atFunction
colors_at(indices::AbstractVector{<:Integer}, cs::ColorSpace=SRGB(); 
          seed::Integer=GAY_SEED)

Get colors at specific invocation indices.

source
Gay.palette_atFunction
palette_at(index::Integer, n::Int, cs::ColorSpace=SRGB();
           min_distance::Float64=30.0, seed::Integer=GAY_SEED)

Get a palette at a specific invocation index.

source

RNG Control

Gay.gay_seed!Function
gay_seed!(seed::Integer)

Reset the global Gay RNG with a new seed. All subsequent color generations will be deterministic from this seed.

source
Gay.gay_rngFunction
gay_rng()

Get the global Gay RNG, initializing if needed.

source
Gay.gay_splitFunction
gay_split(gr::GayRNG=gay_rng())

Split the RNG for a new independent stream. Increments invocation counter for tracking.

source
gay_split(n::Integer, gr::GayRNG=gay_rng())

Get n independent RNG splits as a vector.

source
Gay.GayRNGType
GayRNG

A splittable random number generator for deterministic color generation. Each color operation splits the RNG to ensure reproducibility regardless of execution order (Strong Parallelism Invariance).

The RNG state tracks an invocation counter to generate a unique deterministic stream for each call, enabling reproducible sequences even across sessions.

source

Non-Deterministic (Legacy)

Gay.random_colorFunction
random_color(cs::ColorSpace=SRGB(); rng=Random.GLOBAL_RNG)

Sample a random color uniformly from the given color space's gamut. Returns an RGB color.

source
Gay.random_colorsFunction
random_colors(n::Int, cs::ColorSpace=SRGB(); rng=Random.GLOBAL_RNG)

Generate n random colors from the given color space.

source
Gay.random_paletteFunction
random_palette(n::Int, cs::ColorSpace=SRGB(); 
               min_distance=30.0, rng=Random.GLOBAL_RNG)

Generate n visually distinct random colors using rejection sampling. Colors are separated by at least min_distance in CIEDE2000.

source

Color Spaces

Built-in Spaces

Gay.Rec2020Type
Rec2020

ITU-R BT.2020 (Rec. 2020) color space - Ultra HD / 4K / 8K.

source

Space Management

Gay.gay_spaceFunction
gay_space(cs::Symbol)

Set the current color space (:srgb, :p3, :rec2020).

source

Pride Flags

Gay.rainbowFunction
rainbow(cs::ColorSpace=SRGB())

Get the Gilbert Baker rainbow flag colors.

source
Gay.transgenderFunction
transgender(cs::ColorSpace=SRGB())

Get the transgender pride flag colors.

source
Gay.bisexualFunction
bisexual(cs::ColorSpace=SRGB())

Get the bisexual pride flag colors.

source
Gay.nonbinaryFunction
nonbinary(cs::ColorSpace=SRGB())

Get the nonbinary pride flag colors.

source
Gay.pansexualFunction
pansexual(cs::ColorSpace=SRGB())

Get the pansexual pride flag colors.

source
Gay.asexualFunction
asexual(cs::ColorSpace=SRGB())

Get the asexual pride flag colors.

source
Gay.pride_flagFunction
pride_flag(name::Symbol, cs::ColorSpace=SRGB())

Get the colors of a pride flag in the specified color space.

source

Comrade Sky Models

Primitives

Gay.comrade_ringFunction
(comrade-ring radius width)

Create a ring primitive with deterministic color from Gay.jl RNG.

source

Composition

Gay.sky_addFunction
(sky-add component1 component2 ...)

Combine sky components additively (like Comrade's ring + gaussian).

source
Gay.sky_stretchFunction
(sky-stretch model sx sy)

Stretch a model (like Comrade's Stretch modifier).

source
Gay.sky_rotateFunction
(sky-rotate model angle)

Rotate a model (like Comrade's Rotate modifier).

source
Gay.sky_shiftFunction
(sky-shift model dx dy)

Shift/translate a model (like Comrade's shifted).

source

Display

Gay.sky_showFunction
sky_show(primitive)

Display a sky primitive as a colored S-expression. The parentheses are colored with the primitive's deterministic color.

source
Gay.sky_renderFunction
sky_render(model; size=30)

Render a sky model as colored ASCII art. Each primitive contributes its color to the visualization.

source
Gay.comrade_showFunction
(comrade-show model)

Display a model as colored S-expression + ASCII render.

source
Gay.comrade_modelFunction
comrade_model(; seed=42, style=:m87)

Build a Comrade-style sky model with deterministic colors. Returns the model and its colored S-expression representation.

Styles: :m87, :sgra, :custom

source

Display Utilities

Gay.show_colorsFunction
show_colors(colors; width=2)

Display colors as ANSI true-color blocks in the terminal.

source

Lisp Interface

These functions are available in the Gay REPL (Lisp syntax):

Lisp FormJulia FunctionDescription
(gay-next)gay_next()Next deterministic color
(gay-next n)gay_next(n)Next n colors
(gay-at i)gay_at(i)Color at index i
(gay-palette n)gay_palette(n)n-color palette
(gay-seed n)gay_seed(n)Set RNG seed
(gay-space :p3)gay_space(:p3)Set color space
(pride :rainbow)gay_pride(:rainbow)Pride flag colors

Types

Color Spaces

abstract type ColorSpace end

struct SRGB <: ColorSpace end
struct DisplayP3 <: ColorSpace end
struct Rec2020 <: ColorSpace end
struct CustomColorSpace <: ColorSpace
    primaries::Vector{Tuple{Float64, Float64}}
    name::String
end

RNG

mutable struct GayRNG
    root::SplittableRandom
    current::SplittableRandom
    invocation::UInt64
    seed::UInt64
end

Sky Models

abstract type SkyPrimitive end

struct Ring <: SkyPrimitive
    radius::Float64
    width::Float64
    color::RGB
end

struct Gaussian <: SkyPrimitive
    σx::Float64
    σy::Float64
    color::RGB
end

struct SkyModel
    components::Vector{Tuple{SkyPrimitive, NamedTuple}}
    total_flux::Float64
end

Derangeable Permutations

Derangements are permutations with no fixed points (σ(i) ≠ i for all i).

Core Types

Missing docstring.

Missing docstring for Derangeable. Check Documenter's build log for details.

Missing docstring.

Missing docstring for GayDerangementStream. Check Documenter's build log for details.

Generation

Missing docstring.

Missing docstring for derange. Check Documenter's build log for details.

Missing docstring.

Missing docstring for derange_at. Check Documenter's build log for details.

Missing docstring.

Missing docstring for derange_indices. Check Documenter's build log for details.

Missing docstring.

Missing docstring for derange_colors. Check Documenter's build log for details.

Missing docstring.

Missing docstring for next_derangement. Check Documenter's build log for details.

Missing docstring.

Missing docstring for nth_derangement. Check Documenter's build log for details.

Analysis

Missing docstring.

Missing docstring for derange_cycle. Check Documenter's build log for details.

Missing docstring.

Missing docstring for cycle_colors. Check Documenter's build log for details.

Missing docstring.

Missing docstring for derangement_sign. Check Documenter's build log for details.

Missing docstring.

Missing docstring for gay_parity_derangement. Check Documenter's build log for details.

Abductive Inference

Abduction: reasoning from effect to cause. Given a color, find what seed/index produced it.

Core Types

Missing docstring.

Missing docstring for GayAbducer. Check Documenter's build log for details.

Missing docstring.

Missing docstring for Abducible. Check Documenter's build log for details.

GayAbducer Workflow

Missing docstring.

Missing docstring for register_observation!. Check Documenter's build log for details.

Missing docstring.

Missing docstring for infer_seed. Check Documenter's build log for details.

Missing docstring.

Missing docstring for infer_structure. Check Documenter's build log for details.

Direct Abduction

Missing docstring.

Missing docstring for abduce. Check Documenter's build log for details.

Missing docstring.

Missing docstring for abduce_index. Check Documenter's build log for details.

Missing docstring.

Missing docstring for abduce_seed. Check Documenter's build log for details.

Inverse Operations

Missing docstring.

Missing docstring for abduce_inverse. Check Documenter's build log for details.

Missing docstring.

Missing docstring for abduce_derangement. Check Documenter's build log for details.

Missing docstring.

Missing docstring for abduce_cycle. Check Documenter's build log for details.

Missing docstring.

Missing docstring for abduce_parity. Check Documenter's build log for details.

Color Utilities

Gay.color_distanceFunction
color_distance(c1::RGB, c2::RGB) -> Float64

Euclidean distance in RGB space (simple, fast).

source
Gay.color_fingerprintFunction

Generate a color fingerprint for a set of seeds.

This is the FIRST-CONTACT VERIFICATION primitive: If Alice and Bob compute the same fingerprint from shared seeds, they have proven they're in the same "world" (same SPI implementation).

The fingerprint is computed as: hash([color_at(i; seed=s) for s in seeds for i in 1:12])

Because color_at is PURE, the fingerprint is deterministic.

source
Missing docstring.

Missing docstring for find_nearest_color. Check Documenter's build log for details.

Binary Analysis

Enhanced binary analysis with tree-sitter AST parsing and diaphora-style hashing.

Core Types

Missing docstring.

Missing docstring for GayBinary. Check Documenter's build log for details.

Missing docstring.

Missing docstring for FunctionSignature. Check Documenter's build log for details.

Missing docstring.

Missing docstring for ASTHash. Check Documenter's build log for details.

AST Parsing & Hashing

Missing docstring.

Missing docstring for parse_pseudocode. Check Documenter's build log for details.

Missing docstring.

Missing docstring for hash_ast_primes. Check Documenter's build log for details.

Missing docstring.

Missing docstring for fnv1a_hash. Check Documenter's build log for details.

Function Matching

Missing docstring.

Missing docstring for function_signature. Check Documenter's build log for details.

Missing docstring.

Missing docstring for abduce_function_match. Check Documenter's build log for details.

Missing docstring.

Missing docstring for abduce_binary_seed. Check Documenter's build log for details.

Visualization

Missing docstring.

Missing docstring for render_call_graph. Check Documenter's build log for details.

Missing docstring.

Missing docstring for render_cfg_graph. Check Documenter's build log for details.

Constants

GAY_SEED::UInt64  # Default seed (0x6761795f636f6c6f)