Class: Processing::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/processing/image.rb

Overview

Image object.

Instance Method Summary collapse

Instance Method Details

#blend(sx, sy, sw, sh, dx, dy, dw, dh, mode) ⇒ nil #blend(img, sx, sy, sw, sh, dx, dy, dw, dh, mode) ⇒ nil

Blends image.



96
97
98
99
100
101
102
# File 'lib/processing/image.rb', line 96

def blend(img = nil, sx, sy, sw, sh, dx, dy, dw, dh, mode)
  img ||= self
  @image.paint do |painter|
    img.drawImage__ painter, sx, sy, sw, sh, dx, dy, dw, dh, blend_mode: mode
  end
  nil
end

#copy(sx, sy, sw, sh, dx, dy, dw, dh) ⇒ nil #copy(img, sx, sy, sw, sh, dx, dy, dw, dh) ⇒ nil

Copies image.



74
75
76
# File 'lib/processing/image.rb', line 74

def copy(img = nil, sx, sy, sw, sh, dx, dy, dw, dh)
  blend img, sx, sy, sw, sh, dx, dy, dw, dh, :normal
end

#filter(*args) ⇒ Object

Applies an image filter.

overload filter(shader) overload filter(type) overload filter(type, param)



39
40
41
# File 'lib/processing/image.rb', line 39

def filter(*args)
  @filter = Shader.createFilter__(*args)
end

#heightNumeric

Gets height of image.



25
26
27
# File 'lib/processing/image.rb', line 25

def height()
  @image.height
end

#resize(width, height) ⇒ nil

Resizes image.



50
51
52
53
54
55
# File 'lib/processing/image.rb', line 50

def resize(width, height)
  @image = Rays::Image.new(width, height).paint do |painter|
    painter.image @image, 0, 0, width, height
  end
  nil
end

#save(filename) ⇒ Object

Saves image to file.



108
109
110
# File 'lib/processing/image.rb', line 108

def save(filename)
  @image.save filename
end

#widthNumeric

Gets width of image.



17
18
19
# File 'lib/processing/image.rb', line 17

def width()
  @image.width
end