Class: PSD::LayerStyles

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

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'
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(layer, png = nil) ⇒ LayerStyles

Returns a new instance of LayerStyles.



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/psd/layer_styles.rb', line 33

def initialize(layer, png=nil)
  @layer = layer
  @data = layer.info[:object_effects]
  @png = png || layer.image.to_png

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

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



31
32
33
# File 'lib/psd/layer_styles.rb', line 31

def data
  @data
end

#layerObject (readonly)

Returns the value of attribute layer.



31
32
33
# File 'lib/psd/layer_styles.rb', line 31

def layer
  @layer
end

#pngObject (readonly)

Returns the value of attribute png.



31
32
33
# File 'lib/psd/layer_styles.rb', line 31

def png
  @png
end

Instance Method Details

#apply!Object



46
47
48
49
50
51
# File 'lib/psd/layer_styles.rb', line 46

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

  apply_color_overlay if data.has_key?('SoFi')
  png
end