Module: PSD::Node::BuildPreview

Includes:
Image::Export::PNG
Included in:
PSD::Node
Defined in:
lib/psd/nodes/build_preview.rb

Instance Method Summary collapse

Methods included from Image::Export::PNG

#mask_to_png, #save_as_png, #to_png_with_mask

Instance Method Details

#build_png(png = nil) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/psd/nodes/build_preview.rb', line 12

def build_png(png=nil)
  png ||= create_canvas

  children.reverse.each do |c|
    next unless c.visible?
    
    if c.group?
      if c.blending_mode == 'passthru'
        c.build_png(png)
      else
        compose! c, png, c.build_png, 0, 0
      end
    else
      compose!(
        c, 
        png, 
        c.image.to_png_with_mask, 
        PSD::Util.clamp(c.left.to_i, 0, png.width), 
        PSD::Util.clamp(c.top.to_i, 0, png.height)
      )
    end
  end

  png
end

#orig_to_pngObject



6
# File 'lib/psd/nodes/build_preview.rb', line 6

alias :orig_to_png :to_png

#to_pngObject



7
8
9
10
# File 'lib/psd/nodes/build_preview.rb', line 7

def to_png
  return build_png if group?
  layer.image.to_png
end