Sha256: 2222a336cc950e3de822e0d9363ee58956c429a101ee311d61cfe44b3311436a

Contents?: true

Size: 905 Bytes

Versions: 21

Compression:

Stored size: 905 Bytes

Contents

class PSD
  # Represents the mask for a single layer
  class Mask < BinData::Record
    endian :big

    int32  :mask_size

    int32 :top,           onlyif: :has_data?
    int32 :left,          onlyif: :has_data?
    int32 :bottom,        onlyif: :has_data?
    int32 :right,         onlyif: :has_data?
    int8  :default_color, onlyif: :has_data?
    bit8  :flags,         onlyif: :has_data?

    skip length: 2,   onlyif: lambda { mask_size == 20 }
    skip length: 18,  onlyif: lambda { mask_size > 0 && mask_size != 20}

    # Is there a mask defined?
    def has_data?
      mask_size > 0
    end

    # Width of the mask
    def width
      right - left
    end

    # Height of the mask
    def height
      bottom - top
    end

    def relative
      flags & 0x01
    end

    def disabled
      (flags & (0x01 << 1)) > 0
    end

    def invert
      (flags & (0x01 << 2)) > 0
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
psd-1.4.4 lib/psd/mask.rb
psd-1.4.3 lib/psd/mask.rb
psd-1.4.2 lib/psd/mask.rb
psd-1.4.1 lib/psd/mask.rb
psd-1.4.0 lib/psd/mask.rb
psd-1.3.3 lib/psd/mask.rb
psd-1.3.2 lib/psd/mask.rb
psd-1.3.0 lib/psd/mask.rb
psd-1.2.2 lib/psd/mask.rb
psd-1.2.1 lib/psd/mask.rb
psd-1.2.0 lib/psd/mask.rb
psd-1.1.1 lib/psd/mask.rb
psd-1.1.0 lib/psd/mask.rb
psd-1.0.0 lib/psd/mask.rb
psd-0.4.2 lib/psd/mask.rb
psd-0.4.1 lib/psd/mask.rb
psd-0.4.0 lib/psd/mask.rb
psd-0.3.5 lib/psd/mask.rb
psd-0.3.4 lib/psd/mask.rb
psd-0.3.3 lib/psd/mask.rb