class Transform2D

class Transform2D

lib/transform2_d.tya:5

Transform2D provides the transform2d/Transform2D standard library API.

Source
# Transform2D provides the transform2d/Transform2D standard library API.
class Transform2D
  # Transform2D.a stores instance state.
  # @type Int
  a: 0

  # Transform2D.b stores instance state.
  # @type Int
  b: 0

  # Transform2D.c stores instance state.
  # @type Int
  c: 0

  # Transform2D.d stores instance state.
  # @type Int
  d: 0

  # Transform2D.tx stores instance state.
  # @type Int
  tx: 0

  # Transform2D.ty stores instance state.
  # @type Int
  ty: 0

  # Transform2D.initialize provides the transform2d/Transform2D standard library operation.
  # @param a Int a value.
  # @param b Int b value.
  # @param c Any c value.
  # @param d Any d value.
  # @param tx Any tx value.
  # @param ty Any ty value.
  # @return Self the initialized object.
  initialize: a = 1, b = 0, c = 0, d = 1, tx = 0, ty = 0 ->
    self.a = self.number(a, "a")
    self.b = self.number(b, "b")
    self.c = self.number(c, "c")
    self.d = self.number(d, "d")
    self.tx = self.number(tx, "tx")
    self.ty = self.number(ty, "ty")

  # Transform2D.abs provides the transform2d/Transform2D standard library operation.
  # @param value String value value.
  # @return Any the resulting value.
  abs: value ->
    if value < 0
      return 0 - value
    value

  # Transform2D.apply_point provides the transform2d/Transform2D standard library operation.
  # @param transform Any transform value.
  # @param point Any point value.
  # @return Any the resulting value.
  apply_point: transform, point = nil ->
    if point == nil
      point = transform
      transform = self
    self.expect(transform, "transform")
    self.expect_point(point, "point")
    geo.Point(
      transform.a * point.x + transform.c * point.y + transform.tx,
      transform.b * point.x + transform.d * point.y + transform.ty
    )

  # Transform2D.apply_rect provides the transform2d/Transform2D standard library operation.
  # @param transform Any transform value.
  # @param rect Any rect value.
  # @return Any the resulting value.
  apply_rect: transform, rect = nil ->
    if rect == nil
      rect = transform
      transform = self
    self.expect(transform, "transform")
    self.expect_rect(rect, "rect")
    geometry_p1 = self.apply_point(transform, geo.Point(rect.x, rect.y))
    geometry_p2 = self.apply_point(
      transform,
      geo.Point(rect.x + rect.width, rect.y)
    )
    geometry_p3 = self.apply_point(
      transform,
      geo.Point(rect.x, rect.y + rect.height)
    )
    geometry_p4 = self.apply_point(
      transform,
      geo.Point(rect.x + rect.width, rect.y + rect.height)
    )
    geometry_left = self.min(
      self.min(geometry_p1.x, geometry_p2.x),
      self.min(geometry_p3.x, geometry_p4.x)
    )
    geometry_top = self.min(
      self.min(geometry_p1.y, geometry_p2.y),
      self.min(geometry_p3.y, geometry_p4.y)
    )
    geometry_right = self.max(
      self.max(geometry_p1.x, geometry_p2.x),
      self.max(geometry_p3.x, geometry_p4.x)
    )
    geometry_bottom = self.max(
      self.max(geometry_p1.y, geometry_p2.y),
      self.max(geometry_p3.y, geometry_p4.y)
    )
    geo.Rect(
      geometry_left,
      geometry_top,
      geometry_right - geometry_left,
      geometry_bottom - geometry_top
    )

  # Transform2D.apply_size provides the transform2d/Transform2D standard library operation.
  # @param transform Any transform value.
  # @param size Int size value.
  # @return Any the resulting value.
  apply_size: transform, size = nil ->
    if size == nil
      size = transform
      transform = self
    self.expect_size(size, "size")
    geometry_rect = self.apply_rect(
      transform,
      geo.Rect(0, 0, size.width, size.height)
    )
    geo.Size(geometry_rect.width, geometry_rect.height)

  # Transform2D.apply_vector2 provides the transform2d/Transform2D standard library operation.
  # @param transform Any transform value.
  # @param vector Any vector value.
  # @return Any the resulting value.
  apply_vector2: transform, vector = nil ->
    if vector == nil
      vector = transform
      transform = self
    self.expect(transform, "transform")
    self.expect_vector2(vector, "vector")
    geo.Vector2(
      transform.a * vector.x + transform.c * vector.y,
      transform.b * vector.x + transform.d * vector.y
    )

  # Transform2D.compose provides the transform2d/Transform2D standard library operation.
  # @param a Int a value.
  # @param b Int b value.
  # @return Any the resulting value.
  compose: a, b = nil ->
    if b == nil
      b = a
      a = self
    self.expect(a, "a")
    self.expect(b, "b")
    Transform2D(
      a.a * b.a + a.c * b.b,
      a.b * b.a + a.d * b.b,
      a.a * b.c + a.c * b.d,
      a.b * b.c + a.d * b.d,
      a.a * b.tx + a.c * b.ty + a.tx,
      a.b * b.tx + a.d * b.ty + a.ty
    )

  # Transform2D.determinant provides the transform2d/Transform2D standard library operation.
  # @param transform Any transform value.
  # @return Any the resulting value.
  determinant: transform = nil ->
    if transform == nil
      transform = self
    self.expect(transform, "transform")
    transform.a * transform.d - transform.b * transform.c

  # Transform2D.equal? provides the transform2d/Transform2D standard library operation.
  # @param a Int a value.
  # @param b Int b value.
  # @return Boolean whether the condition is true.
  equal?: a, b = nil ->
    if b == nil
      b = a
      a = self
    a.class == Transform2D and b.class == Transform2D and a.a == b.a and a.b == b.b and a.c == b.c and a.d == b.d and a.tx == b.tx and a.ty == b.ty

  # Transform2D.expect provides the transform2d/Transform2D standard library operation.
  # @param value String value value.
  # @param name String name value.
  # @return Any the resulting value.
  expect: value, name ->
    if value.class != Transform2D
      raise error("transform2d: " + name + " must be a Transform2D")

  # Transform2D.expect_point provides the transform2d/Transform2D standard library operation.
  # @param value String value value.
  # @param name String name value.
  # @return Any the resulting value.
  expect_point: value, name ->
    if value.class != geo.Point
      raise error("transform2d: " + name + " must be a geometry.Point")

  # Transform2D.expect_rect provides the transform2d/Transform2D standard library operation.
  # @param value String value value.
  # @param name String name value.
  # @return Any the resulting value.
  expect_rect: value, name ->
    if value.class != geo.Rect
      raise error("transform2d: " + name + " must be a geometry.Rect")

  # Transform2D.expect_size provides the transform2d/Transform2D standard library operation.
  # @param value String value value.
  # @param name String name value.
  # @return Any the resulting value.
  expect_size: value, name ->
    if value.class != geo.Size
      raise error("transform2d: " + name + " must be a geometry.Size")

  # Transform2D.expect_vector2 provides the transform2d/Transform2D standard library operation.
  # @param value String value value.
  # @param name String name value.
  # @return Any the resulting value.
  expect_vector2: value, name ->
    if value.class != geo.Vector2
      raise error("transform2d: " + name + " must be a geometry.Vector2")

  # Transform2D.from_array provides the transform2d/Transform2D standard library operation.
  # @param values Array values value.
  # @return Array the resulting value.
  from_array: values ->
    if values.class != Array or values.len() != 6
      raise error("transform2d.from_array: expected six-number array")
    Transform2D(
      values[0],
      values[1],
      values[2],
      values[3],
      values[4],
      values[5]
    )

  # Transform2D.from_matrix provides the transform2d/Transform2D standard library operation.
  # @param value String value value.
  # @return Self the resulting value.
  from_matrix: value ->
    if value.class != matrix.Matrix
      raise error("transform2d.from_matrix: value must be a matrix.Matrix")
    if value.rows != 3 or value.cols != 3
      raise error("transform2d.from_matrix: matrix must be 3x3")
    if value.data[2][0] != 0 or value.data[2][1] != 0 or value.data[2][2] != 1
      raise error("transform2d.from_matrix: matrix must be affine")
    Transform2D(
      value.data[0][0],
      value.data[1][0],
      value.data[0][1],
      value.data[1][1],
      value.data[0][2],
      value.data[1][2]
    )

  # Transform2D.identity provides the transform2d/Transform2D standard library operation.
  # @return Any the resulting value.
  identity: ->
    Transform2D(1, 0, 0, 1, 0, 0)

  # Transform2D.inverse provides the transform2d/Transform2D standard library operation.
  # @param transform Any transform value.
  # @return Any the resulting value.
  inverse: transform = nil ->
    if transform == nil
      transform = self
    self.expect(transform, "transform")
    geometry_det = self.determinant(transform)
    if self.abs(geometry_det) <= 0.000000001
      raise error("transform2d.inverse: transform is not invertible")
    geometry_a = transform.d.to_f() / geometry_det
    geometry_b = 0 - transform.b.to_f() / geometry_det
    geometry_c = 0 - transform.c.to_f() / geometry_det
    geometry_d = transform.a.to_f() / geometry_det
    geometry_tx = transform.c * transform.ty
      - transform.d * transform.tx.to_f() / geometry_det
    geometry_ty = transform.b * transform.tx
      - transform.a * transform.ty.to_f() / geometry_det
    Transform2D(
      geometry_a,
      geometry_b,
      geometry_c,
      geometry_d,
      geometry_tx,
      geometry_ty
    )

  # Transform2D.invertible? provides the transform2d/Transform2D standard library operation.
  # @param transform Any transform value.
  # @return Boolean whether the condition is true.
  invertible?: transform = nil ->
    if transform == nil
      transform = self
    self.abs(self.determinant(transform)) > 0.000000001

  # Transform2D.max provides the transform2d/Transform2D standard library operation.
  # @param a Int a value.
  # @param b Int b value.
  # @return Any the resulting value.
  max: a, b ->
    if a > b
      return a
    b

  # Transform2D.min provides the transform2d/Transform2D standard library operation.
  # @param a Int a value.
  # @param b Int b value.
  # @return Any the resulting value.
  min: a, b ->
    if a < b
      return a
    b

  # Transform2D.nearly_equal? provides the transform2d/Transform2D standard library operation.
  # @param a Int a value.
  # @param b Int b value.
  # @param epsilon Any epsilon value.
  # @return Boolean whether the condition is true.
  nearly_equal?: a, b, epsilon = nil ->
    if epsilon == nil
      epsilon = b
      b = a
      a = self
    self.expect(a, "a")
    self.expect(b, "b")
    if epsilon < 0
      raise error("transform2d.nearly_equal?: epsilon must be non-negative")
    self.abs(a.a - b.a) <= epsilon and self.abs(a.b - b.b) <= epsilon and self.abs(a.c - b.c) <= epsilon and self.abs(a.d - b.d) <= epsilon and self.abs(a.tx - b.tx) <= epsilon and self.abs(a.ty - b.ty) <= epsilon

  # Transform2D.new provides the transform2d/Transform2D standard library operation.
  # @param a Int a value.
  # @param b Int b value.
  # @param c Any c value.
  # @param d Any d value.
  # @param tx Any tx value.
  # @param ty Any ty value.
  # @return Self the resulting value.
  new: a, b, c, d, tx, ty ->
    Transform2D(a, b, c, d, tx, ty)

  # Transform2D.number provides the transform2d/Transform2D standard library operation.
  # @param value String value value.
  # @param name String name value.
  # @return Any the resulting value.
  number: value, name ->
    if value.class != Number
      raise error("transform2d: " + name + " must be a number")
    value

  # Transform2D.rotate provides the transform2d/Transform2D standard library operation.
  # @param transform Any transform value.
  # @param radians Any radians value.
  # @return Any the resulting value.
  rotate: transform, radians = nil ->
    if radians == nil
      radians = transform
      transform = self
    self.compose(self.rotation(radians), transform)

  # Transform2D.rotation provides the transform2d/Transform2D standard library operation.
  # @param radians Any radians value.
  # @return Any the resulting value.
  rotation: radians ->
    self.number(radians, "radians")
    geometry_cos = math_cos(radians)
    geometry_sin = math_sin(radians)
    Transform2D(
      geometry_cos,
      geometry_sin,
      0 - geometry_sin,
      geometry_cos,
      0,
      0
    )

  # Transform2D.rotation_around provides the transform2d/Transform2D standard library operation.
  # @param radians Any radians value.
  # @param point Any point value.
  # @return Any the resulting value.
  rotation_around: radians, point ->
    self.expect_point(point, "point")
    geometry_to_origin = self.translation(0 - point.x, 0 - point.y)
    geometry_back = self.translation(point.x, point.y)
    self.compose(
      geometry_back,
      self.compose(self.rotation(radians), geometry_to_origin)
    )

  # Transform2D.scale provides the transform2d/Transform2D standard library operation.
  # @param sx Any sx value.
  # @param sy Any sy value.
  # @return Any the resulting value.
  scale: sx, sy ->
    self.number(sx, "sx")
    self.number(sy, "sy")
    Transform2D(sx, 0, 0, sy, 0, 0)

  # Transform2D.scale_by provides the transform2d/Transform2D standard library operation.
  # @param transform Any transform value.
  # @param sx Any sx value.
  # @param sy Any sy value.
  # @return Any the resulting value.
  scale_by: transform, sx, sy = nil ->
    if sy == nil
      sy = sx
      sx = transform
      transform = self
    self.compose(self.scale(sx, sy), transform)

  # Transform2D.skew provides the transform2d/Transform2D standard library operation.
  # @param x_radians Any x radians value.
  # @param y_radians Any y radians value.
  # @return Any the resulting value.
  skew: x_radians, y_radians ->
    self.number(x_radians, "x_radians")
    self.number(y_radians, "y_radians")
    Transform2D(1, math_tan(y_radians), math_tan(x_radians), 1, 0, 0)

  # Transform2D.to_array provides the transform2d/Transform2D standard library operation.
  # @param transform Any transform value.
  # @return Array the resulting value.
  to_array: transform = nil ->
    if transform == nil
      transform = self
    self.expect(transform, "transform")
    [transform.a, transform.b, transform.c, transform.d, transform.tx, transform.ty]

  # Transform2D.to_matrix provides the transform2d/Transform2D standard library operation.
  # @param transform Any transform value.
  # @return Any the resulting value.
  to_matrix: transform = nil ->
    if transform == nil
      transform = self
    self.expect(transform, "transform")
    matrix.Matrix(
      [[transform.a, transform.c, transform.tx], [transform.b, transform.d, transform.ty], [0, 0, 1]]
    )

  # Transform2D.translate provides the transform2d/Transform2D standard library operation.
  # @param transform Any transform value.
  # @param x Int x value.
  # @param y Int y value.
  # @return Any the resulting value.
  translate: transform, x, y = nil ->
    if y == nil
      y = x
      x = transform
      transform = self
    self.compose(self.translation(x, y), transform)

  # Transform2D.translation provides the transform2d/Transform2D standard library operation.
  # @param x Int x value.
  # @param y Int y value.
  # @return Any the resulting value.
  translation: x, y ->
    self.number(x, "x")
    self.number(y, "y")
    Transform2D(1, 0, 0, 1, x, y)

  # Transform2D.uniform_scale provides the transform2d/Transform2D standard library operation.
  # @param s Any s value.
  # @return Any the resulting value.
  uniform_scale: s ->
    self.number(s, "s")
    self.scale(s, s)

