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

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.

Parameters

Return

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

Example

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

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)

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)

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()

GetKeyIterator()

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

Return

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

Example

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

GetNonzero()

This action returns the current nonzero value of the line.

Return

integer: Returns the current nonzero value of the line.

Example

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

GetXInterceptAtY(integer y)

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

Parameters

  • integer y: The y-coordinate to get the x-intercepts of.

Return

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

Example

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

GetXIntercepts()

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

Return

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

Example

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

GetYMaximum()

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

Return

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

Example

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

GetYMinimum()

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

Return

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

Example

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

HasY(integer y)

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

Parameters

  • integer y: The y-coordinate to check if it is present in the hash table.

Return

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

Example

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

SetNonzero(integer nonzero)

This action sets the current nonzero value of the line.

Parameters

  • integer nonzero: The nonzero value of the line.

Example

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

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.

Parameters

Example

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

SetYMaximum(integer yMax)

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

Parameters

  • integer yMax: The highest point of the glyph, on the y-axis.

Example

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

SetYMinimum(integer yMin)

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

Parameters

  • integer yMin: The lowest point of the glyph, on the y-axis.

Example

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

XInterceptsToText(integer y)

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

Parameters

  • integer y: The y-coordinate to get the x-intercepts of.

Return

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

Example

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