Libraries.Game.Graphics.Fonts.Line Documentation

The Line class is used to calculate the lines that need to be drawn to fill in a glyph's outline, including the points that fall on the outline itself. It scans the glyph line by line on the y-axis to find where the glyph outline begins and ends, and sets the x-intercepts accordingly. These x-intercepts/y-coordinate pairs are used in the rasterization process.

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
        Line line
        HashTable<integer, XCoordinateList> list
        // Gets the x-intercepts for a line where the pixel size is 14,
        // EM size is 2048, the vertical resolution is 1080, and the nonzero
        // value is currently 0.
        list = line:GetXInterceptsNumber(14, 14, 2048, 1080, 0)
    end
end

Inherits from: Libraries.Language.Object

Actions Documentation

CalculateCoordinate(integer gridCoordinate, integer pixelSize, integer emSize, integer screenSize)

This action calculates and returns the scaled coordinate position of a coordinate, as an integer.

Parameters

  • integer gridCoordinate: The coordinate to scale.
  • integer pixelSize: The size of a pixel on the display.
  • integer emSize: The EM size of the font.
  • integer screenSize: The screen size of the display.

Return

integer: Returns the scaled coordinate position of a coordinate, as an integer.

Example

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

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        Line line
        output line:CalculateCoordinate(100, 12, 2048, 1080)
    end
end

CalculateCoordinateNumber(integer gridCoordinate, integer pixelSize, integer emSize, integer screenSize)

This action calculates and returns the scaled coordinate position of a coordinate, as a number.

Parameters

  • integer gridCoordinate: The coordinate to scale.
  • integer pixelSize: The size of a pixel on the display.
  • integer emSize: The EM size of the font.
  • integer screenSize: The screen size of the display.

Return

number: Returns the scaled coordinate position of a coordinate, as a number.

Example

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

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        Line line
        output line:CalculateCoordinateNumber(100, 12, 2048, 1080)
    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()

GetX1()

This action returns the starting x-coordinate of the line.

Return

integer: Returns the starting x-coordinate of the line.

Example

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

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        Line line
        output line:GetX1()
    end
end

GetX2()

This action returns the ending x-coordinate of the line.

Return

integer: Returns the ending x-coordinate of the line.

Example

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

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        Line line
        output line:GetX2()
    end
end

GetXInterceptsNumber(integer xPixelSize, integer yPixelSize, integer unitsPerEM, integer yScreenSize, integer oldNonZero)

This action finds all of the x-intercepts for a scanline along the y-axis, and then returns a hash table of these intercepts.

Parameters

  • integer xPixelSize: The pixel size of the display on the x-axis.
  • integer yPixelSize: The pixel size of the display on the y-axis.
  • integer unitsPerEM: The EM size of the font.
  • integer yScreenSize: The vertical resolution of the display.
  • integer oldNonZero: The previous nonzero value of the line.

Return

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

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
        Line line
        HashTable<integer, XCoordinateList> list
        // Gets the x-intercepts for a line where the pixel size is 14,
        // EM size is 2048, the vertical resolution is 1080, and the nonzero
        // value is currently 0.
        list = line:GetXInterceptsNumber(14, 14, 2048, 1080, 0)
    end
end

GetY1()

This action returns the starting y-coordinate of the line.

Return

integer: Returns the starting y-coordinate of the line.

Example

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

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        Line line
        output line:GetY1()
    end
end

GetY2()

This action returns the ending y-coordinate of the line.

Return

integer: Returns the ending y-coordinate of the line.

Example

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

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        Line line
        output line:GetY2()
    end
end

SetPoint1(integer x, integer y)

This action sets the starting coordinates of the line.

Parameters

  • integer x: The x-coordinate of the starting position.
  • integer y: The y-coordinate of the starting position.

Example

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

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        Line line
        line:SetPoint1(0, 0)
    end
end

SetPoint2(integer x, integer y)

This action sets the ending coordinates of the line.

Parameters

  • integer x: The x-coordinate of the ending position.
  • integer y: The y-coordinate of the ending position.

Example

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

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        Line line
        line:SetPoint2(10, 10)
    end
end

SetX1(integer x)

This action sets the starting x-coordinate of the line.

Parameters

  • integer x: The starting x-coordinate of the line.

Example

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

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        Line line
        line:SetX1(0)
    end
end

SetX2(integer x)

This action sets the ending x-coordinate of the line.

Parameters

  • integer x: The ending x-coordinate of the line.

Example

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

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        Line line
        line:SetX2(10)
    end
end

SetY1(integer y)

This action sets the starting y-coordinate of the line.

Parameters

  • integer y: The starting y-coordinate of the line.

Example

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

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        Line line
        line:SetY1(0)
    end
end

SetY2(integer y)

This action sets the ending y-coordinate of the line.

Parameters

  • integer y: The ending y-coordinate of the line.

Example

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

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        Line line
        line:SetY2(10)
    end
end

ToText()

This action returns the starting and ending coordinate positions of the line as text, in ordered pair form (x, y).

Return

text: Returns the starting and ending coordinate positions of the line as text.

Example

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

class Main is Game
    action Main
        StartGame()
    end

    action CreateGame
        Line line
        output line:ToText()
    end
end