Libraries.Game.Graphics.Fonts.GlyphProfile Documentation

The GlyphProfile class is used to maintain information about a glyph's outline which is used in the rasterization process. Specifically, it saves the maximum and minimum y values of the glyph, which is the range of performing scanlines for the glyph, as well as where a given y-coordinate intersects with the glyph outline, which are the x-intercepts.

Example Code

use Libraries.Game.Graphics.Fonts.all
    use Libraries.Game.Game

    class Main is Game
        action Main
            StartGame()
        end

        action CreateGame
            XCoordinateList item
            PixelIntersection intersection
            GlyphProfile glyphProfile
            intersection:SetXPosition(0)
            intersection:SetIntensity(1)
            item:Add(intersection)
            // This will add an x-intercept for y = 0, where it intercepts
            // the outline at x = 0
            glyphProfile:AddCoordinatesAt(0, item)
        end
    end

Inherits from: Libraries.Language.Object

Summary

Actions Summary Table

ActionsDescription
AddCoordinatesAt(integer y, Libraries.Game.Graphics.Fonts.XCoordinateList coordinates)This action adds a list of x-intercepts for the given y-coordinate to the hash table.
Compare(Libraries.Language.Object object)This action compares two object hash codes and returns an integer.
Equals(Libraries.Language.Object object)This action determines if two objects are equal based on their hash code values.
GetHashCode()This action gets the hash code for an object.
GetKeyIterator()This action returns an iterator for the hash table of x-intercepts.
GetNonzero()This action returns the current nonzero value of the line.
GetXInterceptAtY(integer y)This action returns all of the x-intercepts for the given y-coordinate.
GetXIntercepts()This action returns the hash table of x-intercepts and their corresponding y-coordinate values.
GetYMaximum()This action returns the highest point of the glyph, on the y-axis.
GetYMinimum()This action returns the lowest point of the glyph, on the y-axis.
HasY(integer y)This action checks if a given y-coordinate has x-intercepts mapped to it in the hash table.
SetNonzero(integer nonzero)This action sets the current nonzero value of the line.
SetXIntercepts(Libraries.Containers.HashTable<integer:Libraries.Game.Graphics.Fonts.CoordinateContainer> intercepts)This action sets the x-intercepts hash table.
SetYMaximum(integer yMax)This action sets the highest point of the glyph, on the y-axis.
SetYMinimum(integer yMin)This action sets the lowest point of the glyph, on the y-axis.
XInterceptsToText(integer y)This action returns the x-intercepts for a given y-coordinate as text.

Actions Documentation

AddCoordinatesAt(integer y, Libraries.Game.Graphics.Fonts.XCoordinateList coordinates)

This action adds a list of x-intercepts for the given y-coordinate to the hash table.

Example Code

use Libraries.Game.Graphics.Fonts.all
        use Libraries.Game.Game

        class Main is Game
            action Main
                StartGame()
            end

            action CreateGame
                GlyphProfile glyphProfile
                XCoordinateList coordinates
                glyphProfile:AddCoordinatesAt(0, coordinates)
            end
        end

Parameters

Return

boolean: Returns true once the x-intercepts have been added to the hash table for the specified y-value.

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.

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.

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.

GetKeyIterator()

This action returns an iterator for the hash table of x-intercepts.

Example Code

use Libraries.Game.Graphics.Fonts.all
        use Libraries.Game.Game

        class Main is Game
            action Main
                StartGame()
            end

            action CreateGame
                GlyphProfile glyphProfile
                Iterator<integer> iterator = glyphProfile:GetKeyIterator()
            end
        end

Return

Libraries.Containers.Iterator: Returns an iterator for the hash table of x-intercepts.

GetNonzero()

This action returns the current nonzero value of the line.

Example Code

use Libraries.Game.Graphics.Fonts.all
        use Libraries.Game.Game

        class Main is Game
            action Main
                StartGame()
            end

            action CreateGame
                GlyphProfile glyphProfile
                output glyphProfile:GetNonzero()
            end
        end

Return

integer: Returns the current nonzero value of the line.

GetXInterceptAtY(integer y)

This action returns all of the x-intercepts for the given y-coordinate.

Example Code

use Libraries.Game.Graphics.Fonts.all
        use Libraries.Game.Game

        class Main is Game
            action Main
                StartGame()
            end

            action CreateGame
                GlyphProfile glyphProfile
                CoordinateContainer intercepts
                intercepts = glyphProfile:GetXInterceptAtY(0)
            end
        end

