Class: SwfRuby::Swf::Matrix
- Inherits:
-
Object
- Object
- SwfRuby::Swf::Matrix
- Defined in:
- lib/swf_ruby/swf/matrix.rb
Instance Attribute Summary collapse
-
#has_rotate ⇒ Object
Returns the value of attribute has_rotate.
-
#has_scale ⇒ Object
Returns the value of attribute has_scale.
-
#length ⇒ Object
readonly
byte_aligned.
-
#n_rotate_bits ⇒ Object
Returns the value of attribute n_rotate_bits.
-
#n_scale_bits ⇒ Object
Returns the value of attribute n_scale_bits.
-
#n_translate_bits ⇒ Object
Returns the value of attribute n_translate_bits.
-
#rotate_skew_0 ⇒ Object
Returns the value of attribute rotate_skew_0.
-
#rotate_skew_1 ⇒ Object
Returns the value of attribute rotate_skew_1.
-
#scale_x ⇒ Object
Returns the value of attribute scale_x.
-
#scale_y ⇒ Object
Returns the value of attribute scale_y.
-
#translate_x ⇒ Object
Returns the value of attribute translate_x.
-
#translate_y ⇒ Object
Returns the value of attribute translate_y.
Instance Method Summary collapse
-
#initialize(bytearray) ⇒ Matrix
constructor
A new instance of Matrix.
Constructor Details
#initialize(bytearray) ⇒ Matrix
Returns a new instance of Matrix.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/swf_ruby/swf/matrix.rb', line 19 def initialize(bytearray) bits_str = bytearray.unpack("B*").first @has_scale = bits_str[0, 1].to_i(2) offset = 1 if @has_scale == 1 @n_scale_bits = bits_str[offset, 5].to_i(2) offset += 5 @scale_x = bits_str[offset, self.n_scale_bits].to_i(2) @scale_y = bits_str[offset+self.n_scale_bits, self.n_scale_bits].to_i(2) offset += 2 * self.n_scale_bits end @has_rotate = bits_str[offset, 1].to_i(2) offset += 1 if @has_rotate == 1 @n_rotate_bits = bits_str[offset, 5].to_i(2) offset += 5 @rotate_skew_0 = bits_str[offset, self.n_rotate_bits].to_i(2) @rotate_skew_1 = bits_str[offset+self.n_rotate_bits, self.n_rotate_bits].to_i(2) offset += 2 * self.n_rotate_bits end @n_translate_bits = bits_str[offset, 5].to_i(2) offset += 5 @translate_x = bits_str[offset, self.n_translate_bits].to_i(2) @translate_y = bits_str[offset+self.n_translate_bits, self.n_translate_bits].to_i(2) offset += 2 * self.n_translate_bits @length = offset >> 3 @length += 1 if offset & 7 > 0 self end |
Instance Attribute Details
#has_rotate ⇒ Object
Returns the value of attribute has_rotate.
10 11 12 |
# File 'lib/swf_ruby/swf/matrix.rb', line 10 def has_rotate @has_rotate end |
#has_scale ⇒ Object
Returns the value of attribute has_scale.
6 7 8 |
# File 'lib/swf_ruby/swf/matrix.rb', line 6 def has_scale @has_scale end |
#length ⇒ Object (readonly)
byte_aligned
17 18 19 |
# File 'lib/swf_ruby/swf/matrix.rb', line 17 def length @length end |
#n_rotate_bits ⇒ Object
Returns the value of attribute n_rotate_bits.
11 12 13 |
# File 'lib/swf_ruby/swf/matrix.rb', line 11 def n_rotate_bits @n_rotate_bits end |
#n_scale_bits ⇒ Object
Returns the value of attribute n_scale_bits.
7 8 9 |
# File 'lib/swf_ruby/swf/matrix.rb', line 7 def n_scale_bits @n_scale_bits end |
#n_translate_bits ⇒ Object
Returns the value of attribute n_translate_bits.
14 15 16 |
# File 'lib/swf_ruby/swf/matrix.rb', line 14 def n_translate_bits @n_translate_bits end |
#rotate_skew_0 ⇒ Object
Returns the value of attribute rotate_skew_0.
12 13 14 |
# File 'lib/swf_ruby/swf/matrix.rb', line 12 def rotate_skew_0 @rotate_skew_0 end |
#rotate_skew_1 ⇒ Object
Returns the value of attribute rotate_skew_1.
13 14 15 |
# File 'lib/swf_ruby/swf/matrix.rb', line 13 def rotate_skew_1 @rotate_skew_1 end |
#scale_x ⇒ Object
Returns the value of attribute scale_x.
8 9 10 |
# File 'lib/swf_ruby/swf/matrix.rb', line 8 def scale_x @scale_x end |
#scale_y ⇒ Object
Returns the value of attribute scale_y.
9 10 11 |
# File 'lib/swf_ruby/swf/matrix.rb', line 9 def scale_y @scale_y end |
#translate_x ⇒ Object
Returns the value of attribute translate_x.
15 16 17 |
# File 'lib/swf_ruby/swf/matrix.rb', line 15 def translate_x @translate_x end |
#translate_y ⇒ Object
Returns the value of attribute translate_y.
16 17 18 |
# File 'lib/swf_ruby/swf/matrix.rb', line 16 def translate_y @translate_y end |