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
- #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 |
# File 'lib/psd/mask.rb', line 12 def initialize(file) @file = file @top = 0 @left = 0 @bottom = 0 @right = 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
49 50 51 |
# File 'lib/psd/mask.rb', line 49 def disabled (@flags & (0x01 << 1)) > 0 end |
#height ⇒ Object
41 42 43 |
# File 'lib/psd/mask.rb', line 41 def height bottom - top end |
#invert ⇒ Object
53 54 55 |
# File 'lib/psd/mask.rb', line 53 def invert (@flags & (0x01 << 2)) > 0 end |
#parse ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/psd/mask.rb', line 20 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
45 46 47 |
# File 'lib/psd/mask.rb', line 45 def relative (@flags & 0x01) > 0 end |
#to_hash ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/psd/mask.rb', line 57 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
37 38 39 |
# File 'lib/psd/mask.rb', line 37 def width right - left end |