Instance Variables

a

Transform2D.a

lib/transform2_d.tya:8

Transform2D.a stores instance state.

Source
  # Transform2D.a stores instance state.
  # @type Int
  a: 0

b

Transform2D.b

lib/transform2_d.tya:12

Transform2D.b stores instance state.

Source
  # Transform2D.b stores instance state.
  # @type Int
  b: 0

c

Transform2D.c

lib/transform2_d.tya:16

Transform2D.c stores instance state.

Source
  # Transform2D.c stores instance state.
  # @type Int
  c: 0

d

Transform2D.d

lib/transform2_d.tya:20

Transform2D.d stores instance state.

Source
  # Transform2D.d stores instance state.
  # @type Int
  d: 0

tx

Transform2D.tx

lib/transform2_d.tya:24

Transform2D.tx stores instance state.

Source
  # Transform2D.tx stores instance state.
  # @type Int
  tx: 0

ty

Transform2D.ty

lib/transform2_d.tya:28

Transform2D.ty stores instance state.

Source
  # Transform2D.ty stores instance state.
  # @type Int
  ty: 0

Methods

abs

Transform2D.abs(value)

lib/transform2_d.tya:49

Transform2D.abs provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.abs provides the transform2d/Transform2D standard library operation.
  # @param value String value value.
  # @return Any the resulting value.
  abs: value ->
    if value < 0
      return 0 - value
    value

