Class: Salamander::Canvas

Inherits:
Object
  • Object
show all
Defined in:
lib/salamander/canvas.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(surface) ⇒ Canvas

Returns a new instance of Canvas.



5
6
7
# File 'lib/salamander/canvas.rb', line 5

def initialize (surface)
  @surface = surface
end

Instance Attribute Details

#surfaceObject (readonly)

Returns the value of attribute surface.



3
4
5
# File 'lib/salamander/canvas.rb', line 3

def surface
  @surface
end

Instance Method Details

#arc(x, y, radius, left, right, color) ⇒ Object



21
22
23
# File 'lib/salamander/canvas.rb', line 21

def arc (x, y, radius, left, right, color)
  SDL::Gfx.arcColor(surface, x.round, y.round, radius.round, left.round, right.round, color)
end

#circle(x, y, radius, color) ⇒ Object



25
26
27
# File 'lib/salamander/canvas.rb', line 25

def circle (x, y, radius, color)
  SDL::Gfx.circleColor(surface, x.round, y.round, radius.round, color)
end

#heightObject



34
35
36
# File 'lib/salamander/canvas.rb', line 34

def height
  surface.h
end

#line(x1, y1, x2, y2, color) ⇒ Object



17
18
19
# File 'lib/salamander/canvas.rb', line 17

def line (x1, y1, x2, y2, color)
  SDL::Gfx.lineColor(surface, x1.round, y1.round, x2.round, y2.round, color)
end

#point(x, y, color) ⇒ Object



13
14
15
# File 'lib/salamander/canvas.rb', line 13

def point (x, y, color)
  SDL::Gfx.pixelColor(surface, x.round, y.round, color)
end

#redrawObject



9
10
11
# File 'lib/salamander/canvas.rb', line 9

def redraw
  SDL.UpdateRect(surface, 0, 0, width, height)
end

#widthObject



30
31
32
# File 'lib/salamander/canvas.rb', line 30

def width
  surface.w
end