Class: PSD::Node::Layer
- Includes:
- LockToOrigin
- Defined in:
- lib/psd/node_layer.rb
Constant Summary
Constants inherited from PSD::Node
Instance Attribute Summary collapse
-
#layer ⇒ Object
readonly
Returns the value of attribute layer.
Attributes inherited from PSD::Node
Instance Method Summary collapse
-
#hide! ⇒ Object
Tries to hide the layer by moving it way off canvas.
-
#initialize(layer) ⇒ Layer
constructor
Stores a reference to the PSD::Layer.
-
#method_missing(method, *args, &block) ⇒ Object
If the method is missing, we blindly send it to the layer.
-
#scale_path_components(xr, yr) ⇒ Object
Attempt to scale the path components of the layer.
-
#show! ⇒ Object
Tries to re-show the canvas by moving it back to it’s original position.
-
#to_hash ⇒ Object
Exports this layer to a Hash.
-
#translate(x = 0, y = 0) ⇒ Object
Attempt to translate the layer.
Methods included from LockToOrigin
Methods inherited from PSD::Node
#document_dimensions, #group?, #hidden?, #layer?, #visible?
Methods included from Search
Methods included from Ancestry
#ancestors, #childless?, #depth, #descendants, #has_children?, #has_siblings?, #only_child?, #root, #root?, #siblings, #subtree
Constructor Details
#initialize(layer) ⇒ Layer
Stores a reference to the PSD::Layer
10 11 12 13 14 15 |
# File 'lib/psd/node_layer.rb', line 10 def initialize(layer) super([]) @layer = layer layer.node = self end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
If the method is missing, we blindly send it to the layer. The layer handles the case in which the method doesn’t exist.
30 31 32 |
# File 'lib/psd/node_layer.rb', line 30 def method_missing(method, *args, &block) layer.send(method, *args, &block) end |
Instance Attribute Details
#layer ⇒ Object (readonly)
Returns the value of attribute layer.
7 8 9 |
# File 'lib/psd/node_layer.rb', line 7 def layer @layer end |
Instance Method Details
#hide! ⇒ Object
Tries to hide the layer by moving it way off canvas.
45 46 47 48 49 50 51 |
# File 'lib/psd/node_layer.rb', line 45 def hide! # TODO actually mess with the blend modes instead of # just putting things way off canvas return if @hidden_by_kelly translate(100000, 10000) @hidden_by_kelly = true end |
#scale_path_components(xr, yr) ⇒ Object
Attempt to scale the path components of the layer.
40 41 42 |
# File 'lib/psd/node_layer.rb', line 40 def scale_path_components(xr, yr) @layer.scale_path_components(xr, yr) end |
#show! ⇒ Object
Tries to re-show the canvas by moving it back to it’s original position.
54 55 56 57 58 59 |
# File 'lib/psd/node_layer.rb', line 54 def show! if @hidden_by_kelly translate(-100000, -10000) @hidden_by_kelly = false end end |
#to_hash ⇒ Object
Exports this layer to a Hash.
62 63 64 65 66 67 68 69 |
# File 'lib/psd/node_layer.rb', line 62 def to_hash super.merge({ type: :layer, text: @layer.text, ref_x: @layer.reference_point.x, ref_y: @layer.reference_point.y }) end |
#translate(x = 0, y = 0) ⇒ Object
Attempt to translate the layer.
35 36 37 |
# File 'lib/psd/node_layer.rb', line 35 def translate(x=0, y=0) @layer.translate x, y end |