Class: Image

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(width, height, mipmaps, format) ⇒ Image

Creates a new instance of Image

Parameters:

  • width (Integer)
  • height (Integer)
  • mipmaps (Integer)
  • format (Integer)


12
13
14
15
16
# File 'mrb_doc/models/image.rb', line 12

def initialize(width, height, mipmaps, format)
  # mrb_Image_initialize
  # src/mruby_integration/models/image.cpp
  Image.new
end

Instance Attribute Details

#formatInteger

Returns:

  • (Integer)


4
5
6
# File 'mrb_doc/models/image.rb', line 4

def format
  @format
end

#heightInteger

Returns:

  • (Integer)


4
5
6
# File 'mrb_doc/models/image.rb', line 4

def height
  @height
end

#mipmapsInteger

Returns:

  • (Integer)


4
5
6
# File 'mrb_doc/models/image.rb', line 4

def mipmaps
  @mipmaps
end

#widthInteger

Returns:

  • (Integer)


4
5
6
# File 'mrb_doc/models/image.rb', line 4

def width
  @width
end

Class Method Details

.generate(width:, height:, colour: RAYWHITE) ⇒ Image

Generates a new image of width by height in the specified colour.

Parameters:

  • width (Integer)
  • height (Integer)
  • colour (Colour) (defaults to: RAYWHITE)

Returns:



232
233
234
235
# File 'mrb_doc/models/image.rb', line 232

def self.generate(width:, height:, colour: RAYWHITE)
  # src/mruby_integration/models/image.cpp
  Image.new
end

.load(path) ⇒ Image

Loads an image from the specified path

Parameters:

  • path (String)

Returns:

Raises:



66
67
68
69
# File 'mrb_doc/models/image.rb', line 66

def self.load(path)
  # src/mruby_integration/models/image.cpp
  Image.new
end

Instance Method Details

#alpha_mask=(mask) ⇒ Image

Applies the alpha of the mask to the image

Parameters:

Returns:



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

Parameters:

  • brightness (Float)

    a value between -255 and 255

Returns:

  • (nil)

Raises:

  • (ArgumentError)

    If the brightness is outside of the allowed range



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

Parameters:

  • contrast (Float)

    a value between -100 and 100

Returns:

  • (nil)

Raises:

  • (ArgumentError)

    If the contrast is outside of the allowed range



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.

Parameters:

Returns:



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

Parameters:

Returns:



116
117
118
119
# File 'mrb_doc/models/image.rb', line 116

def crop!(rectangle)
  # src/mruby_integration/models/image.cpp
  self
end

#dataArray<Colour>

Returns an array containing the image data as an array of Colour objects

Returns:



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.

Parameters:

  • image (Image)
  • source (Rectangle) (defaults to: nil)

    if left blank, will use the whole image

  • destination (Rectangle) (defaults to: nil)

    if left blank, will draw into the top left corner

  • colour (Colour) (defaults to: WHITE)

    if left blank, no tinting is applied

Returns:

  • (nil)


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

Parameters:

  • path (String)

Returns:

  • (nil)


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

Returns:



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

Returns:



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

Returns:



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

Returns:

  • (nil)


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

Returns:

  • (nil)


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

Returns:



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

Parameters:

Returns:

  • (nil)


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.

Parameters:

  • width (Integer)
  • height (Integer)
  • scaling (Symbol) (defaults to: :nearest_neighbour)

    Valid options are :nearest_neighbour and :bicubic

Returns:



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

Parameters:

  • Valid (direction)

    options are :cw and :ccw

Returns:

Raises:

  • (ArgumentError)

    If the direction is invalid



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

Parameters:

Returns:

  • (nil)


169
170
171
172
# File 'mrb_doc/models/image.rb', line 169

def tint!(colour)
  # src/mruby_integration/models/image.cpp
  self
end

#to_hHash

Return the object represented by a Hash

Returns:

  • (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_textureTexture2D

Returns a texture of the image

Returns:



97
98
99
100
# File 'mrb_doc/models/image.rb', line 97

def to_texture
  # src/mruby_integration/models/image.cpp
  Texture2D.new
end

#unloadnil

Unloads the texture from memory

Returns:

  • (nil)


73
74
75
76
# File 'mrb_doc/models/image.rb', line 73

def unload
  # src/mruby_integration/models/image.cpp
  nil
end