Class: PSD::Layer
- Inherits:
-
Object
- Object
- PSD::Layer
- Includes:
- BlendModes, BlendingRanges, ChannelImage, Exporting, Helpers, Info, Mask, Name, PathComponents, PositionAndChannels, Section
- 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
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
-
#group_layer ⇒ Object
Returns the value of attribute group_layer.
-
#header ⇒ Object
readonly
Returns the value of attribute header.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#info_keys ⇒ Object
readonly
Returns the value of attribute info_keys.
-
#node ⇒ Object
Returns the value of attribute node.
Attributes included from PositionAndChannels
#bottom, #channels, #channels_info, #cols, #left, #right, #rows, #top
Attributes included from Mask
Attributes included from Info
Attributes included from ChannelImage
Attributes included from BlendingRanges
Attributes included from BlendModes
Attributes included from Section
Instance Method Summary collapse
-
#[](val) ⇒ Object
We just delegate this to a normal method call.
-
#initialize(file, header) ⇒ Layer
constructor
Initializes all of the defaults for the layer.
-
#method_missing(method, *args, &block) ⇒ Object
We delegate all missing method calls to the extra layer info to make it easier to access that data.
-
#parse(index = nil) ⇒ Object
Parse the layer and all of it’s sub-sections.
Methods included from PathComponents
#scale_path_components, #translate
Methods included from Name
Methods included from Helpers
#fill_opacity, #folder?, #folder_end?, #hidden?, #layer_type, #text, #visible?
Methods included from Exporting
Methods included from ChannelImage
Methods included from BlendModes
Methods included from Section
#end_of_section, #end_section, #start_of_section, #start_section
Constructor Details
#initialize(file, header) ⇒ Layer
Initializes all of the defaults for the layer.
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/psd/layer.rb', line 21 def initialize(file, header) @file = file @header = header @mask = {} @blending_ranges = {} @adjustments = {} @channels_info = [] @blend_mode = {} @group_layer = nil @blending_mode = 'normal' @opacity = 255 # Just used for tracking which layer adjustments we're parsing. # Not essential. @info_keys = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
We delegate all missing method calls to the extra layer info to make it easier to access that data.
72 73 74 75 |
# File 'lib/psd/layer.rb', line 72 def method_missing(method, *args, &block) return @adjustments[method] if @adjustments.has_key?(method) super end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
18 19 20 |
# File 'lib/psd/layer.rb', line 18 def file @file end |
#group_layer ⇒ Object
Returns the value of attribute group_layer.
18 19 20 |
# File 'lib/psd/layer.rb', line 18 def group_layer @group_layer end |
#header ⇒ Object (readonly)
Returns the value of attribute header.
17 18 19 |
# File 'lib/psd/layer.rb', line 17 def header @header end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
17 18 19 |
# File 'lib/psd/layer.rb', line 17 def id @id end |
#info_keys ⇒ Object (readonly)
Returns the value of attribute info_keys.
17 18 19 |
# File 'lib/psd/layer.rb', line 17 def info_keys @info_keys end |
#node ⇒ Object
Returns the value of attribute node.
18 19 20 |
# File 'lib/psd/layer.rb', line 18 def node @node end |
Instance Method Details
#[](val) ⇒ Object
We just delegate this to a normal method call.
66 67 68 |
# File 'lib/psd/layer.rb', line 66 def [](val) self.send(val) end |
#parse(index = nil) ⇒ Object
Parse the layer and all of it’s sub-sections.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/psd/layer.rb', line 41 def parse(index=nil) start_section @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 end_section return self end |