prawn-utils/lib/fourmi/prawn/utils/callbacks/highlight_callback.rb

20 lines
645 B
Ruby
Raw Permalink Normal View History

2022-10-14 09:05:37 +00:00
module Fourmi::Prawn::Utils
module Callbacks
class HighlightCallback
def initialize(color, document, padding_top = 0, padding_left = 0)
@color = color
@document = document
@padding_top = padding_top
@padding_left = padding_left
end
def render_behind(fragment)
original_color = @document.fill_color
@document.fill_color = @color
@document.fill_rectangle([fragment.left - @padding_left, fragment.top + @padding_top], fragment.width + 2 * @padding_left, fragment.height + 2 * @padding_top)
@document.fill_color = original_color
end
end
end
end