Class: PSD::Renderer::Canvas
- Inherits:
-
Object
- Object
- PSD::Renderer::Canvas
- Defined in:
- lib/psd/renderer/canvas.rb
Instance Attribute Summary collapse
-
#bottom ⇒ Object
readonly
Returns the value of attribute bottom.
-
#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.
-
#left ⇒ Object
readonly
Returns the value of attribute left.
-
#node ⇒ Object
readonly
Returns the value of attribute node.
-
#opacity ⇒ Object
readonly
Returns the value of attribute opacity.
-
#right ⇒ Object
readonly
Returns the value of attribute right.
-
#top ⇒ Object
readonly
Returns the value of attribute top.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
- #[](x, y) ⇒ Object
- #[]=(x, y, value) ⇒ Object
-
#initialize(node, width = nil, height = nil, color = ChunkyPNG::Color::TRANSPARENT) ⇒ 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, color = ChunkyPNG::Color::TRANSPARENT) ⇒ Canvas
Returns a new instance of Canvas.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/psd/renderer/canvas.rb', line 6 def initialize(node, width = nil, height = nil, color = ChunkyPNG::Color::TRANSPARENT) @node = node @pixel_data = @node.group? ? [] : @node.image.pixel_data @width = (width || @node.width).to_i @height = (height || @node.height).to_i @left = @node.left.to_i @right = @node.right.to_i @top = @node.top.to_i @bottom = @node.bottom.to_i @opacity = @node.opacity.to_f @fill_opacity = @node.fill_opacity.to_f @canvas = ChunkyPNG::Canvas.new(@width, @height, color) initialize_canvas unless @node.group? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
44 45 46 |
# File 'lib/psd/renderer/canvas.rb', line 44 def method_missing(method, *args, &block) @canvas.send(method, *args, &block) end |
Instance Attribute Details
#bottom ⇒ Object (readonly)
Returns the value of attribute bottom.
4 5 6 |
# File 'lib/psd/renderer/canvas.rb', line 4 def bottom @bottom end |
#canvas ⇒ Object
Returns the value of attribute canvas.
4 5 6 |
# File 'lib/psd/renderer/canvas.rb', line 4 def canvas @canvas end |
#fill_opacity ⇒ Object (readonly)
Returns the value of attribute fill_opacity.
4 5 6 |
# File 'lib/psd/renderer/canvas.rb', line 4 def fill_opacity @fill_opacity end |
#height ⇒ Object (readonly)
Returns the value of attribute height.
4 5 6 |
# File 'lib/psd/renderer/canvas.rb', line 4 def height @height end |
#left ⇒ Object (readonly)
Returns the value of attribute left.
4 5 6 |
# File 'lib/psd/renderer/canvas.rb', line 4 def left @left end |
#node ⇒ Object (readonly)
Returns the value of attribute node.
4 5 6 |
# File 'lib/psd/renderer/canvas.rb', line 4 def node @node end |
#opacity ⇒ Object (readonly)
Returns the value of attribute opacity.
4 5 6 |
# File 'lib/psd/renderer/canvas.rb', line 4 def opacity @opacity end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
4 5 6 |
# File 'lib/psd/renderer/canvas.rb', line 4 def right @right end |
#top ⇒ Object (readonly)
Returns the value of attribute top.
4 5 6 |
# File 'lib/psd/renderer/canvas.rb', line 4 def top @top end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
4 5 6 |
# File 'lib/psd/renderer/canvas.rb', line 4 def width @width end |
Instance Method Details
#[](x, y) ⇒ Object
41 |
# File 'lib/psd/renderer/canvas.rb', line 41 def [](x, y); @canvas[x, y]; end |
#[]=(x, y, value) ⇒ Object
42 |
# File 'lib/psd/renderer/canvas.rb', line 42 def []=(x, y, value); @canvas[x, y] = value; end |
#paint_to(base) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/psd/renderer/canvas.rb', line 25 def paint_to(base) PSD.logger.debug "Painting #{node.name} to #{base.node.debug_name}" apply_mask apply_clipping_mask apply_layer_styles apply_layer_opacity compose_pixels(base) end |