Class: PandaCanvas::DrawingCanvas

Inherits:
Gosu::Window
  • Object
show all
Includes:
DrawingMethods, DrawingWithCleanRoom, DrawingWithFibers
Defined in:
lib/panda_canvas/drawing_canvas.rb

Overview

DrawingCanvas is a subclassed Gosu::Window that is used for drawing.

Constant Summary

Constants included from DrawingMethods

PandaCanvas::DrawingMethods::CANVAS_CALLS, PandaCanvas::DrawingMethods::CANVAS_UPDATE

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DrawingWithFibers

#flush, #prepare, #update

Methods included from DrawingWithCleanRoom

#prepare, #update

Methods included from DrawingMethods

#font, #sym_color, #text, #text_rel

Constructor Details

#initialize(width, height, &block) ⇒ DrawingCanvas

Creates a new canvas window with dimensions width and height. A block is passed to be executed.



23
24
25
26
27
28
29
# File 'lib/panda_canvas/drawing_canvas.rb', line 23

def initialize(width, height, &block)
  super(width, height, false)
  self.caption = 'Panda Canvas'
  @image = TexPlay.create_image(self, width, height)
  @canvas_calls = []
  prepare &block
end

Instance Attribute Details

#imageObject (readonly)

TexPlay image, which is drawn in the window.



19
20
21
# File 'lib/panda_canvas/drawing_canvas.rb', line 19

def image
  @image
end

Instance Method Details

#drawObject

Draws the image in memory.



32
33
34
35
# File 'lib/panda_canvas/drawing_canvas.rb', line 32

def draw
  @image.draw(0, 0, 0)
  @canvas_calls.each {|call| send call[0], *call[1..-1] }
end