Sha256: 8a8774c0a812ee0c09052f6ce65e6e279dca44444ed6368daa68ade3ac865508
Contents?: true
Size: 1.14 KB
Versions: 3
Compression:
Stored size: 1.14 KB
Contents
require_relative 'nodes/ancestry' require_relative 'nodes/search' # Internal structure to help us build trees of a Photoshop documents. # A lot of method names borrowed from the Ruby ancestry gem. class PSD class Node include Ancestry include Search # Default properties that all nodes contain PROPERTIES = [:name, :left, :right, :top, :bottom, :height, :width] attr_accessor :parent, :children, :layer def initialize(layers=[]) @children = [] layers.each do |layer| layer.parent = self @children << layer end end def hidden? !@layer.visible? end def visible? @layer.visible? end def psd parent.psd end def layer? is_a?(PSD::Node::Layer) end def group? is_a?(PSD::Node::Group) end def to_hash hash = { type: nil, visible: visible?, opacity: @layer.opacity / 255.0, blending_mode: @layer.blending_mode } PROPERTIES.each do |p| hash[p] = self.send(p) end hash end def document_dimensions @parent.document_dimensions end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
psd-1.3.3 | lib/psd/node.rb |
psd-1.3.2 | lib/psd/node.rb |
psd-1.3.0 | lib/psd/node.rb |