apply_point

Transform2D.apply_point(transform, point = nil)

lib/transform2_d.tya:58

Transform2D.apply_point provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.apply_point provides the transform2d/Transform2D standard library operation.
  # @param transform Any transform value.
  # @param point Any point value.
  # @return Any the resulting value.
  apply_point: transform, point = nil ->
    if point == nil
      point = transform
      transform = self
    self.expect(transform, "transform")
    self.expect_point(point, "point")
    geo.Point(
      transform.a * point.x + transform.c * point.y + transform.tx,
      transform.b * point.x + transform.d * point.y + transform.ty
    )

apply_rect

Transform2D.apply_rect(transform, rect = nil)

lib/transform2_d.tya:73

Transform2D.apply_rect provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.apply_rect provides the transform2d/Transform2D standard library operation.
  # @param transform Any transform value.
  # @param rect Any rect value.
  # @return Any the resulting value.
  apply_rect: transform, rect = nil ->
    if rect == nil
      rect = transform
      transform = self
    self.expect(transform, "transform")
    self.expect_rect(rect, "rect")
    geometry_p1 = self.apply_point(transform, geo.Point(rect.x, rect.y))
    geometry_p2 = self.apply_point(
      transform,
      geo.Point(rect.x + rect.width, rect.y)
    )
    geometry_p3 = self.apply_point(
      transform,
      geo.Point(rect.x, rect.y + rect.height)
    )
    geometry_p4 = self.apply_point(
      transform,
      geo.Point(rect.x + rect.width, rect.y + rect.height)
    )
    geometry_left = self.min(
      self.min(geometry_p1.x, geometry_p2.x),
      self.min(geometry_p3.x, geometry_p4.x)
    )
    geometry_top = self.min(
      self.min(geometry_p1.y, geometry_p2.y),
      self.min(geometry_p3.y, geometry_p4.y)
    )
    geometry_right = self.max(
      self.max(geometry_p1.x, geometry_p2.x),
      self.max(geometry_p3.x, geometry_p4.x)
    )
    geometry_bottom = self.max(
      self.max(geometry_p1.y, geometry_p2.y),
      self.max(geometry_p3.y, geometry_p4.y)
    )
    geo.Rect(
      geometry_left,
      geometry_top,
      geometry_right - geometry_left,
      geometry_bottom - geometry_top
    )

