Sha256: 3c04a82d0000273e5e9c4aef1827b63420653dd227c7731cd209c9009b0d840a

Contents?: true

Size: 1.4 KB

Versions: 12

Compression:

Stored size: 1.4 KB

Contents

require 'psd/renderer/layer_styles/color_overlay'

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

    SUPPORTED_STYLES = [
      ColorOverlay
    ]

    attr_reader :canvas, :node, :data

    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

    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

    def styles_enabled?
      data['masterFXSwitch']
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
psd-3.9.0 lib/psd/renderer/layer_styles.rb
psd-3.8.0 lib/psd/renderer/layer_styles.rb
psd-3.7.0 lib/psd/renderer/layer_styles.rb
psd-3.6.0 lib/psd/renderer/layer_styles.rb
psd-3.5.0 lib/psd/renderer/layer_styles.rb
psd-3.4.0 lib/psd/renderer/layer_styles.rb
psd-3.3.3 lib/psd/renderer/layer_styles.rb
psd-3.3.2 lib/psd/renderer/layer_styles.rb
psd-3.3.1 lib/psd/renderer/layer_styles.rb
psd-3.2.4 lib/psd/renderer/layer_styles.rb
psd-3.2.3 lib/psd/renderer/layer_styles.rb
psd-3.2.2 lib/psd/renderer/layer_styles.rb