Method: Processing::GraphicsContext#createImage

Defined in:
lib/processing/graphics_context.rb

#createImage(w, h) ⇒ Image #createImage(w, h, format) ⇒ Image

Creates a new image object.

Parameters:

  • w (Numeric)

    width of new image

  • h (Numeric)

    height of new image

  • format (RGB, RGBA) (defaults to: RGBA)

    image format

Returns:

Raises:

  • (ArgumentError)

See Also:



3215
3216
3217
3218
3219
# File 'lib/processing/graphics_context.rb', line 3215

def createImage(w, h, format = RGBA)
  colorspace = {RGB => Rays::RGB, RGBA => Rays::RGBA}[format]
  raise ArgumentError, "Unknown image format" unless colorspace
  Image.new Rays::Image.new(w, h, colorspace).paint {background 0, 0}
end