Class: RComposite::FillLayer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Layer

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

Constructor Details

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

Returns a new instance of FillLayer.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rcomposite/filllayer.rb', line 12

def initialize(type, *args, &block)
  case type
    when SolidColor
      color = args[0]

      fill = Magick::GradientFill.new(0, 0, 0, 0, color, color)
      
    when Gradient
      x1 = args[0]
      y1 = args[1]
      x2 = args[2]
      y2 = args[3]
      color1 = args[4]
      color2 = args[5]

      fill = Magick::GradientFill.new(x1, y1, x2, y2, color1, color2)
    
    when Pattern
      image = args[0]

      fill = Magick::TextureFill.new(image)
  end

  @image = Magick::Image.new($RCompositeCanvasWidth, $RCompositeCanvasHeight, fill)

  @image.matte = true
  @mode = Normal
  @offset_x = 0
  @offset_y = 0
  @opacity_percent = 100
end

Instance Attribute Details

#imageObject

Returns the value of attribute image.



9
10
11
# File 'lib/rcomposite/filllayer.rb', line 9

def image
  @image
end

#offset_xObject (readonly)

Returns the value of attribute offset_x.



10
11
12
# File 'lib/rcomposite/filllayer.rb', line 10

def offset_x
  @offset_x
end

#offset_yObject (readonly)

Returns the value of attribute offset_y.



10
11
12
# File 'lib/rcomposite/filllayer.rb', line 10

def offset_y
  @offset_y
end