Class: Rixmap::Image
- Inherits:
-
Object
- Object
- Rixmap::Image
- Defined in:
- lib/rixmap/image.rb
Instance Method Summary collapse
-
#resize(width, height, anchor = nil) ⇒ Rixmap::Image
指定サイズに画像サイズを変更します.
-
#resize!(width, height, anchor = nil) ⇒ Rixmnap::Image
画像サイズを破壊的に変更します.
-
#rotate(angle) ⇒ Rixmap::Image
画像を回転させます.
-
#rotate!(angle) ⇒ Rixmap::Image
画像を破壊的に回転させます.
-
#scale(*args) ⇒ Object
画像を拡大または縮小します.
-
#scale!(*args) ⇒ Object
画像を破壊的に拡大または縮小します.
Instance Method Details
#resize(width, height, anchor = nil) ⇒ Rixmap::Image
指定サイズに画像サイズを変更します.
ピクセルは拡縮されないことに注意してください. あくまで、画像自体のサイズ変更を目的としています.
38 39 40 41 |
# File 'lib/rixmap/image.rb', line 38 def resize(width, height, anchor=nil) left, top, right, bottom = get_bounds(width, height, anchor) return self.crop(left, top, right, bottom) end |
#resize!(width, height, anchor = nil) ⇒ Rixmnap::Image
画像サイズを破壊的に変更します.
51 52 53 54 |
# File 'lib/rixmap/image.rb', line 51 def resize!(width, height, anchor=nil) left, top, right, bottom = get_bounds(width, height, anchor) return self.crop!(left, top, right, bottom) end |
#rotate(angle) ⇒ Rixmap::Image
画像を回転させます.
126 127 128 129 130 131 |
# File 'lib/rixmap/image.rb', line 126 def rotate(angle) deformer = Rixmap::Deformer::AffineDeformer.new deformer.matrix.angle = angle deformer.interpolator = Rixmap::Deformer::IPO_BICUBIC return self.deform(deformer, true) end |
#rotate!(angle) ⇒ Rixmap::Image
画像を破壊的に回転させます.
137 138 139 140 141 142 |
# File 'lib/rixmap/image.rb', line 137 def rotate!(angle) deformer = Rixmap::Deformer::AffineDeformer.new deformer.matrix.angle = angle deformer.interpolator = Rixmap::Deformer::IPO_BICUBIC return self.deform!(deformer, true) end |
#scale(scale) ⇒ Rixmap::Image #scale(xscale, yscale) ⇒ Rixmap::Image
画像を拡大または縮小します.
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/rixmap/image.rb', line 68 def scale(*args) xscale = 1.0 yscale = 1.0 case args.size when 1 xscale = args[0].to_f yscale = args[0].to_f when 2 xscale = args[0].to_f yscale = args[1].to_f else raise ArgumentError.new("wrong number of arguments (#{args.size} for 1..2)") end deformer = Rixmap::Deformer::AffineDeformer.new deformer.matrix.scale = [xscale, yscale] return self.deform(deformer, true) end |
#scale(scale) ⇒ Rixmap::Image #scale(xscale, yscale) ⇒ Rixmap::Image
画像を破壊的に拡大または縮小します.
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/rixmap/image.rb', line 101 def scale!(*args) xscale = 1.0 yscale = 1.0 case args.size when 1 xscale = args[0].to_f yscale = args[0].to_f when 2 xscale = args[0].to_f yscale = args[1].to_f else raise ArgumentError.new("wrong number of arguments (#{args.size} for 1..2)") end deformer = Rixmap::Deformer::AffineDeformer.new deformer.matrix.scale = [xscale, yscale] return self.deform!(deformer, true) end |