Class: RComposite::AdjustmentLayer

Inherits:
Layer
  • Object
show all
Defined in:
lib/rcomposite/adjustmentlayer.rb

Instance Attribute Summary collapse

Attributes inherited from Layer

#image, #offset_x, #offset_y

Instance Method Summary collapse

Methods inherited from Layer

#height, #join_set, #layer_mask, #leave_set, #mode, #offset, #opacity, #rotate, #save_as, #width

Constructor Details

#initialize(type, *args, &block) ⇒ AdjustmentLayer

Returns a new instance of AdjustmentLayer.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rcomposite/adjustmentlayer.rb', line 19

def initialize(type, *args, &block)
  @type = type
  @args = args
  @mode = Normal
  @offset_x = 0
  @offset_y = 0
  @opacity_percent = 100
  @layer_mask = nil
  
  case type
    when Invert
      @proc = proc { negate }
    when Threshold    
      @proc = proc { threshold *args }
    when Levels
      @proc = proc { level *args }
    when Blur
      @proc = proc { gaussian_blur *args }
  end
  @proc = proc { |*args| @proc }.call(*@args)
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



17
18
19
# File 'lib/rcomposite/adjustmentlayer.rb', line 17

def args
  @args
end

#typeObject (readonly)

Returns the value of attribute type.



17
18
19
# File 'lib/rcomposite/adjustmentlayer.rb', line 17

def type
  @type
end

Instance Method Details

#merge_down(image) ⇒ Object



41
42
43
44
45
46
# File 'lib/rcomposite/adjustmentlayer.rb', line 41

def merge_down(image)
  @image = image.clone.instance_eval &@proc
  @image.matte = true

  super(image)
end