Class: Rubygoo::RubygameRenderAdapter
- Inherits:
-
Object
- Object
- Rubygoo::RubygameRenderAdapter
- Defined in:
- lib/rubygoo/adapters/rubygame_render_adapter.rb
Instance Method Summary collapse
- #convert_color(goo_color) ⇒ Object
- #draw_box(x1, y1, x2, y2, color) ⇒ Object
- #draw_circle(cx, cy, radius, color) ⇒ Object
- #draw_circle_filled(cx, cy, radius, color) ⇒ Object
- #draw_image(img, x, y, color = nil) ⇒ Object
- #fill(x1, y1, x2, y2, color) ⇒ Object
- #fill_screen(color) ⇒ Object
- #finish_drawing ⇒ Object
-
#initialize(screen) ⇒ RubygameRenderAdapter
constructor
A new instance of RubygameRenderAdapter.
- #render_text(text, font_file, font_size, color) ⇒ Object
- #size_text(text, font_file, font_size) ⇒ Object
- #start_drawing ⇒ Object
Constructor Details
#initialize(screen) ⇒ RubygameRenderAdapter
Returns a new instance of RubygameRenderAdapter.
4 5 6 7 |
# File 'lib/rubygoo/adapters/rubygame_render_adapter.rb', line 4 def initialize(screen) @screen = screen TTF.setup end |
Instance Method Details
#convert_color(goo_color) ⇒ Object
29 30 31 |
# File 'lib/rubygoo/adapters/rubygame_render_adapter.rb', line 29 def convert_color(goo_color) [goo_color.r,goo_color.g,goo_color.b,goo_color.a] end |
#draw_box(x1, y1, x2, y2, color) ⇒ Object
9 10 11 |
# File 'lib/rubygoo/adapters/rubygame_render_adapter.rb', line 9 def draw_box(x1,y1,x2,y2,color) @screen.draw_box [x1,y1], [x2,y2], convert_color(color) end |
#draw_circle(cx, cy, radius, color) ⇒ Object
13 14 15 |
# File 'lib/rubygoo/adapters/rubygame_render_adapter.rb', line 13 def draw_circle(cx,cy,radius,color) @screen.draw_circle_a [cx,cy],radius,convert_color(color) end |
#draw_circle_filled(cx, cy, radius, color) ⇒ Object
17 18 19 |
# File 'lib/rubygoo/adapters/rubygame_render_adapter.rb', line 17 def draw_circle_filled(cx,cy,radius,color) @screen.draw_circle_s [cx,cy],radius,convert_color(color) end |
#draw_image(img, x, y, color = nil) ⇒ Object
39 40 41 |
# File 'lib/rubygoo/adapters/rubygame_render_adapter.rb', line 39 def draw_image(img, x, y, color=nil) img.blit @screen, [x,y] end |
#fill(x1, y1, x2, y2, color) ⇒ Object
25 26 27 |
# File 'lib/rubygoo/adapters/rubygame_render_adapter.rb', line 25 def fill(x1,y1,x2,y2,color) @screen.draw_box_s [x1,y1], [x2,y2], convert_color(color) end |
#fill_screen(color) ⇒ Object
21 22 23 |
# File 'lib/rubygoo/adapters/rubygame_render_adapter.rb', line 21 def fill_screen(color) @screen.draw_box_s [0,0], [@screen.width,@screen.height], convert_color(color) end |
#finish_drawing ⇒ Object
35 36 37 |
# File 'lib/rubygoo/adapters/rubygame_render_adapter.rb', line 35 def finish_drawing() @screen.flip end |
#render_text(text, font_file, font_size, color) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/rubygoo/adapters/rubygame_render_adapter.rb', line 51 def render_text(text, font_file, font_size, color) @font_cache ||= {} @font_cache[font_file] ||= {} font = @font_cache[font_file][font_size] ||= TTF.new(font_file, font_size) text_image = font.render text, true, convert_color(color) end |
#size_text(text, font_file, font_size) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/rubygoo/adapters/rubygame_render_adapter.rb', line 43 def size_text(text, font_file, font_size) @font_cache ||= {} @font_cache[font_file] ||= {} font = @font_cache[font_file][font_size] ||= TTF.new(font_file, font_size) font.size_text text end |
#start_drawing ⇒ Object
33 |
# File 'lib/rubygoo/adapters/rubygame_render_adapter.rb', line 33 def start_drawing(); end |