Class: Processing::Image
- Inherits:
-
Object
- Object
- Processing::Image
- Includes:
- Xot::Inspectable
- Defined in:
- lib/processing/image.rb
Overview
Image object.
Instance Method Summary collapse
-
#blend(img = nil, sx, sy, sw, sh, dx, dy, dw, dh, mode) ⇒ nil
Blends image.
-
#copy(img = nil, sx, sy, sw, sh, dx, dy, dw, dh) ⇒ nil
Copies image.
-
#filter(*args) ⇒ Object
Applies an image filter.
-
#height ⇒ Numeric
(also: #h)
Gets height of image.
-
#resize(width, height) ⇒ nil
Resizes image.
-
#save(filename) ⇒ Object
Saves image to file.
-
#size ⇒ Array<Numeric>
Returns the width and height of image.
-
#width ⇒ Numeric
(also: #w)
Gets width of image.
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.
109 110 111 112 113 114 115 |
# File 'lib/processing/image.rb', line 109 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.
87 88 89 |
# File 'lib/processing/image.rb', line 87 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)
52 53 54 |
# File 'lib/processing/image.rb', line 52 def filter(*args) @filter = Shader.createFilter__(*args) end |
#height ⇒ Numeric Also known as: h
Gets height of image.
27 28 29 |
# File 'lib/processing/image.rb', line 27 def height() @image.height end |
#resize(width, height) ⇒ nil
Resizes image.
63 64 65 66 67 68 |
# File 'lib/processing/image.rb', line 63 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.
121 122 123 |
# File 'lib/processing/image.rb', line 121 def save(filename) @image.save filename end |
#size ⇒ Array<Numeric>
Returns the width and height of image.
38 39 40 |
# File 'lib/processing/image.rb', line 38 def size() @image.size end |
#width ⇒ Numeric Also known as: w
Gets width of image.
19 20 21 |
# File 'lib/processing/image.rb', line 19 def width() @image.width end |