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

Summary

Actions Summary Table

ActionsDescription
Compare(Libraries.Language.Object object)This action compares two object hash codes and returns an integer.
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.
Define2DImage(integer target, integer mipLevel, integer border)This action will create OpenGL information for the currently loaded PixelMap information.
Dispose()This action will free up the memory used to store the pixel information of the image.
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.
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.
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.
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.
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.
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.
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.
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.
Equals(Libraries.Language.Object object)This action determines if two objects are equal based on their hash code values.
Fill(integer color)This action will fill the complete bitmap with the given color code.
Fill(Libraries.Game.Graphics.Color color)This action will fill the complete bitmap with the given color.
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.
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.
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.
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.
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.
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.
GetBlending()This action will return the Blending being used on this PixelMap.
GetColor()Returns the color being applied to this PixelMap.
GetFormat()Returns the Format that is used by this PixelMap.
GetGLInternalFormat()This action returns an integer value representing the internal GL format.
GetHashCode()This action gets the hash code for an object.
GetHeight()Returns the height of this PixelMap.
GetPixel(integer x, integer y)This action will return an integer color code representing the color of the pixel at the given coordinates.
GetWidth()Returns the width of this PixelMap.
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).
LoadMatrix(Libraries.Compute.Matrix matrix)This action will load a matrix into the PixelMap to create a monochrome (black and white) image.
LoadPixelMap(Libraries.System.File file)This action will load a PixelMap using an image file.
SetBlending(Libraries.Game.Graphics.Blending newBlend)This action will set the Blending to be used for this PixelMap.
SetColor(Libraries.Game.Graphics.Color newColor)Sets the color being used by this PixelMap using a Color object.
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.
SetColorFromCode(integer code)Sets the color being used by this PixelMap using an integer color code.
SetFilter(Libraries.Game.Graphics.Filter filter)Sets the type of interpolation Filter to be used for this PixelMap.
SetPixel(integer x, integer y)This action will set the pixel at the given coordinates with the PixelMap's current color.
SetPixel(integer x, integer y, integer code)This action will set the pixel at the given coordinates with the given color 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.
SetScale(integer scale)This action will set the scaling filter to the given type.

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.

Example Code

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

Parameters

Return

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

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

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

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

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

Equals(Libraries.Language.Object object)

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

Example Code

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

Parameters

Return

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

Fill(integer color)

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

Parameters

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

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

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

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.

Example Code

Object o
        integer hash = o:GetHashCode()

Return

integer: The integer hash code of the object.

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

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.

Example Code

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

Parameters

LoadPixelMap(Libraries.System.File file)

This action will load a PixelMap using an image file.

Parameters

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

SetColorFromCode(integer code)

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

Parameters

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

SetPixel(integer x, integer y, integer code)

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

Parameters

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