Skip to content

Repository files navigation

Gesso

Processing-style 2D drawing for Ruby, backed by Tessel and RBGL.

Gem Version Downloads Ruby Version License

Features · Installation · Quick Start · Browser · CLI


Gesso is a small creative-coding DSL for sketches that run in an RBGL window or render deterministic PNG frames without a window.

Features

  • Immediate-mode setup and draw callbacks.
  • Lines, shapes, images, transforms, text, and configurable stroke styles.
  • RGB and HSB color modes with corner, center, and radius shape modes.
  • Seeded random values and deterministic smooth noise.
  • Optional rlsl shader backgrounds and Twiddle control panels.
  • Interactive windows and headless frame rendering.

Installation

Add Gesso to your Gemfile:

gem "gesso"

Then run:

bundle install

Or install the released gem:

gem install gesso

Requirements

  • Ruby 3.1 or newer.
  • A C toolchain is needed when Bundler builds Larb's native extension.

Quick Start

require "gesso"

sketch = Gesso.run(width: 320, height: 200) do
  setup { background 16, 24, 39 }

  draw do
    fill 240, 120, 80
    circle width / 2, height / 2, 30
  end
end

sketch.canvas.write("shot.png")

Install the optional Flipbook gem to record the next frames as an animated GIF:

Gesso.run(width: 320, height: 200) do
  save_gif("sketch.gif", frames: 120, fps: 30)
  draw do
    background 16, 24, 39
    fill 240, 120, 80
    circle width / 2 + Math.sin(millis / 200.0) * 40, height / 2, 30
  end
end

For a top-level sketch file, load the automatic DSL:

require "gesso/auto"

size 320, 200
draw do
  background "#101827"
  fill "#f07850"
  circle 160, 100, 30
end

CLI

gesso run examples/bubbles.rb
gesso render examples/bubbles.rb --frames 3 -o frames

Use --backend file for a headless window run. The examples/gui_sketch.rb example shows the optional Twiddle panel.

Browser

Add the Webvas gem to the application bundle to run a sketch in a browser worker. The Webvas playground build includes Gesso and its graphics dependencies.

require "gesso"

Gesso.run(width: 480, height: 320, runner: :web) do
  background "#171a18"
  draw do
    background "#171a18"
    fill "#d38a62"
    circle 240, 160, 48
  end
end

Development

bundle install
bundle exec rake verify

Contributing

Bug reports and pull requests are welcome at rbgfx/gesso.

License

MIT

About

Processing-style 2D drawing for Ruby with interactive windows and deterministic headless rendering.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages