Class: Fontisan::Ufo::Transformation

Inherits:
Object
  • Object
show all
Defined in:
lib/fontisan/ufo/transformation.rb

Overview

2×3 transformation matrix, as used in UFO 3 for component and image placement. The matrix is laid out in the standard affine row-major order: [a b c d e f] represents

| a c e |
| b d f |
| 0 0 1 |

(UFO and OpenType both use the row-major convention despite the geometrically column-major appearance — this is how the transformation element reads in .glif XML.)

Constant Summary collapse

IDENTITY_MATRIX =
[1.0, 0.0, 0.0, 1.0, 0.0, 0.0].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(a: 1.0, b: 0.0, c: 0.0, d: 1.0, e: 0.0, f: 0.0) ⇒ Transformation

Returns a new instance of Transformation.



21
22
23
24
25
26
27
28
# File 'lib/fontisan/ufo/transformation.rb', line 21

def initialize(a: 1.0, b: 0.0, c: 0.0, d: 1.0, e: 0.0, f: 0.0)
  @a = a.to_f
  @b = b.to_f
  @c = c.to_f
  @d = d.to_f
  @e = e.to_f
  @f = f.to_f
end

Instance Attribute Details

#aObject (readonly)

Returns the value of attribute a.



19
20
21
# File 'lib/fontisan/ufo/transformation.rb', line 19

def a
  @a
end

#bObject (readonly)

Returns the value of attribute b.



19
20
21
# File 'lib/fontisan/ufo/transformation.rb', line 19

def b
  @b
end

#cObject (readonly)

Returns the value of attribute c.



19
20
21
# File 'lib/fontisan/ufo/transformation.rb', line 19

def c
  @c
end

#dObject (readonly)

Returns the value of attribute d.



19
20
21
# File 'lib/fontisan/ufo/transformation.rb', line 19

def d
  @d
end

#eObject (readonly)

Returns the value of attribute e.



19
20
21
# File 'lib/fontisan/ufo/transformation.rb', line 19

def e
  @e
end

#fObject (readonly)

Returns the value of attribute f.



19
20
21
# File 'lib/fontisan/ufo/transformation.rb', line 19

def f
  @f
end

Instance Method Details

#identity?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/fontisan/ufo/transformation.rb', line 30

def identity?
  [a, b, c, d, e, f] == IDENTITY_MATRIX
end

#to_aObject



34
35
36
# File 'lib/fontisan/ufo/transformation.rb', line 34

def to_a
  [a, b, c, d, e, f]
end