apply_size

Transform2D.apply_size(transform, size = nil)

lib/transform2_d.tya:119

Transform2D.apply_size provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.apply_size provides the transform2d/Transform2D standard library operation.
  # @param transform Any transform value.
  # @param size Int size value.
  # @return Any the resulting value.
  apply_size: transform, size = nil ->
    if size == nil
      size = transform
      transform = self
    self.expect_size(size, "size")
    geometry_rect = self.apply_rect(
      transform,
      geo.Rect(0, 0, size.width, size.height)
    )
    geo.Size(geometry_rect.width, geometry_rect.height)

apply_vector2

Transform2D.apply_vector2(transform, vector = nil)

lib/transform2_d.tya:134

Transform2D.apply_vector2 provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.apply_vector2 provides the transform2d/Transform2D standard library operation.
  # @param transform Any transform value.
  # @param vector Any vector value.
  # @return Any the resulting value.
  apply_vector2: transform, vector = nil ->
    if vector == nil
      vector = transform
      transform = self
    self.expect(transform, "transform")
    self.expect_vector2(vector, "vector")
    geo.Vector2(
      transform.a * vector.x + transform.c * vector.y,
      transform.b * vector.x + transform.d * vector.y
    )

compose

Transform2D.compose(a, b = nil)

lib/transform2_d.tya:149

