Class: Lipstick::Images::LogoOnlyEmailBanner
- Inherits:
-
Object
- Object
- Lipstick::Images::LogoOnlyEmailBanner
- Defined in:
- lib/lipstick/images/logo_only_email_banner.rb
Overview
Creates a logo-only email banner, with two elements.
-
Logo, centered vertically and horizontally within the image.
-
Environment string, stamped across the logo.
The math here seemed like it would be a lot simpler than the EmailBanner class, but then I went and made it all confusing by bringing trigonometry into it. I promise there was a good reason for doing it.
Instance Method Summary collapse
-
#initialize(image:, environment:, background_color:) ⇒ LogoOnlyEmailBanner
constructor
A new instance of LogoOnlyEmailBanner.
- #to_png ⇒ Object
Constructor Details
#initialize(image:, environment:, background_color:) ⇒ LogoOnlyEmailBanner
Returns a new instance of LogoOnlyEmailBanner.
14 15 16 17 18 19 20 |
# File 'lib/lipstick/images/logo_only_email_banner.rb', line 14 def initialize(image:, environment:, background_color:) require 'rmagick' @environment = environment.upcase @image = image @background_color = background_color end |
Instance Method Details
#to_png ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/lipstick/images/logo_only_email_banner.rb', line 22 def to_png bgcolor = @background_color canvas = Magick::ImageList.new canvas.new_image(WIDTH, HEIGHT) do |f| f.format = 'PNG' f.background_color = bgcolor end canvas.composite!(logo, logo_x, logo_y, Magick::SrcOverCompositeOp) annotate_environment(canvas) canvas.to_blob end |