Class: Fontisan::Ufo::Transformation
- Inherits:
-
Object
- Object
- Fontisan::Ufo::Transformation
- 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
-
#a ⇒ Object
readonly
Returns the value of attribute a.
-
#b ⇒ Object
readonly
Returns the value of attribute b.
-
#c ⇒ Object
readonly
Returns the value of attribute c.
-
#d ⇒ Object
readonly
Returns the value of attribute d.
-
#e ⇒ Object
readonly
Returns the value of attribute e.
-
#f ⇒ Object
readonly
Returns the value of attribute f.
Instance Method Summary collapse
- #identity? ⇒ Boolean
-
#initialize(a: 1.0, b: 0.0, c: 0.0, d: 1.0, e: 0.0, f: 0.0) ⇒ Transformation
constructor
A new instance of Transformation.
- #to_a ⇒ Object
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
#a ⇒ Object (readonly)
Returns the value of attribute a.
19 20 21 |
# File 'lib/fontisan/ufo/transformation.rb', line 19 def a @a end |
#b ⇒ Object (readonly)
Returns the value of attribute b.
19 20 21 |
# File 'lib/fontisan/ufo/transformation.rb', line 19 def b @b end |
#c ⇒ Object (readonly)
Returns the value of attribute c.
19 20 21 |
# File 'lib/fontisan/ufo/transformation.rb', line 19 def c @c end |
#d ⇒ Object (readonly)
Returns the value of attribute d.
19 20 21 |
# File 'lib/fontisan/ufo/transformation.rb', line 19 def d @d end |
#e ⇒ Object (readonly)
Returns the value of attribute e.
19 20 21 |
# File 'lib/fontisan/ufo/transformation.rb', line 19 def e @e end |
#f ⇒ Object (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
30 31 32 |
# File 'lib/fontisan/ufo/transformation.rb', line 30 def identity? [a, b, c, d, e, f] == IDENTITY_MATRIX end |
#to_a ⇒ Object
34 35 36 |
# File 'lib/fontisan/ufo/transformation.rb', line 34 def to_a [a, b, c, d, e, f] end |