Class: Bagel::Graphic::Scoreboard::Score
- Inherits:
-
Object
- Object
- Bagel::Graphic::Scoreboard::Score
- Defined in:
- lib/bagel/graphic/scoreboard/score.rb
Constant Summary collapse
- WIDTH =
50
- HEIGHT =
50
Instance Method Summary collapse
- #color_bg ⇒ Object
- #color_text ⇒ Object
- #draw ⇒ Object
-
#initialize(value) ⇒ Score
constructor
A new instance of Score.
Constructor Details
#initialize(value) ⇒ Score
Returns a new instance of Score.
7 8 9 |
# File 'lib/bagel/graphic/scoreboard/score.rb', line 7 def initialize(value) @value = value end |
Instance Method Details
#color_bg ⇒ Object
29 30 31 |
# File 'lib/bagel/graphic/scoreboard/score.rb', line 29 def color_bg raise 'abstract' end |
#color_text ⇒ Object
33 34 35 |
# File 'lib/bagel/graphic/scoreboard/score.rb', line 33 def color_text raise 'abstract' end |
#draw ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/bagel/graphic/scoreboard/score.rb', line 11 def draw text = Image.new(HEIGHT * 2, HEIGHT * 2) { |i| i.background_color = color_bg } draw = Magick::Draw.new do |d| d.font_family = FONT_FAMILY d.font_weight = FONT_WEIGHT d.pointsize = FONT_SIZE d.gravity = CenterGravity d.fill = color_text end draw.annotate(text, 0, 0, 0, 0, @value.to_s) text.trim! canvas = Image.new(HEIGHT, HEIGHT) { |i| i.background_color = color_bg } canvas.composite!(text, CenterGravity, 0, 0, OverCompositeOp) end |