Transform2D.compose provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.compose provides the transform2d/Transform2D standard library operation.
  # @param a Int a value.
  # @param b Int b value.
  # @return Any the resulting value.
  compose: a, b = nil ->
    if b == nil
      b = a
      a = self
    self.expect(a, "a")
    self.expect(b, "b")
    Transform2D(
      a.a * b.a + a.c * b.b,
      a.b * b.a + a.d * b.b,
      a.a * b.c + a.c * b.d,
      a.b * b.c + a.d * b.d,
      a.a * b.tx + a.c * b.ty + a.tx,
      a.b * b.tx + a.d * b.ty + a.ty
    )

determinant

Transform2D.determinant(transform = nil)

lib/transform2_d.tya:167

Transform2D.determinant provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.determinant provides the transform2d/Transform2D standard library operation.
  # @param transform Any transform value.
  # @return Any the resulting value.
  determinant: transform = nil ->
    if transform == nil
      transform = self
    self.expect(transform, "transform")
    transform.a * transform.d - transform.b * transform.c

equal?

Transform2D.equal?(a, b = nil)

lib/transform2_d.tya:177

Transform2D.equal? provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.equal? provides the transform2d/Transform2D standard library operation.
  # @param a Int a value.
  # @param b Int b value.
  # @return Boolean whether the condition is true.
  equal?: a, b = nil ->
    if b == nil
      b = a
      a = self
    a.class == Transform2D and b.class == Transform2D and a.a == b.a and a.b == b.b and a.c == b.c and a.d == b.d and a.tx == b.tx and a.ty == b.ty

