Class: PandaCanvas::AnimationCanvas
- Inherits:
-
Gosu::Window
- Object
- Gosu::Window
- PandaCanvas::AnimationCanvas
- Includes:
- DrawingMethods
- Defined in:
- lib/panda_canvas/animation_canvas.rb
Overview
AnimationCanvas is a subclassed Gosu::Window that is used for animation.
Constant Summary
Constants included from DrawingMethods
DrawingMethods::CANVAS_CALLS, DrawingMethods::CANVAS_UPDATE
Instance Attribute Summary collapse
-
#image ⇒ Object
readonly
TexPlay image, which is drawn in the window.
Instance Method Summary collapse
-
#draw ⇒ Object
Draws the image in memory.
-
#initialize(width, height, &block) ⇒ AnimationCanvas
constructor
Creates a new canvas window with dimensions
widthandheight. -
#update ⇒ Object
Runs an animation block.
Methods included from DrawingMethods
#font, #sym_color, #text, #text_rel
Constructor Details
#initialize(width, height, &block) ⇒ AnimationCanvas
Creates a new canvas window with dimensions width and height. A block is passed to be executed.
13 14 15 16 17 18 19 20 |
# File 'lib/panda_canvas/animation_canvas.rb', line 13 def initialize(width, height, &block) super(width, height, false) self.caption = 'Panda Canvas' @block = block @image = TexPlay.create_image(self, width, height) @agent = DrawingAgent.new(self, @image) @agent.frame = 0 end |
Instance Attribute Details
#image ⇒ Object (readonly)
TexPlay image, which is drawn in the window.
9 10 11 |
# File 'lib/panda_canvas/animation_canvas.rb', line 9 def image @image end |
Instance Method Details
#draw ⇒ Object
Draws the image in memory.
23 24 25 26 |
# File 'lib/panda_canvas/animation_canvas.rb', line 23 def draw @image.draw(0, 0, 0) @agent.canvas_calls.each {|call| send call[0], *call[1..-1] } end |
#update ⇒ Object
Runs an animation block.
29 30 31 32 33 34 35 |
# File 'lib/panda_canvas/animation_canvas.rb', line 29 def update @image.rect 0, 0, width, height, :color => :black, :fill => true DrawingMethods::CANVAS_UPDATE.each {|call| send call[0], *call[1..-1] } @agent.canvas_calls = [] @agent.frame += 1 @agent.instance_eval &@block end |