Class: CompositorNode::Cropper

Inherits:
Object
  • Object
show all
Defined in:
lib/compositor_node/cropper.rb

Defined Under Namespace

Classes: MissingDimensionCropError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Cropper

Returns a new instance of Cropper.



8
9
10
11
12
13
14
# File 'lib/compositor_node/cropper.rb', line 8

def initialize(options = {})
  @source = options[:source]
  @width = options[:width]
  @height = options[:height]
  @x_offset = options[:x_offset] || 0
  @y_offset = options[:y_offset] || 0
end

Instance Attribute Details

#heightObject

Returns the value of attribute height.



4
5
6
# File 'lib/compositor_node/cropper.rb', line 4

def height
  @height
end

#sourceObject

Returns the value of attribute source.



4
5
6
# File 'lib/compositor_node/cropper.rb', line 4

def source
  @source
end

#widthObject

Returns the value of attribute width.



4
5
6
# File 'lib/compositor_node/cropper.rb', line 4

def width
  @width
end

#x_offsetObject

Returns the value of attribute x_offset.



4
5
6
# File 'lib/compositor_node/cropper.rb', line 4

def x_offset
  @x_offset
end

#y_offsetObject

Returns the value of attribute y_offset.



4
5
6
# File 'lib/compositor_node/cropper.rb', line 4

def y_offset
  @y_offset
end

Instance Method Details

#executeObject



16
17
18
19
# File 'lib/compositor_node/cropper.rb', line 16

def execute
  raise MissingDimensionCropError unless @width && @height
  Engine.crop(@source.execute, @x_offset, @y_offset, @width, @height)
end