class DYI::Matrix
@since 1.0.0
Attributes
x0[RW]
xx[RW]
xy[RW]
y0[RW]
yx[RW]
yy[RW]
Public Class Methods
identity()
click to toggle source
# File lib/dyi/matrix.rb, line 97 def identity new(1, 0, 0, 1, 0, 0) end
new (xx, yx, xy, yy, x0, y0)
click to toggle source
# File lib/dyi/matrix.rb, line 31 def initialize(*args) case args.first when :translate @xx = @yy = 1 @xy = @yx = 0 @x0 = args[1] @y0 = args[2] || 0 when :scale @xx = args[1] @yy = args[2] || args[1] @xy = @yx = @x0 = @y0 = 0 when :rotate @xx = @yy = DYI::Util.cos(args[1]) @xy = -(@yx = DYI::Util.sin(args[1])) @x0 = @y0 = 0 when :skewX @xx = @yy = 1 @xy = DYI::Util.tan(args[1]) @yx = @x0 = @y0 = 0 when :skewY @xx = @yy = 1 @yx = DYI::Util.tan(args[1]) @xy = @x0 = @y0 = 0 else raise ArgumentError unless args.size == 6 @xx, @yx, @xy, @yy, @x0, @y0 = args end end
rotate(angle)
click to toggle source
# File lib/dyi/matrix.rb, line 109 def rotate(angle) new(:rotate, angle) end
scale(sx, sy)
click to toggle source
# File lib/dyi/matrix.rb, line 105 def scale(sx, sy) new(:scale, sx, sy) end
skew_x(angle)
click to toggle source
# File lib/dyi/matrix.rb, line 113 def skew_x(angle) new(:skewX, angle) end
skew_y(angle)
click to toggle source
# File lib/dyi/matrix.rb, line 117 def skew_y(angle) new(:skewY, angle) end
translate(tx, ty)
click to toggle source
# File lib/dyi/matrix.rb, line 101 def translate(tx, ty) new(:translate, tx, ty) end
Public Instance Methods
*(other)
click to toggle source
# File lib/dyi/matrix.rb, line 60 def *(other) self.class.new( xx * other.xx + xy * other.yx, yx * other.xx + yy * other.yx, xx * other.xy + xy * other.yy, yx * other.xy + yy * other.yy, xx * other.x0 + xy * other.y0 + x0, yx * other.x0 + yy * other.y0 + y0) end
==(other)
click to toggle source
# File lib/dyi/matrix.rb, line 67 def ==(other) xx == other.xx && yx == other.yx && xy == other.xy && yy == other.yy && x0 == other.x0 && y0 == other.y0 end
rotate(angle)
click to toggle source
# File lib/dyi/matrix.rb, line 79 def rotate(angle) self * Matrix.rotate(angle) end
scale(sx, xy)
click to toggle source
# File lib/dyi/matrix.rb, line 75 def scale(sx, xy) self * Matrix.scale(sx, xy) end
skew_x(angle)
click to toggle source
# File lib/dyi/matrix.rb, line 83 def skew_x(angle) self * Matrix.skew_x(angle) end
skew_y(angle)
click to toggle source
# File lib/dyi/matrix.rb, line 87 def skew_y(angle) self * Matrix.skew_y(angle) end
to_cls_matrix()
click to toggle source
# File lib/ironruby.rb, line 130 def to_cls_matrix System::Drawing::Drawing2D::Matrix.new(xx, yx, xy, yy, x0, y0) end
transform(coordinate)
click to toggle source
# File lib/dyi/matrix.rb, line 91 def transform(coordinate) Coordinate.new(coordinate.x * @xx + coordinate.y * @xy + @x0, coordinate.x * @yx + coordinate.y * @yy + @y0) end
translate(tx, ty)
click to toggle source
# File lib/dyi/matrix.rb, line 71 def translate(tx, ty) self * Matrix.translate(tx, ty) end