Module: Chingu::GFXHelpers
Overview
Various helper-methods to manipulate the screen. All drawings depend on the global variable $window which should be an instance of Gosu::Window or Chingu::Window
Instance Method Summary collapse
-
#fill(color) ⇒ Object
Fills whole window with color ‘color’.
-
#fill_gradient(options) ⇒ Object
Fills window or a given rect with a gradient between two colors.
-
#fill_rect(rect, color) ⇒ Object
Fills a given Rect ‘rect’ with Color ‘color’.
Instance Method Details
#fill(color) ⇒ Object
Fills whole window with color ‘color’.
33 34 35 36 37 38 39 |
# File 'lib/chingu/gfx_helpers.rb', line 33 def fill(color) $window.draw_quad(0, 0, color, $window.width, 0, color, $window.width, $window.height, color, 0, $window.height, color, 0, :default) end |
#fill_gradient(options) ⇒ Object
Fills window or a given rect with a gradient between two colors.
:from - Start with this color
:to - End with this color
:rect - Only fill rectangle :rect with the gradient, either a Rect-instance or [x,y,width,height] Array.
:orientation - Either :vertical (top to bottom) or :horizontal (left to right)
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/chingu/gfx_helpers.rb', line 61 def fill_gradient() = { :from => Gosu::Color.new(255,0,0,0), :to => Gosu::Color.new(255,255,255,255), :thickness => 10, :orientation => :vertical, :rect => Rect.new([0, 0, $window.width, $window.height]), :zorder => 0, :mode => :default } = .merge() rect = Rect.new([:rect]) if [:orientation] == :vertical $window.draw_quad( rect.x, rect.y, [:from], rect.right, rect.y, [:from], rect.right, rect.bottom, [:to], rect.x, rect.bottom, [:to], [:zorder], [:mode] ) else $window.draw_quad( rect.x, rect.y, [:from], rect.x, rect.bottom, [:from], rect.right, rect.bottom, [:to], rect.right, rect.y, [:to], [:zorder], [:mode] ) end end |
#fill_rect(rect, color) ⇒ Object
Fills a given Rect ‘rect’ with Color ‘color’
44 45 46 47 48 49 50 51 |
# File 'lib/chingu/gfx_helpers.rb', line 44 def fill_rect(rect, color) rect = Rect.new(rect) # Make sure it's a rect $window.draw_quad( rect.x, rect.y, color, rect.right, rect.y, color, rect.right, rect.bottom, color, rect.x, rect.bottom, color, 0, :default) end |