Class: IRB::Canvas (Ruby 2.7.5)
Description: Class : IRB::Canvas - Ruby 2.7.5

### Home Classes Methods

### In Files

- irb/easter-egg.rb

### Parent

Object

### Methods

- ::new
- #draw
- #line

### Class/Module Index

Quicksearch

- Binding
- IRB::Abort
- IRB::Canvas
- IRB::Color
- IRB::Color::SymbolState
- IRB::Context
- IRB::ContextExtender
- IRB::ExtendCommandBundle
- IRB::FileInputMethod
- IRB::Frame
- IRB::Frame::FrameOverflow
- IRB::Frame::FrameUnderflow
- IRB::History
- IRB::InputMethod
- IRB::Inspector
- IRB::Irb
- IRB::IrbLoader
- IRB::JobManager
- IRB::LoadAbort
- IRB::MethodExtender
- IRB::Notifier
- IRB::Notifier::AbstractNotifier
- IRB::Notifier::CompositeNotifier
- IRB::Notifier::ErrUndefinedNotifier
- IRB::Notifier::ErrUnrecognizedLevel
- IRB::Notifier::LeveledNotifier
- IRB::Notifier::NoMsgNotifier
- IRB::OutputMethod
- IRB::OutputMethod::NotImplementedError
- IRB::ReadlineInputMethod
- IRB::ReidlineInputMethod
- IRB::RubyModel
- IRB::StdioInputMethod
- IRB::StdioOutputMethod
- IRB::Vec
- IRB::WorkSpace
- Object
- XMP
- XMP::StringInputMethod

No matching classes.

# IRB::Canvas

### Public Class Methods

new((h, w)) click to toggle source

                   # File irb/easter-egg.rb, line 32
    def initialize((h, w))
      @data = (0..h-2).map { [0] * w }
      @scale = [w / 2.0, h-2].min
      @center = Complex(w / 2, h-2)
    end

### Public Instance Methods

draw() click to toggle source

                   # File irb/easter-egg.rb, line 55
    def draw
      @data.each {|row| row.fill(0) }
      yield
      @data.map {|row| row.map {|n| " ',;"[n] }.join }.join("\n")
    end

line((x1, y1), (x2, y2)) click to toggle source

                   # File irb/easter-egg.rb, line 38
    def line((x1, y1), (x2, y2))
      p1 = Complex(x1, y1) / 2 * @scale + @center
      p2 = Complex(x2, y2) / 2 * @scale + @center
      line0(p1, p2)
    end