Class: Bagel::Graphic::Stats::Duration
- Inherits:
-
Object
- Object
- Bagel::Graphic::Stats::Duration
- Defined in:
- lib/bagel/graphic/stats/duration.rb
Constant Summary collapse
- WIDTH =
Stats::WIDTH
- HEIGHT =
90
- COLOR_BG =
COLOR_GREY
- COLOR_TEXT =
COLOR_WHITE
Instance Method Summary collapse
- #draw ⇒ Object
-
#initialize(minutes) ⇒ Duration
constructor
A new instance of Duration.
Constructor Details
#initialize(minutes) ⇒ Duration
Returns a new instance of Duration.
10 11 12 |
# File 'lib/bagel/graphic/stats/duration.rb', line 10 def initialize(minutes) @minutes = minutes end |
Instance Method Details
#draw ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/bagel/graphic/stats/duration.rb', line 14 def draw canvas = Image.new(WIDTH, HEIGHT) { |i| i.background_color = COLOR_BG } text = Image.new(WIDTH, HEIGHT) { |i| i.background_color = COLOR_BG } draw = Magick::Draw.new do |d| d.font_family = FONT_FAMILY d.pointsize = 32 d.gravity = Magick::CenterGravity d.fill = COLOR_TEXT end draw.annotate(text, 0, 0, 0, 0, "SET TIME: #{@minutes} MINUTES") text.trim! canvas.composite!(text, CenterGravity, 0, 0, AtopCompositeOp) end |