Class: Inch::Badge::Image::PNG

Inherits:
Base
  • Object
show all
Defined in:
lib/inch/badge/image/png.rb

Instance Attribute Summary

Attributes inherited from Base

#style

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Inch::Badge::Image::Base

Instance Method Details

#saveObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/inch/badge/image/png.rb', line 7

def save
  base_image = ChunkyPNG::Image.from_file( Config.image_path('bg.png') )

  x = 0
  @grades.each do |grade|
    grade.width.times do |i|
      if x < grade.section_width
        badge  = load_image( Config.image_path("grade-#{grade.name}-#{grade.prefix(x)}.png") )
        base_image.compose!(badge, 34+x, 0)
      end
      x += 1
    end
  end

  base_image.save(@filename, :fast_rgba)
end