Class: Bagel::Graphic::Scoreboard::Name

Inherits:
Object
  • Object
show all
Defined in:
lib/bagel/graphic/scoreboard/name.rb

Constant Summary collapse

WIDTH =
160
HEIGHT =
50
PADDING =
10

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Name

Returns a new instance of Name.



9
10
11
# File 'lib/bagel/graphic/scoreboard/name.rb', line 9

def initialize(name)
  @name = name
end

Instance Method Details

#drawObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/bagel/graphic/scoreboard/name.rb', line 13

def draw
  text = Image.new(WIDTH, HEIGHT) { self.background_color = COLOR_GREY }

  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_WHITE
  end

  draw.annotate(text, 0, 0, 0, 0, @name.upcase)
  text.trim!

  canvas = Image.new(WIDTH, HEIGHT) { self.background_color = COLOR_GREY }
  canvas.composite!(text, WestGravity, PADDING, 0, OverCompositeOp)
end