Class: PSD::Mask
- Inherits:
-
Object
- Object
- PSD::Mask
- Defined in:
- lib/psd/mask.rb
Instance Attribute Summary collapse
-
#bottom ⇒ Object
readonly
Returns the value of attribute bottom.
-
#default_color ⇒ Object
readonly
Returns the value of attribute default_color.
-
#left ⇒ Object
readonly
Returns the value of attribute left.
-
#right ⇒ Object
readonly
Returns the value of attribute right.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#top ⇒ Object
readonly
Returns the value of attribute top.
Class Method Summary collapse
Instance Method Summary collapse
- #disabled ⇒ Object
- #from_other_data ⇒ Object
- #height ⇒ Object
-
#initialize(file) ⇒ Mask
constructor
A new instance of Mask.
- #invert ⇒ Object
- #parse ⇒ Object
- #relative ⇒ Object
- #to_hash ⇒ Object
- #width ⇒ Object
Constructor Details
#initialize(file) ⇒ Mask
Returns a new instance of Mask.
12 13 14 15 16 17 18 19 20 |
# File 'lib/psd/mask.rb', line 12 def initialize(file) @file = file @top = 0 @left = 0 @bottom = 0 @right = 0 @default_color = 0 @flags = 0 end |
Instance Attribute Details
#bottom ⇒ Object (readonly)
Returns the value of attribute bottom.
3 4 5 |
# File 'lib/psd/mask.rb', line 3 def bottom @bottom end |
#default_color ⇒ Object (readonly)
Returns the value of attribute default_color.
3 4 5 |
# File 'lib/psd/mask.rb', line 3 def default_color @default_color end |
#left ⇒ Object (readonly)
Returns the value of attribute left.
3 4 5 |
# File 'lib/psd/mask.rb', line 3 def left @left end |
#right ⇒ Object (readonly)
Returns the value of attribute right.
3 4 5 |
# File 'lib/psd/mask.rb', line 3 def right @right end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
3 4 5 |
# File 'lib/psd/mask.rb', line 3 def size @size end |
#top ⇒ Object (readonly)
Returns the value of attribute top.
3 4 5 |
# File 'lib/psd/mask.rb', line 3 def top @top end |
Class Method Details
Instance Method Details
#disabled ⇒ Object
51 52 53 |
# File 'lib/psd/mask.rb', line 51 def disabled (@flags & (0x01 << 1)) > 0 end |
#from_other_data ⇒ Object
59 60 61 |
# File 'lib/psd/mask.rb', line 59 def from_other_data (@flags & (0x01 << 3)) > 0 end |
#height ⇒ Object
43 44 45 |
# File 'lib/psd/mask.rb', line 43 def height bottom - top end |
#invert ⇒ Object
55 56 57 |
# File 'lib/psd/mask.rb', line 55 def invert (@flags & (0x01 << 2)) > 0 end |
#parse ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/psd/mask.rb', line 22 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 |
#relative ⇒ Object
47 48 49 |
# File 'lib/psd/mask.rb', line 47 def relative (@flags & 0x01) > 0 end |
#to_hash ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/psd/mask.rb', line 63 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 |
#width ⇒ Object
39 40 41 |
# File 'lib/psd/mask.rb', line 39 def width right - left end |