lib/lipstick/images/email_banner.rb in aaf-lipstick-4.2.0 vs lib/lipstick/images/email_banner.rb in aaf-lipstick-4.3.0
- old
+ new
@@ -26,21 +26,26 @@
# * `height` is greater than `(ascent - descent)`, making it useless for our
# purposes here.
#
# For image compositing, (x, y) is the position of the top-left corner.
class EmailBanner
- def initialize(image:, title:, environment:)
+ def initialize(image:, title:, environment:,
+ background_color:, resize_to:)
@title = title
@environment = environment
@image = image
+ @background_color = background_color
+ @resize_to = resize_to
end
def to_png
+ bgcolor = @background_color
+
canvas = Magick::ImageList.new
canvas.new_image(WIDTH, HEIGHT) do |f|
f.format = 'PNG'
- f.background_color = '#2A3685'
+ f.background_color = bgcolor
end
annotate_title(canvas)
annotate_environment(canvas)
@@ -88,10 +93,10 @@
environment_format.annotate(canvas, 0, 0, env_x, env_y, @environment)
end
def logo
@logo ||= Magick::Image.read(@image.pathname.to_s).first
- .resize_to_fill(78, 78)
+ .resize_to_fill(@resize_to[0], @resize_to[1])
end
def gap
@gap ||= environment_format.get_type_metrics('AAF').width
end