Sha256: a1ae62744005c4f3af2e5d4b765ad1cc03b9e9b365df9529b197c5432960c9ea

Contents?: true

Size: 1.94 KB

Versions: 1

Compression:

Stored size: 1.94 KB

Contents

class PSD
  class Layer
    module Helpers
      # Does this layer represent the start of a folder section?
      def folder?
        if info.has_key?(:section_divider)
          info[:section_divider].is_folder
        elsif info.has_key?(:nested_section_divider)
          info[:nested_section_divider].is_folder
        else
          name == "<Layer group>"
        end
      end

      # Does this layer represent the end of a folder section?
      def folder_end?
        if info.has_key?(:section_divider)
          info[:section_divider].is_hidden
        elsif info.has_key?(:nested_section_divider)
          info[:nested_section_divider].is_hidden
        else
          name == "</Layer group>"
        end
      end

      # Is the layer completely locked?
      def all_locked?
        return false unless info.has_key?(:locked)
        info[:locked].all_locked
      end

      # Is the layer position locked?
      def position_locked?
        return false unless info.has_key?(:locked)
        info[:locked].position_locked
      end

      # Is the layer composite locked?
      def composite_locked?
        return false unless info.has_key?(:locked)
        info[:locked].composite_locked
      end

      # Is the layer transparency locked?
      def transparency_locked?
        return false unless info.has_key?(:locked)
        info[:locked].transparency_locked
      end

      # Is this layer visible?
      def visible?
        @visible
      end

      # Is this layer hidden?
      def hidden?
        !@visible
      end

      # Helper that exports the text data in this layer, if any.
      def text
        return nil unless info[:type]
        info[:type].to_hash
      end

      def layer_type
        return 'normal' unless info.has_key?(:section_divider)
        info[:section_divider].layer_type
      end

      def fill_opacity
        return 255 unless info.has_key?(:fill_opacity)
        info[:fill_opacity].enabled
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
psd-1.5.0 lib/psd/layer/helpers.rb