API Reference
Color Generation
Deterministic (Splittable RNG)
Gay.next_color — Function
next_color(cs::ColorSpace=SRGB(); gr::GayRNG=gay_rng())Generate the next deterministic random color. Each call splits the RNG for reproducibility.
Gay.next_colors — Function
next_colors(n::Int, cs::ColorSpace=SRGB(); gr::GayRNG=gay_rng())Generate n deterministic random colors.
Gay.next_palette — Function
next_palette(n::Int, cs::ColorSpace=SRGB();
min_distance::Float64=30.0, gr::GayRNG=gay_rng())Generate n deterministic visually distinct colors.
Gay.color_at — Function
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 c1Gay.colors_at — Function
colors_at(indices::AbstractVector{<:Integer}, cs::ColorSpace=SRGB();
seed::Integer=GAY_SEED)Get colors at specific invocation indices.
Gay.palette_at — Function
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.
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.
Gay.gay_rng — Function
gay_rng()Get the global Gay RNG, initializing if needed.
Gay.gay_split — Function
gay_split(gr::GayRNG=gay_rng())Split the RNG for a new independent stream. Increments invocation counter for tracking.
gay_split(n::Integer, gr::GayRNG=gay_rng())Get n independent RNG splits as a vector.
Gay.GayRNG — Type
GayRNGA 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.
Non-Deterministic (Legacy)
Gay.random_color — Function
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.
Gay.random_colors — Function
random_colors(n::Int, cs::ColorSpace=SRGB(); rng=Random.GLOBAL_RNG)Generate n random colors from the given color space.
Gay.random_palette — Function
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.
Color Spaces
Built-in Spaces
Gay.DisplayP3 — Type
DisplayP3Display P3 (Apple/DCI-P3 with D65) color space.
Gay.Rec2020 — Type
Rec2020ITU-R BT.2020 (Rec. 2020) color space - Ultra HD / 4K / 8K.
Gay.CustomColorSpace — Type
CustomColorSpaceUser-defined color space with arbitrary primaries.
Space Management
Gay.current_colorspace — Function
current_colorspace() -> ColorSpaceGet the current preferred color space. Default: DisplayP3.
Gay.gay_space — Function
gay_space(cs::Symbol)Set the current color space (:srgb, :p3, :rec2020).
Pride Flags
Gay.rainbow — Function
rainbow(cs::ColorSpace=SRGB())Get the Gilbert Baker rainbow flag colors.
Gay.transgender — Function
transgender(cs::ColorSpace=SRGB())Get the transgender pride flag colors.
Gay.bisexual — Function
bisexual(cs::ColorSpace=SRGB())Get the bisexual pride flag colors.
Gay.nonbinary — Function
nonbinary(cs::ColorSpace=SRGB())Get the nonbinary pride flag colors.
Gay.pansexual — Function
pansexual(cs::ColorSpace=SRGB())Get the pansexual pride flag colors.
Gay.asexual — Function
asexual(cs::ColorSpace=SRGB())Get the asexual pride flag colors.
Gay.pride_flag — Function
pride_flag(name::Symbol, cs::ColorSpace=SRGB())Get the colors of a pride flag in the specified color space.
Comrade Sky Models
Primitives
Gay.comrade_ring — Function
(comrade-ring radius width)Create a ring primitive with deterministic color from Gay.jl RNG.
Gay.comrade_mring — Function
(comrade-mring radius α β)Create an azimuthal ring with Fourier structure.
Gay.comrade_gaussian — Function
(comrade-gaussian σx σy)Create an elliptical Gaussian.
Gay.comrade_disk — Function
(comrade-disk radius)Create a uniform disk.
Gay.comrade_crescent — Function
(comrade-crescent r_out r_in shift)Create a crescent (asymmetric ring).
Composition
Gay.sky_add — Function
(sky-add component1 component2 ...)Combine sky components additively (like Comrade's ring + gaussian).
Gay.sky_stretch — Function
(sky-stretch model sx sy)Stretch a model (like Comrade's Stretch modifier).
Gay.sky_rotate — Function
(sky-rotate model angle)Rotate a model (like Comrade's Rotate modifier).
Gay.sky_shift — Function
(sky-shift model dx dy)Shift/translate a model (like Comrade's shifted).
Display
Gay.sky_show — Function
sky_show(primitive)Display a sky primitive as a colored S-expression. The parentheses are colored with the primitive's deterministic color.
Gay.sky_render — Function
sky_render(model; size=30)Render a sky model as colored ASCII art. Each primitive contributes its color to the visualization.
Gay.comrade_show — Function
(comrade-show model)Display a model as colored S-expression + ASCII render.
Gay.comrade_model — Function
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
Display Utilities
Gay.show_colors — Function
show_colors(colors; width=2)Display colors as ANSI true-color blocks in the terminal.
Gay.show_palette — Function
show_palette(colors)Display colors with their hex codes.
Lisp Interface
These functions are available in the Gay REPL (Lisp syntax):
| Lisp Form | Julia Function | Description |
|---|---|---|
(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
endRNG
mutable struct GayRNG
root::SplittableRandom
current::SplittableRandom
invocation::UInt64
seed::UInt64
endSky 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
endDerangeable Permutations
Derangements are permutations with no fixed points (σ(i) ≠ i for all i).
Core Types
Missing docstring for GayDerangementStream. Check Documenter's build log for details.
Generation
Analysis
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
GayAbducer Workflow
Missing docstring for register_observation!. Check Documenter's build log for details.
Direct Abduction
Inverse Operations
Missing docstring for abduce_derangement. Check Documenter's build log for details.
Color Utilities
Gay.color_distance — Function
color_distance(c1::RGB, c2::RGB) -> Float64Euclidean distance in RGB space (simple, fast).
Gay.color_fingerprint — Function
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.
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 for FunctionSignature. Check Documenter's build log for details.
AST Parsing & Hashing
Function Matching
Missing docstring for function_signature. Check Documenter's build log for details.
Missing docstring for abduce_function_match. Check Documenter's build log for details.
Missing docstring for abduce_binary_seed. Check Documenter's build log for details.
Visualization
Missing docstring for render_call_graph. Check Documenter's build log for details.
Constants
GAY_SEED::UInt64 # Default seed (0x6761795f636f6c6f)