Sha256: a29e8588c531782e872fa986f8473f0bbfdf968e7c77c2453b9fdd7a82026757

Contents?: true

Size: 829 Bytes

Versions: 25

Compression:

Stored size: 829 Bytes

Contents

%w[xot rays reflex]
  .map  {|s| File.expand_path "../../#{s}/lib", __dir__}
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}

require 'reflex'


class HelloWindow < Reflex::Window

  def initialize ()
    super title: "Hello Reflex!", frame: [100, 100, 320, 240]
    p = painter
    p.font Reflex::Font.new "Menlo", 32
    p.background 0
    p.fill 1
  end

  def on_draw (e)
    p = e.painter
    draw_grid p
    p.text "hello world!", 5, 5
  end

  def on_update (e)
    painter.background = rand, rand, rand
    redraw
  end

  def draw_grid (painter)
    painter.push do |p|
      w, h = frame.size.to_a
      p.stroke 0.5, 0.4
      (0..w).step(5).each {|x| p.line x, 0, x, h}
      (0..h).step(5).each {|y| p.line 0, y, w, y}
    end
  end

end# HelloWindow


Reflex.start do
  HelloWindow.new.show
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
reflexion-0.3 samples/hello.rb
reflexion-0.2.1 samples/hello.rb
reflexion-0.2 samples/hello.rb
reflexion-0.1.57 samples/hello.rb
reflexion-0.1.56 samples/hello.rb
reflexion-0.1.55 samples/hello.rb
reflexion-0.1.54 samples/hello.rb
reflexion-0.1.53 samples/hello.rb
reflexion-0.1.52 samples/hello.rb
reflexion-0.1.51 samples/hello.rb
reflexion-0.1.50 samples/hello.rb
reflexion-0.1.49 samples/hello.rb
reflexion-0.1.48 samples/hello.rb
reflexion-0.1.47 samples/hello.rb
reflexion-0.1.46 samples/hello.rb
reflexion-0.1.45 samples/hello.rb
reflexion-0.1.44 samples/hello.rb
reflexion-0.1.43 samples/hello.rb
reflexion-0.1.42 samples/hello.rb
reflexion-0.1.41 samples/hello.rb