Class: Bagel::Graphic::Stats::Stat
- Inherits:
-
Object
- Object
- Bagel::Graphic::Stats::Stat
- Defined in:
- lib/bagel/graphic/stats/stat.rb
Constant Summary collapse
- WIDTH =
Stats::WIDTH
- HEIGHT =
65
- COLOR_TEXT =
COLOR_WHITE
- COLOR_TEXT_HIGHLIGHT =
COLOR_ORANGE
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize(index, stat) ⇒ Stat
constructor
A new instance of Stat.
Constructor Details
#initialize(index, stat) ⇒ Stat
Returns a new instance of Stat.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/bagel/graphic/stats/stat.rb', line 9 def initialize(index, stat) @index = index @stat = stat @color_bg = @index.even? ? COLOR_GREY_LIGHT : COLOR_GREY_DARK @canvas = Image.new(WIDTH, HEIGHT) { |i| i.background_color = @color_bg } @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
24 25 26 27 28 29 30 31 32 |
# File 'lib/bagel/graphic/stats/stat.rb', line 24 def draw left = cell(value: @stat.values[0], highlight: @stat.superior[0], is_small: false) center = cell(value: @stat.name, is_small: true) right = cell(value: @stat.values[1], highlight: @stat.superior[1], is_small: false) @canvas.composite!(left, WestGravity, 0, 0, OverCompositeOp) @canvas.composite!(center, CenterGravity, 0, 0, OverCompositeOp) @canvas.composite!(right, EastGravity, 0, 0, OverCompositeOp) end |