expect

Transform2D.expect(value, name)

lib/transform2_d.tya:187

Transform2D.expect provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.expect provides the transform2d/Transform2D standard library operation.
  # @param value String value value.
  # @param name String name value.
  # @return Any the resulting value.
  expect: value, name ->
    if value.class != Transform2D
      raise error("transform2d: " + name + " must be a Transform2D")

expect_point

Transform2D.expect_point(value, name)

lib/transform2_d.tya:195

Transform2D.expect_point provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.expect_point provides the transform2d/Transform2D standard library operation.
  # @param value String value value.
  # @param name String name value.
  # @return Any the resulting value.
  expect_point: value, name ->
    if value.class != geo.Point
      raise error("transform2d: " + name + " must be a geometry.Point")

expect_rect

Transform2D.expect_rect(value, name)

lib/transform2_d.tya:203

Transform2D.expect_rect provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.expect_rect provides the transform2d/Transform2D standard library operation.
  # @param value String value value.
  # @param name String name value.
  # @return Any the resulting value.
  expect_rect: value, name ->
    if value.class != geo.Rect
      raise error("transform2d: " + name + " must be a geometry.Rect")

expect_size

Transform2D.expect_size(value, name)

lib/transform2_d.tya:211

Transform2D.expect_size provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.expect_size provides the transform2d/Transform2D standard library operation.
  # @param value String value value.
  # @param name String name value.
  # @return Any the resulting value.
  expect_size: value, name ->
    if value.class != geo.Size
      raise error("transform2d: " + name + " must be a geometry.Size")

expect_vector2

Transform2D.expect_vector2(value, name)

lib/transform2_d.tya:219

Transform2D.expect_vector2 provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.expect_vector2 provides the transform2d/Transform2D standard library operation.
  # @param value String value value.
  # @param name String name value.
  # @return Any the resulting value.
  expect_vector2: value, name ->
    if value.class != geo.Vector2
      raise error("transform2d: " + name + " must be a geometry.Vector2")

from_array

Transform2D.from_array(values)

lib/transform2_d.tya:226

Transform2D.from_array provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.from_array provides the transform2d/Transform2D standard library operation.
  # @param values Array values value.
  # @return Array the resulting value.
  from_array: values ->
    if values.class != Array or values.len() != 6
      raise error("transform2d.from_array: expected six-number array")
    Transform2D(
      values[0],
      values[1],
      values[2],
      values[3],
      values[4],
      values[5]
    )

from_matrix

Transform2D.from_matrix(value)

lib/transform2_d.tya:241

Transform2D.from_matrix provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.from_matrix provides the transform2d/Transform2D standard library operation.
  # @param value String value value.
  # @return Self the resulting value.
  from_matrix: value ->
    if value.class != matrix.Matrix
      raise error("transform2d.from_matrix: value must be a matrix.Matrix")
    if value.rows != 3 or value.cols != 3
      raise error("transform2d.from_matrix: matrix must be 3x3")
    if value.data[2][0] != 0 or value.data[2][1] != 0 or value.data[2][2] != 1
      raise error("transform2d.from_matrix: matrix must be affine")
    Transform2D(
      value.data[0][0],
      value.data[1][0],
      value.data[0][1],
      value.data[1][1],
      value.data[0][2],
      value.data[1][2]
    )

identity

Transform2D.identity()

lib/transform2_d.tya:259

Transform2D.identity provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.identity provides the transform2d/Transform2D standard library operation.
  # @return Any the resulting value.
  identity: ->
    Transform2D(1, 0, 0, 1, 0, 0)

initialize

Transform2D.initialize(a = 1, b = 0, c = 0, d = 1, tx = 0, ty = 0)

lib/transform2_d.tya:38

Transform2D.initialize provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.initialize provides the transform2d/Transform2D standard library operation.
  # @param a Int a value.
  # @param b Int b value.
  # @param c Any c value.
  # @param d Any d value.
  # @param tx Any tx value.
  # @param ty Any ty value.
  # @return Self the initialized object.
  initialize: a = 1, b = 0, c = 0, d = 1, tx = 0, ty = 0 ->
    self.a = self.number(a, "a")
    self.b = self.number(b, "b")
    self.c = self.number(c, "c")
    self.d = self.number(d, "d")
    self.tx = self.number(tx, "tx")
    self.ty = self.number(ty, "ty")

inverse

Transform2D.inverse(transform = nil)

lib/transform2_d.tya:265

