Skip to content

Instantly share code, notes, and snippets.

@mat813
Created April 18, 2011 17:08
Show Gist options
  • Save mat813/925715 to your computer and use it in GitHub Desktop.
Save mat813/925715 to your computer and use it in GitHub Desktop.
def stretch_box(ratio, point, options, &block)
x, y = if ratio.is_a?(Array)
ratio.map(&:to_f)
else
[ratio.to_f, 1.0]
end
options[:width] = options[:width] / x
options[:height] = options[:height] / y if options.key?(:height)
point[0] += bounds.absolute_left
point[1] += bounds.absolute_bottom
point[0] /= x
point[1] /= y
canvas do
transformation_matrix(x, 0, 0, y, 0, 0) do
bounding_box(point, options, &block)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment