Sha256: 9eeb819849590c2ca36f72e8753f4ad9e8da232a4736eed275b24fecbf170906

Contents?: true

Size: 1.32 KB

Versions: 5

Compression:

Stored size: 1.32 KB

Contents

require_relative 'layer_styles/color_overlay'
require_relative 'layer_styles/drop_shadow'

class PSD
  class LayerStyles
    # Blend modes in layer effects use different keys
    # than normal layer blend modes. Thanks Adobe.
    BLEND_TRANSLATION = {
      '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

    attr_reader :canvas, :node, :data

    def initialize(canvas)
      @canvas = canvas
      @node = @canvas.node
      @data = @node.layer.info[:object_effects]

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

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

      ColorOverlay.new(self).apply! if ColorOverlay.should_apply?(data)
      DropShadow.new(self).apply!   if DropShadow.should_apply?(data)
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
bench9000-0.1 vendor/psd.rb/lib/psd/renderer/layer_styles.rb
psd-2.1.2 lib/psd/renderer/layer_styles.rb
psd-2.1.1 lib/psd/renderer/layer_styles.rb
psd-2.1.0 lib/psd/renderer/layer_styles.rb
psd-2.0.0 lib/psd/renderer/layer_styles.rb