Class: PSD::GradientMap

Inherits:
LayerInfo show all
Defined in:
lib/psd/layer/info/gradient_map.rb

Instance Attribute Summary collapse

Attributes inherited from LayerInfo

#data

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from LayerInfo

#initialize, #skip

Constructor Details

This class inherits a constructor from PSD::LayerInfo

Instance Attribute Details

#color_modelObject (readonly)

Returns the value of attribute color_model.



9
10
11
# File 'lib/psd/layer/info/gradient_map.rb', line 9

def color_model
  @color_model
end

#color_stopsObject (readonly)

Returns the value of attribute color_stops.



9
10
11
# File 'lib/psd/layer/info/gradient_map.rb', line 9

def color_stops
  @color_stops
end

#ditherObject (readonly)

Returns the value of attribute dither.



9
10
11
# File 'lib/psd/layer/info/gradient_map.rb', line 9

def dither
  @dither
end

#interpolationObject (readonly)

Returns the value of attribute interpolation.



9
10
11
# File 'lib/psd/layer/info/gradient_map.rb', line 9

def interpolation
  @interpolation
end

#maximum_colorObject (readonly)

Returns the value of attribute maximum_color.



9
10
11
# File 'lib/psd/layer/info/gradient_map.rb', line 9

def maximum_color
  @maximum_color
end

#minimum_colorObject (readonly)

Returns the value of attribute minimum_color.



9
10
11
# File 'lib/psd/layer/info/gradient_map.rb', line 9

def minimum_color
  @minimum_color
end

#modeObject (readonly)

Returns the value of attribute mode.



9
10
11
# File 'lib/psd/layer/info/gradient_map.rb', line 9

def mode
  @mode
end

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/psd/layer/info/gradient_map.rb', line 9

def name
  @name
end

#random_seedObject (readonly)

Returns the value of attribute random_seed.



9
10
11
# File 'lib/psd/layer/info/gradient_map.rb', line 9

def random_seed
  @random_seed
end

#reverseObject (readonly)

Returns the value of attribute reverse.



9
10
11
# File 'lib/psd/layer/info/gradient_map.rb', line 9

def reverse
  @reverse
end

#roughness_factorObject (readonly)

Returns the value of attribute roughness_factor.



9
10
11
# File 'lib/psd/layer/info/gradient_map.rb', line 9

def roughness_factor
  @roughness_factor
end

#showing_transparencyObject (readonly)

Returns the value of attribute showing_transparency.



9
10
11
# File 'lib/psd/layer/info/gradient_map.rb', line 9

def showing_transparency
  @showing_transparency
end

#transparency_stopsObject (readonly)

Returns the value of attribute transparency_stops.



9
10
11
# File 'lib/psd/layer/info/gradient_map.rb', line 9

def transparency_stops
  @transparency_stops
end

#using_vector_colorObject (readonly)

Returns the value of attribute using_vector_color.



9
10
11
# File 'lib/psd/layer/info/gradient_map.rb', line 9

def using_vector_color
  @using_vector_color
end

Class Method Details

.should_parse?(key) ⇒ Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/psd/layer/info/gradient_map.rb', line 5

def self.should_parse?(key)
  key == 'grdm'
end

Instance Method Details

#parseObject



13
14
15
16
17
18
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/psd/layer/info/gradient_map.rb', line 13

def parse
  # Version
  @file.seek 2, IO::SEEK_CUR

  @reverse = @file.read_boolean
  @dither = @file.read_boolean

  @name = @file.read_unicode_string

  color_stops = @file.read_short
  @color_stops = color_stops.times.map do
    color = {
      location: @file.read_int,
      midpoint: @file.read_int,
      color: @file.read_space_color
    }

    # Mystery padding
    @file.seek 2, IO::SEEK_CUR
    color
  end

  transparency_stops = @file.read_short
  @transparency_stops = transparency_stops.times.map do
    {
      location: @file.read_int,
      midpoint: @file.read_int,
      opacity: @file.read_short
    }
  end

  expansion_count = @file.read_short
  if expansion_count > 0
    @interpolation = @file.read_short
    length = @file.read_short
    if length >= 32
      @mode = @file.read_short
      @random_seed = @file.read_int
      @showing_transparency = @file.read_short > 0
      @using_vector_color = @file.read_short > 0
      @roughness_factor = @file.read_int
      
      @color_model = @file.read_short
      @minimum_color = 4.times.map do
        @file.read_short >> 8
      end

      @maximum_color = 4.times.map do
        @file.read_short >> 8
      end
    end
  end

  @file.seek 2, IO::SEEK_CUR
end