Class: Image
- Inherits:
-
Object
- Object
- Image
- Defined in:
- mrb_doc/models/image.rb
Overview
A class for holding image data
Defined Under Namespace
Classes: NotFound
Instance Attribute Summary collapse
Class Method Summary collapse
-
.generate(width:, height:, colour: RAYWHITE) ⇒ Image
Generates a new image of width by height in the specified colour.
-
.load(path) ⇒ Image
Loads an image from the specified path.
Instance Method Summary collapse
-
#alpha_mask=(mask) ⇒ Image
Applies the alpha of the mask to the image.
-
#brightness!(brightness) ⇒ nil
Change the brightness of the image.
-
#contrast!(contrast) ⇒ nil
Change the contrast of the image.
-
#copy(source: nil) ⇒ Image
Copies the image to a new object.
-
#crop!(rectangle) ⇒ Image
Crops the image to the section in the rectangle.
-
#data ⇒ Array<Colour>
Returns an array containing the image data as an array of Colour objects.
-
#draw!(image:, source: nil, destination: nil, colour: WHITE) ⇒ nil
Draws the specified portion of the image into the specified region of the this image.
-
#export(path) ⇒ nil
Exports an image to a file.
-
#flip_horizontal! ⇒ Image
Flips the image sideways.
-
#flip_vertical! ⇒ Image
Flips the image upside down.
-
#generate_mipmaps! ⇒ Image
Generates mipmaps for the image.
-
#grayscale! ⇒ nil
Converts the image to grayscale.
-
#initialize(width, height, mipmaps, format) ⇒ Image
constructor
Creates a new instance of Image.
-
#invert! ⇒ nil
Inverts the colours of the image.
-
#premultiply_alpha! ⇒ Image
Pre-multiplies the alpha for the image.
-
#replace!(old_colour, new_colour) ⇒ nil
Replace the old Colour with the new Colour.
-
#resize!(width:, height:, scaling: :nearest_neighbour) ⇒ Image
Resizes the image, defaults to using the nearest neighbour algorithm which is useful for pixel art.
-
#rotate!(direction = :cw) ⇒ Image
Rotates the image either clockwise or counter-clockwise.
-
#tint!(colour) ⇒ nil
Tints the image with the specified colour.
-
#to_h ⇒ Hash
Return the object represented by a Hash.
-
#to_texture ⇒ Texture2D
Returns a texture of the image.
-
#unload ⇒ nil
Unloads the texture from memory.
Constructor Details
Instance Attribute Details
#format ⇒ Integer
4 5 6 |
# File 'mrb_doc/models/image.rb', line 4 def format @format end |
#height ⇒ Integer
4 5 6 |
# File 'mrb_doc/models/image.rb', line 4 def height @height end |
#mipmaps ⇒ Integer
4 5 6 |
# File 'mrb_doc/models/image.rb', line 4 def mipmaps @mipmaps end |
#width ⇒ Integer
4 5 6 |
# File 'mrb_doc/models/image.rb', line 4 def width @width end |
Class Method Details
Instance Method Details
#alpha_mask=(mask) ⇒ Image
Applies the alpha of the mask to the image
124 125 126 127 |
# File 'mrb_doc/models/image.rb', line 124 def alpha_mask=(mask) # src/mruby_integration/models/image.cpp self end |
#brightness!(brightness) ⇒ nil
Change the brightness of the image
201 202 203 204 |
# File 'mrb_doc/models/image.rb', line 201 def brightness!(brightness) # src/mruby_integration/models/image.cpp self end |
#contrast!(contrast) ⇒ nil
Change the contrast of the image
192 193 194 195 |
# File 'mrb_doc/models/image.rb', line 192 def contrast!(contrast) # src/mruby_integration/models/image.cpp self end |
#copy(source: nil) ⇒ Image
Copies the image to a new object. If source
is specified it’ll only be that section of the image that is returned.
90 91 92 93 |
# File 'mrb_doc/models/image.rb', line 90 def copy(source: nil) # src/mruby_integration/models/image.cpp Image.new end |
#crop!(rectangle) ⇒ Image
Crops the image to the section in the rectangle
116 117 118 119 |
# File 'mrb_doc/models/image.rb', line 116 def crop!(rectangle) # src/mruby_integration/models/image.cpp self end |
#data ⇒ Array<Colour>
Returns an array containing the image data as an array of Colour objects
44 45 46 47 48 |
# File 'mrb_doc/models/image.rb', line 44 def data # mrb_Image_get_data # src/mruby_integration/models/image.cpp [Colour.new] end |
#draw!(image:, source: nil, destination: nil, colour: WHITE) ⇒ nil
Draws the specified portion of the image into the specified region of the this image.
222 223 224 225 |
# File 'mrb_doc/models/image.rb', line 222 def draw!(image:, source: nil, destination: nil, colour: WHITE) # src/mruby_integration/models/image.cpp self end |
#export(path) ⇒ nil
Exports an image to a file
81 82 83 84 |
# File 'mrb_doc/models/image.rb', line 81 def export(path) # src/mruby_integration/models/image.cpp nil end |
#flip_horizontal! ⇒ Image
Flips the image sideways
152 153 154 155 |
# File 'mrb_doc/models/image.rb', line 152 def flip_horizontal! # src/mruby_integration/models/image.cpp self end |
#flip_vertical! ⇒ Image
Flips the image upside down
138 139 140 141 |
# File 'mrb_doc/models/image.rb', line 138 def flip_vertical! # src/mruby_integration/models/image.cpp self end |
#generate_mipmaps! ⇒ Image
Generates mipmaps for the image
145 146 147 148 |
# File 'mrb_doc/models/image.rb', line 145 def generate_mipmaps! # src/mruby_integration/models/image.cpp self end |
#grayscale! ⇒ nil
Converts the image to grayscale
183 184 185 186 |
# File 'mrb_doc/models/image.rb', line 183 def grayscale! # src/mruby_integration/models/image.cpp self end |
#invert! ⇒ nil
Inverts the colours of the image
176 177 178 179 |
# File 'mrb_doc/models/image.rb', line 176 def invert! # src/mruby_integration/models/image.cpp self end |
#premultiply_alpha! ⇒ Image
Pre-multiplies the alpha for the image
131 132 133 134 |
# File 'mrb_doc/models/image.rb', line 131 def premultiply_alpha! # src/mruby_integration/models/image.cpp self end |
#replace!(old_colour, new_colour) ⇒ nil
Replace the old Colour with the new Colour
210 211 212 213 |
# File 'mrb_doc/models/image.rb', line 210 def replace!(old_colour, new_colour) # src/mruby_integration/models/image.cpp self end |
#resize!(width:, height:, scaling: :nearest_neighbour) ⇒ Image
Resizes the image, defaults to using the nearest neighbour algorithm which is useful for pixel art.
108 109 110 111 |
# File 'mrb_doc/models/image.rb', line 108 def resize!(width:, height:, scaling: :nearest_neighbour) # src/mruby_integration/models/image.cpp self end |
#rotate!(direction = :cw) ⇒ Image
Rotates the image either clockwise or counter-clockwise
161 162 163 164 |
# File 'mrb_doc/models/image.rb', line 161 def rotate!(direction = :cw) # src/mruby_integration/models/image.cpp self end |
#tint!(colour) ⇒ nil
Tints the image with the specified colour
169 170 171 172 |
# File 'mrb_doc/models/image.rb', line 169 def tint!(colour) # src/mruby_integration/models/image.cpp self end |
#to_h ⇒ Hash
Return the object represented by a Hash
52 53 54 55 56 57 58 59 60 |
# File 'mrb_doc/models/image.rb', line 52 def to_h # src/mruby_integration/models/image.cpp { width: width, height: height, mipmaps: mipmaps, format: format, } end |
#to_texture ⇒ Texture2D
Returns a texture of the image
97 98 99 100 |
# File 'mrb_doc/models/image.rb', line 97 def to_texture # src/mruby_integration/models/image.cpp Texture2D.new end |
#unload ⇒ nil
Unloads the texture from memory
73 74 75 76 |
# File 'mrb_doc/models/image.rb', line 73 def unload # src/mruby_integration/models/image.cpp nil end |