Class: PSD::Layer

Inherits:
Object
  • Object
show all
Includes:
BlendModes, BlendingRanges, ChannelImage, Exporting, Helpers, Info, Mask, Name, PathComponents, PositionAndChannels
Defined in:
lib/psd/layer.rb,
lib/psd/layer/info.rb,
lib/psd/layer/mask.rb,
lib/psd/layer/name.rb,
lib/psd/layer/helpers.rb,
lib/psd/layer/exporting.rb,
lib/psd/layer/blend_modes.rb,
lib/psd/layer/channel_image.rb,
lib/psd/layer/blending_ranges.rb,
lib/psd/layer/path_components.rb,
lib/psd/layer/position_and_channels.rb

Overview

Represents a single layer and all of the data associated with that layer.

Defined Under Namespace

Modules: BlendModes, BlendingRanges, ChannelImage, Exporting, Helpers, Info, Mask, Name, PathComponents, PositionAndChannels

Constant Summary

Constants included from Info

Info::BIG_LAYER_INFO_KEYS, Info::LAYER_INFO

Instance Attribute Summary collapse

Attributes included from PositionAndChannels

#bottom, #channels, #channels_info, #cols, #left, #right, #rows, #top

Attributes included from Mask

#mask

Attributes included from Info

#adjustments

Attributes included from ChannelImage

#image

Attributes included from BlendingRanges

#blending_ranges

Attributes included from BlendModes

#blend_mode

Instance Method Summary collapse

Methods included from Helpers

#all_locked?, #composite_locked?, #fill_opacity, #folder?, #folder_end?, #layer_type, #position_locked?, #raster_mask?, #text, #transparency_locked?, #vector_mask?

Methods included from PathComponents

#scale_path_components, #translate

Methods included from Name

#name

Methods included from Exporting

#export, #write_vector_mask

Methods included from ChannelImage

#parse_channel_image

Methods included from BlendModes

#blending_mode, #hidden?

Constructor Details

#initialize(file, header) ⇒ Layer

Initializes all of the defaults for the layer.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/psd/layer.rb', line 31

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

Instance Attribute Details

#fileObject

Returns the value of attribute file.



28
29
30
# File 'lib/psd/layer.rb', line 28

def file
  @file
end

#group_layerObject

Returns the value of attribute group_layer.



28
29
30
# File 'lib/psd/layer.rb', line 28

def group_layer
  @group_layer
end

#headerObject (readonly)

Returns the value of attribute header.



27
28
29
# File 'lib/psd/layer.rb', line 27

def header
  @header
end

#idObject (readonly)

Returns the value of attribute id.



27
28
29
# File 'lib/psd/layer.rb', line 27

def id
  @id
end

#info_keysObject (readonly)

Returns the value of attribute info_keys.



27
28
29
# File 'lib/psd/layer.rb', line 27

def info_keys
  @info_keys
end

#nodeObject

Returns the value of attribute node.



28
29
30
# File 'lib/psd/layer.rb', line 28

def node
  @node
end

Instance Method Details

#[](val) ⇒ Object

We just delegate this to a normal method call.



70
71
72
# File 'lib/psd/layer.rb', line 70

def [](val)
  self.send(val)
end

#parse(index = nil) ⇒ Object

Parse the layer and all of it’s sub-sections.



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/psd/layer.rb', line 48

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