Allowing for save_png to rotate either direction

This commit is contained in:
Andy Meneely
2014-08-26 16:29:37 -04:00
parent 3659579404
commit d4bde92d89
3 changed files with 22 additions and 7 deletions
+5 -5
View File
@@ -3,9 +3,9 @@ module Squib
# :nodoc:
# @api private
def save_png(i, dir, prefix, rotate)
if rotate
surface = rotated_image
def save_png(i, dir, prefix, do_rotate, angle)
if [true, :clockwise, :counterclockwise].include?(do_rotate)
surface = rotated_image(angle)
else
surface = @cairo_surface
end
@@ -14,10 +14,10 @@ module Squib
# :nodoc:
# @api private
def rotated_image
def rotated_image(angle)
rotated_cc = Cairo::Context.new(Cairo::ImageSurface.new(@height, @width) )
rotated_cc.translate(@height * 0.5, @width * 0.5)
rotated_cc.rotate(0.5 * Math::PI)
rotated_cc.rotate(angle)
rotated_cc.translate(@width * -0.5, @height * -0.5)
rotated_cc.set_source(@cairo_surface)
rotated_cc.paint