Sha256: ff602d713742a43231e717626083fbb63ffad57d030f5a30570f4a0390b9c2c8

Contents?: true

Size: 1.36 KB

Versions: 9

Compression:

Stored size: 1.36 KB

Contents

class PSD
  # Represents a single layer and all of the data associated with
  # that layer.
  class Layer
    include BlendModes
    include BlendingRanges
    include ChannelImage
    include Exporting
    include Info
    include Mask
    include Name
    include PathComponents
    include PositionAndChannels
    include Helpers

    attr_reader :id, :info_keys, :header
    attr_accessor :group_layer, :node, :file

    # Initializes all of the defaults for the layer.
    def initialize(file, header)
      @file = file
      @header = header

      @mask = {}
      @blending_ranges = {}
      @adjustments = {}
      @channels_info = []
      @blend_mode = {}
      @group_layer = nil

      # Just used for tracking which layer adjustments we're parsing.
      # Not essential.
      @info_keys = []
    end

    # Parse the layer and all of it's sub-sections.
    def parse(index=nil)
      @id = index

      parse_position_and_channels
      parse_blend_modes

      extra_len = @file.read_int
      @layer_end = @file.tell + extra_len

      parse_mask_data
      parse_blending_ranges
      parse_legacy_layer_name
      parse_layer_info

      PSD.logger.debug "Layer name = #{name}"

      @file.seek @layer_end # Skip over any filler zeros

      return self
    end

    # We just delegate this to a normal method call.
    def [](val)
      self.send(val)
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
psd-3.2.4 lib/psd/layer.rb
psd-3.2.3 lib/psd/layer.rb
psd-3.2.2 lib/psd/layer.rb
psd-3.2.1 lib/psd/layer.rb
psd-3.2.0 lib/psd/layer.rb
psd-3.1.5 lib/psd/layer.rb
psd-3.1.4 lib/psd/layer.rb
psd-3.1.3 lib/psd/layer.rb
psd-3.1.2 lib/psd/layer.rb