Libraries.Game.Graphics.PixelMap Documentation

The PixelMap class represents an image as a collection of individual pixels. It is used by the Texture class to draw shapes and load images from files. This is a class used internally by the game engine, and most users will not need to interface with this class directly.

Inherits from: Libraries.Language.Object, Libraries.Game.Disposable

Actions Documentation

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Example

Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

CreatePixelMap(integer newWidth, integer newHeight, Libraries.Game.Graphics.Format newFormat)

This action will create new PixelMap data to be used in OpenGL with the given width, height, and Format.

Parameters

Define2DImage(integer target, integer mipLevel, integer border)

This action will create OpenGL information for the currently loaded PixelMap information.

Parameters

  • integer target
  • integer mipLevel
  • integer border

Dispose()

This action will free up the memory used to store the pixel information of the image. This should only be used when the PixelMap is no longer needed.

DrawCircle(integer x, integer y, integer radius, Libraries.Game.Graphics.Color color)

This action will draw a hollow circle at the given point with the given radius using the given color.

Parameters

DrawCircle(integer x, integer y, integer radius, integer color)

This action will draw a hollow circle at the given point with the given radius using the given color code.

Parameters

  • integer x
  • integer y
  • integer radius
  • integer color

DrawLine(integer x1, integer y1, integer x2, integer y2, Libraries.Game.Graphics.Color color)

This action will draw a line on the PixelMap between the two points given using the given color.

Parameters

DrawLine(integer x1, integer y1, integer x2, integer y2, integer color)

This action will draw a line on the PixelMap between the two points given using the given color code.

Parameters

  • integer x1
  • integer y1
  • integer x2
  • integer y2
  • integer color

DrawPixelMap(Libraries.Game.Graphics.PixelMap pixmap, integer sourceX, integer sourceY, integer destX, integer destY, integer sourceWidth, integer sourceHeight)

This action will draw a different PixelMap starting from the destX and destY with sourceWidth and sourceHeight on top of this PixelMap at the coordinates of sourceX, sourceY.

Parameters

DrawPixelMap(Libraries.Game.Graphics.PixelMap pixmap, integer x, integer y)

This action takes a different PixelMap and draws it on top of this PixelMap at the given x,y coordinates on this PixelMap.

Parameters

DrawRectangle(integer x, integer y, integer width, integer height, Libraries.Game.Graphics.Color color)

This action will draw a hollow rectangle at the given point with the given width and height using the given color.

Parameters

DrawRectangle(integer x, integer y, integer width, integer height, integer color)

This action will draw a hollow rectangle at the given point with the given width and height using the given color code.

Parameters

  • integer x
  • integer y
  • integer width
  • integer height
  • integer color

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Example

use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)

Fill(integer color)

This action will fill the complete bitmap with the given color code.

Parameters

  • integer color

Fill(Libraries.Game.Graphics.Color color)

This action will fill the complete bitmap with the given color.

Parameters

FillCircle(integer x, integer y, integer radius, integer color)

This action will draw a solid circle at the given point with the given radius using the given color code.

Parameters

  • integer x
  • integer y
  • integer radius
  • integer color

FillCircle(integer x, integer y, integer radius, Libraries.Game.Graphics.Color color)

This action will draw a solid circle at the given point with the given radius using the given color.

Parameters

FillRectangle(integer x, integer y, integer width, integer height, Libraries.Game.Graphics.Color color)

This action will draw a solid rectangle at the given point with the given width and height using the given color.

Parameters

FillRectangle(integer x, integer y, integer width, integer height, integer color)

This action will draw a solid rectangle at the given point with the given width and height using the given color code.

Parameters

  • integer x
  • integer y
  • integer width
  • integer height
  • integer color

FillTriangle(integer x1, integer y1, integer x2, integer y2, integer x3, integer y3, integer color)

This action will draw a solid triangle using the three given points and the given color.

Parameters

  • integer x1
  • integer y1
  • integer x2
  • integer y2
  • integer x3
  • integer y3
  • integer color

FillTriangle(integer x1, integer y1, integer x2, integer y2, integer x3, integer y3, Libraries.Game.Graphics.Color color)

This action will draw a solid triangle using the three given points and the given color.

Parameters

GetBlending()

This action will return the Blending being used on this PixelMap.

Return

Libraries.Game.Graphics.Blending:

GetColor()

Returns the color being applied to this PixelMap.

Return

Libraries.Game.Graphics.Color:

GetFormat()

Returns the Format that is used by this PixelMap.

Return

Libraries.Game.Graphics.Format:

GetGLInternalFormat()

This action returns an integer value representing the internal GL format.

Return

integer:

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()

GetHeight()

Returns the height of this PixelMap.

Return

integer:

GetPixel(integer x, integer y)

This action will return an integer color code representing the color of the pixel at the given coordinates.

Parameters

  • integer x
  • integer y

Return

integer:

GetWidth()

Returns the width of this PixelMap.

Return

integer:

