Class: SwfRuby::Swf::Focalgradient

Inherits:
Object
  • Object
show all
Defined in:
lib/swf_ruby/swf/focalgradient.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bytearray, shape_version) ⇒ Focalgradient

Returns a new instance of Focalgradient.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/swf_ruby/swf/focalgradient.rb', line 14

def initialize(bytearray, shape_version)
  @shape_version = shape_version
  bits_str = bytearray[0, 1].unpack("B").first
  @spread_mode = bits_str[0, 2].to_i(2)
  @interpolation_mode = bits_str[2, 2].to_i(2)
  @num_gradients = bits_str[4, 4].to_i(2)
  offset = 1
  @gradient_records = []
  @num_gradients.times do
    gradient_record = SwfRuby::Swf::Gradrecord.new(bytearray[offset..-1], @shape_version)
    @gradient_records << gradient_record
    offset += gradient_record.length
  end
  # TODO focal_point to be 8bit.8bit fixed_point number.
  @focal_point = bytearray[offset, 2]
  offset += 2
  @length = offset
  self
end

Instance Attribute Details

#focal_pointObject

Returns the value of attribute focal_point.



11
12
13
# File 'lib/swf_ruby/swf/focalgradient.rb', line 11

def focal_point
  @focal_point
end

#gradient_recordsObject

Returns the value of attribute gradient_records.



10
11
12
# File 'lib/swf_ruby/swf/focalgradient.rb', line 10

def gradient_records
  @gradient_records
end

#interpolation_modeObject

Returns the value of attribute interpolation_mode.



8
9
10
# File 'lib/swf_ruby/swf/focalgradient.rb', line 8

def interpolation_mode
  @interpolation_mode
end

#lengthObject (readonly)

Returns the value of attribute length.



12
13
14
# File 'lib/swf_ruby/swf/focalgradient.rb', line 12

def length
  @length
end

#num_gradientsObject

Returns the value of attribute num_gradients.



9
10
11
# File 'lib/swf_ruby/swf/focalgradient.rb', line 9

def num_gradients
  @num_gradients
end

#shape_versionObject

Returns the value of attribute shape_version.



6
7
8
# File 'lib/swf_ruby/swf/focalgradient.rb', line 6

def shape_version
  @shape_version
end

#spread_modeObject

Returns the value of attribute spread_mode.



7
8
9
# File 'lib/swf_ruby/swf/focalgradient.rb', line 7

def spread_mode
  @spread_mode
end