Parameters

Return

Libraries.Game.Graphics.Fonts.CoordinateContainer: Returns the x-intercepts of the given y-coordinate.

GetXIntercepts()

This action returns the hash table of x-intercepts and their corresponding y-coordinate values.

Example Code

use Libraries.Game.Graphics.Fonts.all
        use Libraries.Game.Game
        use Libraries.Containers.HashTable

        class Main is Game
            action Main
                StartGame()
            end

            action CreateGame
                GlyphProfile glyphProfile
                HashTable<integer, CoordinateContainer> intercepts = glyphProfile:GetXIntercepts()
            end
        end

Return

Libraries.Containers.HashTable: Returns the hash table of x-intercepts.

GetYMaximum()

This action returns the highest point of the glyph, on the y-axis.

Example Code

use Libraries.Game.Graphics.Fonts.all
        use Libraries.Game.Game

        class Main is Game
            action Main
                StartGame()
            end

            action CreateGame
                GlyphProfile glyphProfile
                output glyphProfile:GetYMaximum()
            end
        end

Return

integer: Returns the highest point of the glyph, on the y-axis.

GetYMinimum()

This action returns the lowest point of the glyph, on the y-axis.

Example Code

use Libraries.Game.Graphics.Fonts.all
        use Libraries.Game.Game

        class Main is Game
            action Main
                StartGame()
            end
            
            action CreateGame
                GlyphProfile glyphProfile
                output glyphProfile:GetYMinimum()
            end
        end

Return

integer: Returns the lowest point of the glyph, on the y-axis.

HasY(integer y)

This action checks if a given y-coordinate has x-intercepts mapped to it in the hash table.

Example Code

use Libraries.Game.Graphics.Fonts.all
        use Libraries.Game.Game

        class Main is Game
            action Main
                StartGame()
            end

            action CreateGame
                GlyphProfile glyphProfile
                output glyphProfile:HasY(0) 
            end
        end

Parameters

Return

boolean: Returns true if the y-coordinate is in the hash table, and false if it is not.

SetNonzero(integer nonzero)

This action sets the current nonzero value of the line.

Example Code

use Libraries.Game.Graphics.Fonts.all
        use Libraries.Game.Game

        class Main is Game
            action Main
                StartGame()
            end

            action CreateGame
                GlyphProfile glyphProfile
                glyphProfile:SetNonzero(1)
            end
        end

Parameters

SetXIntercepts(Libraries.Containers.HashTable<integer:Libraries.Game.Graphics.Fonts.CoordinateContainer> intercepts)

This action sets the x-intercepts hash table. Each y-coordinate of the glyph is used as a key to map to its x-intercepts.

Example Code

use Libraries.Game.Graphics.Fonts.all
        use Libraries.Game.Game
        use Libraries.Containers.HashTable

        class Main is Game
            action Main
                StartGame()
            end

            action CreateGame
                GlyphProfile glyphProfile
                HashTable<integer, CoordinateContainer> intercepts
                glyphProfile:SetXIntercepts(intercepts)
            end
        end

Parameters

SetYMaximum(integer yMax)

This action sets the highest point of the glyph, on the y-axis.

Example Code

use Libraries.Game.Graphics.Fonts.all
        use Libraries.Game.Game

        class Main is Game
            action Main
                StartGame()
            end

            action CreateGame
                GlyphProfile glyphProfile
                glyphProfile:SetYMaximum(10)
            end
        end

Parameters

SetYMinimum(integer yMin)

This action sets the lowest point of the glyph, on the y-axis.

Example Code

use Libraries.Game.Graphics.Fonts.all
        use Libraries.Game.Game

        class Main is Game
            action Main
                StartGame()
            end

            action CreateGame
                GlyphProfile glyphProfile
                glyphProfile:SetYMinimum(10)
            end
        end

Parameters

XInterceptsToText(integer y)

This action returns the x-intercepts for a given y-coordinate as text.

Example Code

use Libraries.Game.Graphics.Fonts.all
        use Libraries.Game.Game

        class Main is Game
            action Main
                StartGame()
            end

            action CreateGame
                GlyphProfile glyphProfile
                output glyphProfile:XInterceptsToText(0)
            end
        end

Parameters

Return

text: Returns the x-intercepts for the y-coordinate as text.