Skip to content

Repository files navigation

Twiddle

A headless-friendly immediate-mode UI toolkit for Ruby graphics.

Gem Version Downloads Ruby Version License

Features · Installation · Quick Start · RBGL Integration


Twiddle renders compact controls into Tessel images and accepts plain event hashes, so the same UI can run in tests, a headless renderer, or an RBGL window.

Features

  • Buttons, checkboxes, radios, sliders, drags, text fields, and color editors.
  • Progress bars, plots, collapsing headers, tooltips, and scrolling windows.
  • Deterministic widget IDs with duplicate detection in debug mode.
  • Logical coordinates with configurable rendering and input scale.
  • Keyboard text input, mouse events, wheel scrolling, and modifier keys.
  • Pure image rendering with an optional RBGL event and presentation adapter.

Installation

Add Twiddle to your Gemfile:

gem "twiddle"

Then run:

bundle install

Or install the released gem:

gem install twiddle

Requirements

  • Ruby 3.1 or newer.
  • Tessel and Glyphic are installed as runtime dependencies; RBGL integration is optional.

Quick Start

require "tessel"
require "twiddle"

image = Tessel::Image.new(480, 320, fill: "#101827")
ui = Twiddle::Context.new

ui.frame(events: []) do |g|
  g.window("Parameters") do
    g.slider("speed", 1.0, 0.0..4.0)
  end
end

ui.render(image)
image.write("ui.png")

Pass delta_time: to frame for tooltip timing and provide raw events with types such as :mouse_press, :mouse_move, :scroll, and :key_press.

RBGL integration

Load the adapter and attach Twiddle to an RBGL window:

require "twiddle/rbgl"

Twiddle::RBGL.attach(window)

The adapter polls backend events and presents the rendered Tessel image with set_pixels.

Development

bundle install
bundle exec rake verify

Contributing

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

License

MIT

About

Headless-friendly immediate-mode controls rendered to Tessel images with optional RBGL integration.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages