Project

twiddle

0.0
The project is in a healthy, maintained state
Small headless friendly widgets and a Tessel image renderer.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

>= 0.1.0, < 1
>= 0.1.0, < 1
 Project Readme

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