Sha256: 5adc1eea81670c70a771d5b6aeb1520ac1a69db4b77794f2e186a6b556dde115

Contents?: true

Size: 1.41 KB

Versions: 6

Compression:

Stored size: 1.41 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
    ].freeze

    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

6 entries across 6 versions & 1 rubygems

Version Path
psd-3.2.1 lib/psd/renderer/layer_styles.rb
psd-3.2.0 lib/psd/renderer/layer_styles.rb
psd-3.1.5 lib/psd/renderer/layer_styles.rb
psd-3.1.4 lib/psd/renderer/layer_styles.rb
psd-3.1.3 lib/psd/renderer/layer_styles.rb
psd-3.1.2 lib/psd/renderer/layer_styles.rb