Module: PSD::Util

Extended by:
Util
Included in:
Util
Defined in:
lib/psd/util.rb

Instance Method Summary collapse

Instance Method Details

#clamp(num, min, max) ⇒ Object



14
15
16
17
18
# File 'lib/psd/util.rb', line 14

def clamp(num, min, max)
  return max if num > max
  return min if num < min
  num
end

#pad2(i) ⇒ Object



5
6
7
# File 'lib/psd/util.rb', line 5

def pad2(i)
  (i + 1) & ~0x01
end

#pad4(i) ⇒ Object

Ensures value is a multiple of 4



10
11
12
# File 'lib/psd/util.rb', line 10

def pad4(i)
  ((i + 4) & ~0x03) - 1
end