Class: Bagel::Graphic::Stats::Result
- Inherits:
-
Object
- Object
- Bagel::Graphic::Stats::Result
- Defined in:
- lib/bagel/graphic/stats/result.rb
Constant Summary collapse
- WIDTH =
Stats::WIDTH
- HEIGHT =
70
- COLOR_BG =
COLOR_GREY
- COLOR_TEXT =
COLOR_WHITE
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize(names, games) ⇒ Result
constructor
A new instance of Result.
Constructor Details
#initialize(names, games) ⇒ Result
Returns a new instance of Result.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/bagel/graphic/stats/result.rb', line 10 def initialize(names, games) @names = names.map(&:upcase) @games = games @d = Magick::Draw.new do |d| d.font_family = FONT_FAMILY d.pointsize = 36 d.gravity = Magick::CenterGravity d.fill = COLOR_TEXT end end |
Instance Method Details
#draw ⇒ Object
22 23 24 25 26 27 |
# File 'lib/bagel/graphic/stats/result.rb', line 22 def draw canvas = Image.new(WIDTH, HEIGHT) { |i| i.background_color = COLOR_BG } canvas.composite!(cell(@names.first), WestGravity, 0, 0, OverCompositeOp) canvas.composite!(cell(@games.join(' - '), 72), CenterGravity, 0, 0, OverCompositeOp) canvas.composite!(cell(@names.last), EastGravity, 0, 0, OverCompositeOp) end |