LoadAsynchronously(Libraries.System.File file, Libraries.Game.Graphics.Format format, boolean useMipMaps, Libraries.Game.Graphics.Drawable drawable, Libraries.Game.Graphics.Texture texture)

This action will asynchronously load the PixelMap (that is, it will be loaded separately from the rest of the program's execution) and then it will be loaded into the provided Texture, which will be used to load the provided Drawable (if it is not undefined). This is only needed for use on the web, and when loading Drawables or Textures directly via files or file paths, it is called automatically. Most users will never need to use this action directly.

Parameters

LoadMatrix(Libraries.Compute.Matrix matrix)

This action will load a matrix into the PixelMap to create a monochrome (black and white) image. Each value is assumed to be between 0 and 1, where 0 represents a black pixel and 1 represents a white pixel.

Parameters

Example

use Libraries.Game.Game
use Libraries.Game.Graphics.PixelMap
use Libraries.Game.Graphics.Drawable
use Libraries.Game.Graphics.Texture
use Libraries.Compute.Matrix

class Main is Game

    PixelMap pixelMap
    Texture texture
    Drawable drawable

    action Main
        StartGame()
    end

    action CreateGame
        Matrix matrix

        // 7x7 square that is black at edges and lightens as it goes towards the center.
        matrix:Fill(7, 7, 0)
        matrix:Set(1, 1, 0.33)
        matrix:Set(2, 1, 0.33)
        matrix:Set(3, 1, 0.33)
        matrix:Set(4, 1, 0.33)
        matrix:Set(5, 1, 0.33)
        matrix:Set(5, 2, 0.33)
        matrix:Set(5, 3, 0.33)
        matrix:Set(5, 4, 0.33)
        matrix:Set(5, 5, 0.33)
        matrix:Set(4, 5, 0.33)
        matrix:Set(3, 5, 0.33)
        matrix:Set(2, 5, 0.33)
        matrix:Set(1, 5, 0.33)
        matrix:Set(1, 4, 0.33)
        matrix:Set(1, 3, 0.33)
        matrix:Set(1, 2, 0.33)

        matrix:Set(2, 2, 0.66)
        matrix:Set(3, 2, 0.66)
        matrix:Set(4, 2, 0.66)
        matrix:Set(4, 3, 0.66)
        matrix:Set(4, 4, 0.66)
        matrix:Set(3, 4, 0.66)
        matrix:Set(2, 4, 0.66)
        matrix:Set(2, 3, 0.66)

        matrix:Set(3, 3, 1)

        pixelMap:LoadMatrix(matrix)

        // Loading the PixelMap and blowing up the size of the Drawable to make it easier to see.
        texture:LoadFromPixelMap(pixelMap)
        drawable:Load(texture)
        Add(drawable)

        drawable:SetPosition(200, 200)
        drawable:SetSize(100, 100)
    end
end

LoadPixelMap(Libraries.System.File file)

This action will load a PixelMap using an image file.

Parameters

Screenshot(integer x, integer y, integer width, integer height)

This action takes a screenshot of the Game window at the given coordinates and stores it in this PixelMap. Taking screenshots is very timing sensitive and can be unreliable on some platforms (especially the web) if done at the wrong time. It's recommended to use the Game's "Screenshot" action and a ScreenshotListener to reliably take screenshots, instead of using this action.

Parameters

  • integer x
  • integer y
  • integer width
  • integer height

Screenshot()

This action takes a screenshot of the Game window and loads it into this PixelMap. Taking screenshots is very timing sensitive and can be unreliable on some platforms (especially the web) if done at the wrong time. It's recommended to use the Game's "Screenshot" action and a ScreenshotListener to reliably take screenshots, instead of using this action.

SetBlending(Libraries.Game.Graphics.Blending newBlend)

This action will set the Blending to be used for this PixelMap.

Parameters

SetColor(Libraries.Game.Graphics.Color newColor)

Sets the color being used by this PixelMap using a Color object.

Parameters

SetColor(number redValue, number greenValue, number blueValue, number alphaValue)

Sets the color being used by this PixelMap using color component values between 0 and 1 for the red, green, blue, and alpha components.

Parameters

  • number redValue
  • number greenValue
  • number blueValue
  • number alphaValue

SetColorFromCode(integer code)

Sets the color being used by this PixelMap using an integer color code.

Parameters

  • integer code

SetFilter(Libraries.Game.Graphics.Filter filter)

Sets the type of interpolation Filter to be used for this PixelMap.

Parameters

SetPixel(integer x, integer y)

This action will set the pixel at the given coordinates with the PixelMap's current color.

Parameters

  • integer x
  • integer y

SetPixel(integer x, integer y, integer code)

This action will set the pixel at the given coordinates with the given color code.

Parameters

  • integer x
  • integer y
  • integer code

SetPixel(integer x, integer y, Libraries.Game.Graphics.Color setColor)

This action will set the pixel at the given coordinates with the given color.

Parameters

SetScale(integer scale)

This action will set the scaling filter to the given type.

Parameters

  • integer scale