Sha256: 63e7408d5fe35a1ebfb3bc962520429232af088ca3d7683415f47c5833021b2e
Contents?: true
Size: 1.39 KB
Versions: 2
Compression:
Stored size: 1.39 KB
Contents
# -*- coding: utf-8 -*- require 'rays/image' require 'rays/painter' require 'reflex/application' require 'reflex/window' require 'spacy/text' module Spacy class Window < Reflex::Window def initialize () super set :title, Reflex::Application.instance.name set :frame, 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 def close () #Profiler__.print_profile STDOUT super end def on_update (e) redraw end def on_draw (e) super p = e.painter h = p.font.height draw_text p, h draw_cursor p, h draw_fps p, e.fps end def on_key_down (e) @text.selection = e.chars end def on_key_up (e) end def on_pointer_down (e) end def on_pointer_up (e) end def on_pointer_move (e) end private def draw_text (p, lineheight) y = 0 @text.each do |line| p.text line, 0, y y += lineheight end end def draw_cursor (p, lineheight) row, col = @text.cursor x = p.font.width @text[row][0..col] p.rect x, row * lineheight, 4, lineheight end def draw_fps (p, fps) p.text "#{fps.to_i} FPS", *size.move_by(-64, -20).to_a end end# Window end # Spacy
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
spacy-0.1.9 | lib/spacy/window.rb |
spacy-0.1.8 | lib/spacy/window.rb |