Class: PSD::LayerStyles

Inherits:
Object
  • Object
show all
Defined in:
lib/psd/renderer/layer_styles.rb,
lib/psd/renderer/layer_styles/color_overlay.rb

Defined Under Namespace

Classes: ColorOverlay

Constant Summary collapse

BLEND_TRANSLATION =

Blend modes in layer effects use different keys than normal layer blend modes. Thanks Adobe.

{
  'Nrml' => 'norm',
  'Dslv' => 'diss',
  'Drkn' => 'dark',
  'Mltp' => 'mul',
  'CBrn' => 'idiv',
  'linearBurn' => 'lbrn',
  'Lghn' => 'lite',
  'Scrn' => 'scrn',
  'CDdg' => 'div',
  'linearDodge' => 'lddg',
  'Ovrl' => 'over',
  'SftL' => 'sLit',
  'HrdL' => 'hLit',
  'vividLight' => 'vLit',
  'linearLight' => 'lLit',
  'pinLight' => 'pLit',
  'hardMix' => 'hMix',
  'Dfrn' => 'diff',
  'Xclu' => 'smud',
  'H   ' => 'hue',
  'Strt' => 'sat',
  'Clr ' => 'colr',
  'Lmns' => 'lum'
}.freeze
SUPPORTED_STYLES =
[
  ColorOverlay
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(canvas) ⇒ LayerStyles

Returns a new instance of LayerStyles.



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/psd/renderer/layer_styles.rb', line 39

def initialize(canvas)
  @canvas = canvas
  @node = @canvas.node
  @data = @node.object_effects

  if @data.nil?
    @applied = true
  else
    @data = @data.data
    @applied = false
  end
end

Instance Attribute Details

#canvasObject (readonly)

Returns the value of attribute canvas.



37
38
39
# File 'lib/psd/renderer/layer_styles.rb', line 37

def canvas
  @canvas
end

#dataObject (readonly)

Returns the value of attribute data.



37
38
39
# File 'lib/psd/renderer/layer_styles.rb', line 37

def data
  @data
end

#nodeObject (readonly)

Returns the value of attribute node.



37
38
39
# File 'lib/psd/renderer/layer_styles.rb', line 37

def node
  @node
end

Instance Method Details

#apply!Object



52
53
54
55
56
57
58
59
60
# File 'lib/psd/renderer/layer_styles.rb', line 52

def apply!
  return if @applied || data.nil?
  return unless styles_enabled?

  SUPPORTED_STYLES.each do |style|
    next unless style.should_apply?(@canvas, data)
    style.new(self).apply!
  end
end

#styles_enabled?Boolean

Returns:

  • (Boolean)


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

def styles_enabled?
  data['masterFXSwitch']
end