Mirth

1 program Added 2026-02-05T19:52:58Z Agent: claude-codeModel: sonnetWebSearch: enabled Evidence Report issue View issues
Aliases: —
Provenance: commit 0f668a7cbb · authored 2026-02-05T20:53:58+01:00 · agent claude-code · model sonnet

Sources mentioning this language

2 sources · pl_id: pl/mirth
LLM (this repo) · 1Pldb

Related languages

Mirah (0.40)Mira (0.30)Myth (0.30)Carth (0.27)Jorth (0.27)

LLM-contributed programs

Mandelbrot Fractal

Provenance: commit 0f668a7cbb · authored 2026-02-05T20:53:58+01:00 · agent claude-code · model sonnet · WebSearch enabled
code.mth · added: 2026-02-05T19:52:58Z
module examples.fractal

import std.prelude
import std.number
import std.world
import std.list
import std.maybe
import std.ctypes
import std.buffer

import examples.sdl2

##############
# Mandelbrot Game #
##############

def main {
    +Mandelbrot.Init!
    loop!
    quit!
}

struct +Mandelbrot {
    +platform: +FractalUI
    running: Bool
}

struct +FractalUI {
    +SDL
    +window: +SDL_Window
    +surface: +SDL_Surface
    +renderer: +SDL_Renderer
    +event-buffer: +Buffer
}

def +FractalUI.sdl(f) { /+FractalUI f +FractalUI }

def WIDTH { 800 }
def HEIGHT { 800 }
def SNAKE_WINDOW_FLAGS { SDL_WINDOW_HIDDEN }
def SNAKE_RENDERER_FLAGS { SDL_RENDERER_ACCELERATED SDL_RENDERER_PRESENTVSYNC or }

def +FractalUI.Init! [ +World -- +World +FractalUI ] {
    SDL_INIT_VIDEO >flags
    SDL_Init unwrap!

    "Mandelbrot!" >title
    100 >x 100 >y
    WIDTH >w
    HEIGHT >h
    SNAKE_WINDOW_FLAGS >flags
    create-window! unwrap!
    >+window

    -1 >index
    SNAKE_RENDERER_FLAGS >flags
    create-renderer! unwrap!
    >+renderer

    SDL_GetWindowSurface >+surface

    256 bytes +Buffer.New >+event-buffer

    +FractalUI
}

def +Mandelbrot.Init! [ +World -- +World +Mandelbrot ] {
    +FractalUI.Init! >+platform
    True >running
    +Mandelbrot
}

def +Mandelbrot.loop! [ +World +Mandelbrot -- +World +Mandelbrot ] {
    process-events!
    present!
    while(running,
        10 >U32-clamp >ticks +platform:sdl:delay!
        process-events!
    )
}

def +Mandelbrot.quit! [ +World +Mandelbrot -- +World ] {
    /+Mandelbrot +platform> quit! ldrop
}

def +FractalUI.quit! [ +World +FractalUI -- +World ] {
    /+FractalUI
    destroy-renderer!
    destroy-window!

    +event-buffer> rdrop
    +surface> /+SDL_Surface drop

    quit!
}

def rgba [ Int Int Int Int -- r:CInt g:CInt b:CInt a:CInt ] { >CInt >a >CInt >b >CInt >g >CInt >r }
def background-color { 0 0 0 255 rgba }

def BAIL_OUT { 2.0 }
def FLIPS { 24 }

external(
    F64.pow -> pow [ F64 F64 -- F64 ]
    F64.log10 -> log10 [ F64 -- F64 ]
    cset_pixel -> set_pixel [ +surface:+SDL_Surface CInt CInt CInt -- +surface:+SDL_Surface ]
)

def set_pixel [ +surface:+SDL_Surface Int Int Int -- +surface:+SDL_Surface ] {
    dip(dip:>CInt >CInt) >CInt cset_pixel
}

def +Mandelbrot.plot! [ +Mandelbrot x:Int y:Int Int -- +Mandelbrot ] {
    >iterations x> y> iterations> +platform:sdl:set_pixel
}

def scale_x [ Int -- F64 ] {
    2.47 WIDTH / *
    2.0 -
}

def scale_y [ Int -- F64 ] {
    2.24 HEIGHT / *
    1.12 -
}

def +Mandelbrot.present! [ +World +Mandelbrot -- +World +Mandelbrot ] {
    +platform:sdl:show-window!
    +platform:clear!

    0 \py while(
        @py HEIGHT <,
        0 \px while(
            @px WIDTH <,

            @px scale_x >real
            @py scale_y >imag Complex \z0
            0.0 >real 0.0 >imag Complex \z

            0 \iteration
            while(
                @iteration 250 <
                @z magsq 4 <=
                and,

                @z(dup * @z0 +)
                @iteration:1+
            )

            @iteration 250 < then(
                @px >x @py >y
                @iteration plot!
            )
            @px:1+
        )
        @py:1+
    )

    +platform:sdl:SDL_UpdateWindowSurface drop
}

def +FractalUI.clear! [ +FractalUI -- +FractalUI ] {
    background-color sdl:SDL_SetRenderDrawColor
    sdl:SDL_RenderClear
}

def +Mandelbrot.&event [ +Mandelbrot -- +Mandelbrot SDL_Event ] {
    +platform:+event-buffer:base SDL_Event
}

def +Mandelbrot.process-events! [ +World +Mandelbrot -- +World +Mandelbrot ] {
    while(&event +platform:sdl:SDL_PollEvent >Int 0>, process-event!)
}

def +Mandelbrot.process-event! [ +World +Mandelbrot -- +World +Mandelbrot ] {
    &event type@ match {
        { SDL_QUIT ->
            False running! }
        { _ -> drop }
    }
}

Real programs from Software Heritage

No SWH evidence indexed yet for this language. (Either the SWH mining hasn't reached this language's extensions, or no matching files exist in the archive.)

Contribute — propose a file extension

Tell us where to find evidence about Mirth (mapped to pl/mirth). A reference URL is required; at least one of extension or program code must be provided too. A maintainer reviews each submission via a draft PR before anything lands.
Optional: attach a program from that URL
If the reference URL points at a single source file you'd like to add as an example program, paste it below. The workflow will write it under languages/Mirth/programs/<sha>/. Keep under ~200 lines.
(or open the pre-filled issue directly)
← MIRROR MISC →