Class: PSD::Renderer::Canvas
- Inherits:
-
Object
- Object
- PSD::Renderer::Canvas
- Extended by:
- Forwardable
- Defined in:
- lib/psd/renderer/canvas.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#canvas ⇒ Object
Returns the value of attribute canvas.
-
#fill_opacity ⇒ Object
readonly
Returns the value of attribute fill_opacity.
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#opacity ⇒ Object
readonly
Returns the value of attribute opacity.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(node, width = nil, height = nil, opts = {}) ⇒ Canvas
constructor
A new instance of Canvas.
- #method_missing(method, *args, &block) ⇒ Object
- #paint_to(base) ⇒ Object
Constructor Details
#initialize(node, width = nil, height = nil, opts = {}) ⇒ Canvas
Returns a new instance of Canvas.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/psd/renderer/canvas.rb', line 11 def initialize(node, width = nil, height = nil, opts = {}) @node = node @opts = opts @pixel_data = @node.group? ? [] : @node.image.pixel_data @width = (width || @node.width).to_i @height = (height || @node.height).to_i @opacity = @node.opacity.to_f @fill_opacity = @node.fill_opacity.to_f initialize_canvas end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
42 43 44 |
# File 'lib/psd/renderer/canvas.rb', line 42 def method_missing(method, *args, &block) @canvas.send(method, *args, &block) end |
Instance Attribute Details
#canvas ⇒ Object
Returns the value of attribute canvas.
6 7 8 |
# File 'lib/psd/renderer/canvas.rb', line 6 def canvas @canvas end |
#fill_opacity ⇒ Object (readonly)
Returns the value of attribute fill_opacity.
6 7 8 |
# File 'lib/psd/renderer/canvas.rb', line 6 def fill_opacity @fill_opacity end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
6 7 8 |
# File 'lib/psd/renderer/canvas.rb', line 6 def height @height end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
6 7 8 |
# File 'lib/psd/renderer/canvas.rb', line 6 def node @node end |
#opacity ⇒ Object (readonly)
Returns the value of attribute opacity.
6 7 8 |
# File 'lib/psd/renderer/canvas.rb', line 6 def opacity @opacity end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
6 7 8 |
# File 'lib/psd/renderer/canvas.rb', line 6 def opts @opts end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
6 7 8 |
# File 'lib/psd/renderer/canvas.rb', line 6 def width @width end |
Instance Method Details
#paint_to(base) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/psd/renderer/canvas.rb', line 25 def paint_to(base) PSD.logger.debug "Painting #{node.name} to #{base.node.debug_name}" apply_masks apply_clipping_mask apply_layer_styles apply_layer_opacity compose_pixels(base) end |