Stream: show and tell

Topic: Early progress migrating `roc-ray` graphics platform


view this post on Zulip Luke Boswell (Jan 11 2026 at 10:47):

Thought I'd share some cool progress on roc-ray -- I've been using this to help fix bugs in the platform/host side of things and validate the platform packages and linking designs. I got it to a pretty cool point today and wanted to share with everyone here.

roc-ray-alpha-1.gif

app [Model, program] { rr: platform "https://github.com/lukewilliamboswell/roc-ray/releases/download/alpha-0-test/HB6qgLwjKqjmVXTxJEzFqnC72SJEfif98CnJ8ZVN86UE.tar.zst" }

import rr.Draw
import rr.Color
import rr.PlatformState

Model : {
    message: Str,
}
program = { init!, render! }

init! : () => Try(Model, [Exit(I64), ..])
init! = || Ok({
    message: "Roc :heart: Raylib!",
})

render! : Model, PlatformState => Try(Model, [Exit(I64), ..])
render! = |model, state| {

    # Circle follows the mouse, changes color when clicked
    circle_color = if state.mouse.left { Color.Red } else { Color.Green }

    Draw.draw!(RayWhite, || {
        Draw.text!({ pos: { x: 10, y: 10 }, text: model.message, size: 30, color: Color.DarkGray })
        Draw.rectangle!({ x: 100, y: 200, width: 100, height: 80, color: Color.Red })
        Draw.line!({ start: { x: 100, y: 500 }, end: { x: 600, y: 550 }, color: Color.Blue })

        # Draw circle last so it is drawn over the top of other shapes
        Draw.circle!({ center: { x: state.mouse.x, y: state.mouse.y }, radius: 50, color: circle_color })
    })

    Ok(model)
}

This is using a very alpha release that only has macos pre-built host binaries included, and definitely requires roc built from source. I'd like to get Linux and Windows hosts supported next I think before adding too many more features and making a real branch in the roc-ray repository.

$ roc build examples/hello_world.roc

Note* that we have a bug that prevents using the run subcommand, so you just have to build it first then run the executable.


Last updated: Jan 12 2026 at 12:19 UTC