A headless-friendly immediate-mode UI toolkit for Ruby graphics.
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.
- 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.
Add Twiddle to your Gemfile:
gem "twiddle"Then run:
bundle installOr install the released gem:
gem install twiddle- Ruby 3.1 or newer.
- Tessel and Glyphic are installed as runtime dependencies; RBGL integration is optional.
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.
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.
bundle install
bundle exec rake verifyBug reports and pull requests are welcome at rbgfx/twiddle.