Class: PSD::BlendMode

Inherits:
BinData::Record
  • Object
show all
Defined in:
lib/psd/blend_mode.rb

Overview

Describes the blend mode for a single layer or folder.

Constant Summary collapse

BLEND_MODES =

All of the blend modes are stored in the PSD file with a specific key. This is the mapping of that key to its readable name.

{
  norm: 'normal',
  dark: 'darken',
  lite: 'lighten',
  hue:  'hue',
  sat:  'saturation',
  colr: 'color',
  lum:  'luminosity',
  mul:  'multiply',
  scrn: 'screen',
  diss: 'dissolve',
  over: 'overlay',
  hLit: 'hard light',
  sLit: 'soft light',
  diff: 'difference',
  smud: 'exclusion',
  div:  'color dodge',
  idiv: 'color burn',
  lbrn: 'linear burn',
  lddg: 'linear dodge',
  vLit: 'vivid light',
  lLit: 'linear light',
  pLit: 'pin light',
  hMix: 'hard mix'
}

Instance Method Summary collapse

Instance Method Details

#modeObject

Get the readable name for this blend mode.



42
43
44
# File 'lib/psd/blend_mode.rb', line 42

def mode
  BLEND_MODES[blend_key.to_sym]
end

#mode=(val) ⇒ Object

Set the blend mode with the readable name.



47
48
49
# File 'lib/psd/blend_mode.rb', line 47

def mode=(val)
  blend_key = BLEND_MODES.invert[val.downcase]
end

#obsoleteObject



66
67
68
# File 'lib/psd/blend_mode.rb', line 66

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

#opacity_percentageObject

Opacity is stored as an integer between 0-255. This converts the opacity to a percentage value to match the Photoshop interface.



53
54
55
# File 'lib/psd/blend_mode.rb', line 53

def opacity_percentage
  opacity * 100 / 255
end

#pixel_data_irrelevantObject



70
71
72
73
# File 'lib/psd/blend_mode.rb', line 70

def pixel_data_irrelevant
  return nil unless (flags & (0x01 << 3)) > 0
  (flags & (0x01 << 4)) > 0
end

#transparency_protectedObject



57
58
59
# File 'lib/psd/blend_mode.rb', line 57

def transparency_protected
  flags & 0x01
end

#visibleObject

Is this layer/folder visible?



62
63
64
# File 'lib/psd/blend_mode.rb', line 62

def visible
  !((flags & (0x01 << 1)) > 0)
end