Transform2D.inverse provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.inverse provides the transform2d/Transform2D standard library operation.
  # @param transform Any transform value.
  # @return Any the resulting value.
  inverse: transform = nil ->
    if transform == nil
      transform = self
    self.expect(transform, "transform")
    geometry_det = self.determinant(transform)
    if self.abs(geometry_det) <= 0.000000001
      raise error("transform2d.inverse: transform is not invertible")
    geometry_a = transform.d.to_f() / geometry_det
    geometry_b = 0 - transform.b.to_f() / geometry_det
    geometry_c = 0 - transform.c.to_f() / geometry_det
    geometry_d = transform.a.to_f() / geometry_det
    geometry_tx = transform.c * transform.ty
      - transform.d * transform.tx.to_f() / geometry_det
    geometry_ty = transform.b * transform.tx
      - transform.a * transform.ty.to_f() / geometry_det
    Transform2D(
      geometry_a,
      geometry_b,
      geometry_c,
      geometry_d,
      geometry_tx,
      geometry_ty
    )

invertible?

Transform2D.invertible?(transform = nil)

lib/transform2_d.tya:292

Transform2D.invertible? provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.invertible? provides the transform2d/Transform2D standard library operation.
  # @param transform Any transform value.
  # @return Boolean whether the condition is true.
  invertible?: transform = nil ->
    if transform == nil
      transform = self
    self.abs(self.determinant(transform)) > 0.000000001

max

Transform2D.max(a, b)

lib/transform2_d.tya:301

Transform2D.max provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.max provides the transform2d/Transform2D standard library operation.
  # @param a Int a value.
  # @param b Int b value.
  # @return Any the resulting value.
  max: a, b ->
    if a > b
      return a
    b

min

Transform2D.min(a, b)

lib/transform2_d.tya:310

Transform2D.min provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.min provides the transform2d/Transform2D standard library operation.
  # @param a Int a value.
  # @param b Int b value.
  # @return Any the resulting value.
  min: a, b ->
    if a < b
      return a
    b

nearly_equal?

Transform2D.nearly_equal?(a, b, epsilon = nil)

lib/transform2_d.tya:320

Transform2D.nearly_equal? provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.nearly_equal? provides the transform2d/Transform2D standard library operation.
  # @param a Int a value.
  # @param b Int b value.
  # @param epsilon Any epsilon value.
  # @return Boolean whether the condition is true.
  nearly_equal?: a, b, epsilon = nil ->
    if epsilon == nil
      epsilon = b
      b = a
      a = self
    self.expect(a, "a")
    self.expect(b, "b")
    if epsilon < 0
      raise error("transform2d.nearly_equal?: epsilon must be non-negative")
    self.abs(a.a - b.a) <= epsilon and self.abs(a.b - b.b) <= epsilon and self.abs(a.c - b.c) <= epsilon and self.abs(a.d - b.d) <= epsilon and self.abs(a.tx - b.tx) <= epsilon and self.abs(a.ty - b.ty) <= epsilon

new

Transform2D.new(a, b, c, d, tx, ty)

lib/transform2_d.tya:339

Transform2D.new provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.new provides the transform2d/Transform2D standard library operation.
  # @param a Int a value.
  # @param b Int b value.
  # @param c Any c value.
  # @param d Any d value.
  # @param tx Any tx value.
  # @param ty Any ty value.
  # @return Self the resulting value.
  new: a, b, c, d, tx, ty ->
    Transform2D(a, b, c, d, tx, ty)

number

Transform2D.number(value, name)

lib/transform2_d.tya:346

Transform2D.number provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.number provides the transform2d/Transform2D standard library operation.
  # @param value String value value.
  # @param name String name value.
  # @return Any the resulting value.
  number: value, name ->
    if value.class != Number
      raise error("transform2d: " + name + " must be a number")
    value

rotate

Transform2D.rotate(transform, radians = nil)

lib/transform2_d.tya:355

Transform2D.rotate provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.rotate provides the transform2d/Transform2D standard library operation.
  # @param transform Any transform value.
  # @param radians Any radians value.
  # @return Any the resulting value.
  rotate: transform, radians = nil ->
    if radians == nil
      radians = transform
      transform = self
    self.compose(self.rotation(radians), transform)

rotation

Transform2D.rotation(radians)

lib/transform2_d.tya:364

