Sha256: 3d6aa8e7cff1ce7dc1fae15d586d9a099d24ef8efd93f21bc439528545f906c2

Contents?: true

Size: 997 Bytes

Versions: 13

Compression:

Stored size: 997 Bytes

Contents

require_relative '../layer_info'

class PSD
  class LayerSectionDivider < LayerInfo
    @key = 'lsct'

    attr_reader :layer_type, :is_folder, :is_hidden, :blend_mode, :sub_type

    SECTION_DIVIDER_TYPES = [
      "other",
      "open folder",
      "closed folder",
      "bounding section divider"
    ]

    def initialize(file, length)
      super

      @is_folder = false
      @is_hidden = false
      @blend_mode = nil
      @sub_type = nil
    end

    def parse
      code = @file.read_int
      @layer_type = SECTION_DIVIDER_TYPES[code]

      case code
      when 1, 2 then @is_folder = true
      when 3 then @is_hidden = true
      end

      PSD.logger.warn "Section divider is unexpected value: #{code}" if code > 4

      return self unless @length >= 12

      @file.seek 4, IO::SEEK_CUR # sig
      @blend_mode = @file.read_string(4)

      return self unless @length >= 16

      @sub_type = @file.read_int == 0 ? 'normal' : 'scene group'

      return self
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
bench9000-0.1 vendor/psd.rb/lib/psd/layer_info/layer_section_divider.rb
psd-2.1.2 lib/psd/layer_info/layer_section_divider.rb
psd-2.1.1 lib/psd/layer_info/layer_section_divider.rb
psd-2.1.0 lib/psd/layer_info/layer_section_divider.rb
psd-2.0.0 lib/psd/layer_info/layer_section_divider.rb
psd-1.5.0 lib/psd/layer_info/layer_section_divider.rb
psd-1.4.5 lib/psd/layer_info/layer_section_divider.rb
psd-1.4.4 lib/psd/layer_info/layer_section_divider.rb
psd-1.4.3 lib/psd/layer_info/layer_section_divider.rb
psd-1.4.2 lib/psd/layer_info/layer_section_divider.rb
psd-1.4.1 lib/psd/layer_info/layer_section_divider.rb
psd-1.4.0 lib/psd/layer_info/layer_section_divider.rb
psd-1.3.3 lib/psd/layer_info/layer_section_divider.rb