Class: Spacy::Window
- Inherits:
-
Reflex::Window
- Object
- Reflex::Window
- Spacy::Window
- Defined in:
- lib/spacy/window.rb
Instance Method Summary collapse
- #close ⇒ Object
- #draw ⇒ Object
-
#initialize ⇒ Window
constructor
A new instance of Window.
- #key_down(key) ⇒ Object
- #key_up(key) ⇒ Object
- #points_down(points) ⇒ Object
- #points_moved(points) ⇒ Object
- #points_up(points) ⇒ Object
- #update(dt) ⇒ Object
Constructor Details
#initialize ⇒ Window
Returns a new instance of Window.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/spacy/window.rb', line 15 def initialize () super set :title, Reflex::Application.instance.name set :bounds, 100, 100, 600, 500 @text = Text.new p = painter p.background 1 p.fill 0 p.stroke nil p.font Rays::Font.new "Menlo", 12 end |
Instance Method Details
#close ⇒ Object
46 47 48 49 |
# File 'lib/spacy/window.rb', line 46 def close () #Profiler__.print_profile STDOUT super end |
#draw ⇒ Object
36 37 38 39 40 41 42 43 44 |
# File 'lib/spacy/window.rb', line 36 def draw () super paint do |p| h = p.font.height draw_text p, h draw_cursor p, h draw_fps p end end |
#key_down(key) ⇒ Object
51 52 53 |
# File 'lib/spacy/window.rb', line 51 def key_down (key) @text.selection = key.chars end |
#key_up(key) ⇒ Object
55 56 |
# File 'lib/spacy/window.rb', line 55 def key_up (key) end |
#points_down(points) ⇒ Object
58 59 |
# File 'lib/spacy/window.rb', line 58 def points_down (points) end |
#points_moved(points) ⇒ Object
64 65 |
# File 'lib/spacy/window.rb', line 64 def points_moved (points) end |
#points_up(points) ⇒ Object
61 62 |
# File 'lib/spacy/window.rb', line 61 def points_up (points) end |
#update(dt) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/spacy/window.rb', line 27 def update (dt) @t ||= Time.now @c ||= 0 redraw @c += 1 @fps = @c / (Time.now - @t) puts "#{@fps} FPS" if (@c % 100) == 0 end |