20 lines
645 B
Ruby
20 lines
645 B
Ruby
|
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
|