Transform2D.rotation provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.rotation provides the transform2d/Transform2D standard library operation.
  # @param radians Any radians value.
  # @return Any the resulting value.
  rotation: radians ->
    self.number(radians, "radians")
    geometry_cos = math_cos(radians)
    geometry_sin = math_sin(radians)
    Transform2D(
      geometry_cos,
      geometry_sin,
      0 - geometry_sin,
      geometry_cos,
      0,
      0
    )

rotation_around

Transform2D.rotation_around(radians, point)

lib/transform2_d.tya:381

Transform2D.rotation_around provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.rotation_around provides the transform2d/Transform2D standard library operation.
  # @param radians Any radians value.
  # @param point Any point value.
  # @return Any the resulting value.
  rotation_around: radians, point ->
    self.expect_point(point, "point")
    geometry_to_origin = self.translation(0 - point.x, 0 - point.y)
    geometry_back = self.translation(point.x, point.y)
    self.compose(
      geometry_back,
      self.compose(self.rotation(radians), geometry_to_origin)
    )

scale

Transform2D.scale(sx, sy)

lib/transform2_d.tya:394

Transform2D.scale provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.scale provides the transform2d/Transform2D standard library operation.
  # @param sx Any sx value.
  # @param sy Any sy value.
  # @return Any the resulting value.
  scale: sx, sy ->
    self.number(sx, "sx")
    self.number(sy, "sy")
    Transform2D(sx, 0, 0, sy, 0, 0)

scale_by

Transform2D.scale_by(transform, sx, sy = nil)

lib/transform2_d.tya:404

Transform2D.scale_by provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.scale_by provides the transform2d/Transform2D standard library operation.
  # @param transform Any transform value.
  # @param sx Any sx value.
  # @param sy Any sy value.
  # @return Any the resulting value.
  scale_by: transform, sx, sy = nil ->
    if sy == nil
      sy = sx
      sx = transform
      transform = self
    self.compose(self.scale(sx, sy), transform)

skew

Transform2D.skew(x_radians, y_radians)

lib/transform2_d.tya:415

Transform2D.skew provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.skew provides the transform2d/Transform2D standard library operation.
  # @param x_radians Any x radians value.
  # @param y_radians Any y radians value.
  # @return Any the resulting value.
  skew: x_radians, y_radians ->
    self.number(x_radians, "x_radians")
    self.number(y_radians, "y_radians")
    Transform2D(1, math_tan(y_radians), math_tan(x_radians), 1, 0, 0)

to_array

Transform2D.to_array(transform = nil)

lib/transform2_d.tya:423

Transform2D.to_array provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.to_array provides the transform2d/Transform2D standard library operation.
  # @param transform Any transform value.
  # @return Array the resulting value.
  to_array: transform = nil ->
    if transform == nil
      transform = self
    self.expect(transform, "transform")
    [transform.a, transform.b, transform.c, transform.d, transform.tx, transform.ty]

to_matrix

Transform2D.to_matrix(transform = nil)

lib/transform2_d.tya:432

Transform2D.to_matrix provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.to_matrix provides the transform2d/Transform2D standard library operation.
  # @param transform Any transform value.
  # @return Any the resulting value.
  to_matrix: transform = nil ->
    if transform == nil
      transform = self
    self.expect(transform, "transform")
    matrix.Matrix(
      [[transform.a, transform.c, transform.tx], [transform.b, transform.d, transform.ty], [0, 0, 1]]
    )

translate

Transform2D.translate(transform, x, y = nil)

lib/transform2_d.tya:445

Transform2D.translate provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.translate provides the transform2d/Transform2D standard library operation.
  # @param transform Any transform value.
  # @param x Int x value.
  # @param y Int y value.
  # @return Any the resulting value.
  translate: transform, x, y = nil ->
    if y == nil
      y = x
      x = transform
      transform = self
    self.compose(self.translation(x, y), transform)

translation

Transform2D.translation(x, y)

lib/transform2_d.tya:456

Transform2D.translation provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.translation provides the transform2d/Transform2D standard library operation.
  # @param x Int x value.
  # @param y Int y value.
  # @return Any the resulting value.
  translation: x, y ->
    self.number(x, "x")
    self.number(y, "y")
    Transform2D(1, 0, 0, 1, x, y)

uniform_scale

Transform2D.uniform_scale(s)

lib/transform2_d.tya:464

Transform2D.uniform_scale provides the transform2d/Transform2D standard library operation.

Source
  # Transform2D.uniform_scale provides the transform2d/Transform2D standard library operation.
  # @param s Any s value.
  # @return Any the resulting value.
  uniform_scale: s ->
    self.number(s, "s")
    self.scale(s, s)