Sha256: c3c0a805387b90fe7d4d72b3d50310b3d86090f3264edf04c6389daaa48d0527

Contents?: true

Size: 864 Bytes

Versions: 6

Compression:

Stored size: 864 Bytes

Contents

# -*- coding: utf-8 -*-


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

require 'reflex'


class HelloWindow < Reflex::Window

  def initialize ()
    super
    set :title,  "Hello Reflex!"
    set :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 (p)
    p.push do |_|
      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

6 entries across 6 versions & 1 rubygems

Version Path
reflexion-0.1.12 samples/hello.rb
reflexion-0.1.11 samples/hello.rb
reflexion-0.1.10 samples/hello.rb
reflexion-0.1.9.1 samples/hello.rb
reflexion-0.1.9 samples/hello.rb
reflexion-0.1.8 samples/hello.rb