class RatatuiRuby::Widgets::Canvas

Provides a drawing surface for custom shapes.

Standard widgets cover standard cases. Sometimes you need to draw a map, a custom diagram, or a game. Character grids are too coarse for fine detail.

This widget increases the resolution. It uses Braille patterns or block characters to create a “sub-pixel” drawing surface.

Use it to implement free-form graphics, high-resolution plots, or geographic maps.

Examples

Canvas.new(
  x_bounds: [-180, 180],
  y_bounds: [-90, 90],
  shapes: [
    Shape::Map.new(color: :green, resolution: :high),
    Shape::Circle.new(x: 0, y: 0, radius: 10, color: :red),
    Shape::Label.new(x: -122.4, y: 37.8, text: "San Francisco")
  ]
)