Sha256: 20f5c4cb8b79a1b02e21612bed6b5d80435c9e4785b002c2c41d4b54a4bca989
Contents?: true
Size: 1.32 KB
Versions: 4
Compression:
Stored size: 1.32 KB
Contents
class PSD class Mask attr_reader :size, :top, :left, :bottom, :right, :default_color def self.read(file) mask = Mask.new(file) mask.parse mask end def initialize(file) @file = file @top = 0 @left = 0 @bottom = 0 @right = 0 @default_color = 0 @flags = 0 end def parse @size = @file.read_int return if @size == 0 @mask_end = @file.tell + @size @top = @file.read_int @left = @file.read_int @bottom = @file.read_int @right = @file.read_int @default_color = @file.read_byte @flags = @file.read_byte @file.seek @mask_end # Useless info/padding end def width right - left end def height bottom - top end def relative (@flags & 0x01) > 0 end def disabled (@flags & (0x01 << 1)) > 0 end def invert (@flags & (0x01 << 2)) > 0 end def from_other_data (@flags & (0x01 << 3)) > 0 end def to_hash return {} if @size == 0 { top: top, left: left, bottom: bottom, right: right, width: width, height: height, default_color: default_color, relative: relative, disabled: disabled, invert: invert } end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
psd-3.9.0 | lib/psd/mask.rb |
psd-3.8.0 | lib/psd/mask.rb |
psd-3.7.0 | lib/psd/mask.rb |
psd-3.6.0 | lib/psd/mask.rb |