Libraries.Game.Graphics.ColorGroup Documentation
The ColorGroup class represents how color is mapped onto an object's face at four corners (top left, top right, bottom left, and bottom right). This provides a common interface for simple colors (which use the same hue in all four corners), gradients (potentially different colors in each corner), and other color mapping schemes.
Example Code
use Libraries.Game.Game
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.ColorGroup
use Libraries.Game.Graphics.Gradient
use Libraries.Game.Graphics.Drawable
class Main is Game
// We'll set this with our "SetColorGroup" action.
ColorGroup group = undefined
action Main
StartGame()
end
action CreateGame
Color color
color:SetColor(1.0, 1.0, 0.5, 1.0)
Gradient gradient
gradient:Set(color:Red(), color:Blue(), color:Green(), color:White())
// We could use either color or gradient in our action, because both
// inherit from ColorGroup. We'll use the gradient here.
SetColorGroup(gradient)
Drawable drawable
// LoadFilledRectangle can use a ColorGroup object to determine what
// color the rectangle should be.
drawable:LoadFilledRectangle(100, 100, group)
Add(drawable)
end
action SetColorGroup(ColorGroup colorGroup)
group = colorGroup
end
end
Inherits from: Libraries.Language.Object
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
- Libraries.Language.Object: The object to compare to.
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
- Libraries.Language.Object: The to be compared.
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)
GetBottomLeft()
This action returns what color is applied to the bottom left corner of an object which is using this ColorGroup.
Return
Libraries.Game.Graphics.Color: The color in the bottom-left corner of this ColorGroup.
Example
use Libraries.Game.Game
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.Gradient
class Main is Game
action Main
StartGame()
end
action CreateGame
Color color
// Gradient inherits from ColorGroup.
Gradient gradient
gradient:Set(color:Red(), color:Blue(), color:Green(), color:Gray())
Color corner = gradient:GetBottomLeft()
output "The color's values are: " + corner:GetRed() + ", " + corner:GetBlue() + ", " + corner:GetGreen() + ", " + corner:GetAlpha()
end
end
GetBottomRight()
This action returns what color is applied to the bottom right corner of an object which is using this ColorGroup.
Return
Libraries.Game.Graphics.Color: The color in the bottom-right corner of this ColorGroup.
Example
use Libraries.Game.Game
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.Gradient
class Main is Game
action Main
StartGame()
end
action CreateGame
Color color
// Gradient inherits from ColorGroup.
Gradient gradient
gradient:Set(color:Red(), color:Blue(), color:Green(), color:Gray())
Color corner = gradient:GetBottomRight()
output "The color's values are: " + corner:GetRed() + ", " + corner:GetBlue() + ", " + corner:GetGreen() + ", " + corner:GetAlpha()
end
end
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()
GetTopLeft()
This action returns what color is applied to the top left corner of an object which is using this ColorGroup.
Return
Libraries.Game.Graphics.Color: The color in the top-left corner of this ColorGroup.
Example
use Libraries.Game.Game
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.Gradient
class Main is Game
action Main
StartGame()
end
action CreateGame
Color color
// Gradient inherits from ColorGroup.
Gradient gradient
gradient:Set(color:Red(), color:Blue(), color:Green(), color:Gray())
Color corner = gradient:GetTopLeft()
output "The color's values are: " + corner:GetRed() + ", " + corner:GetBlue() + ", " + corner:GetGreen() + ", " + corner:GetAlpha()
end
end
GetTopRight()
This action returns what color is applied to the top right corner of an object which is using this ColorGroup.
Return
Libraries.Game.Graphics.Color: The color in the top-right corner of this ColorGroup.
Example
use Libraries.Game.Game
use Libraries.Game.Graphics.Color
use Libraries.Game.Graphics.Gradient
class Main is Game
action Main
StartGame()
end
action CreateGame
Color color
// Gradient inherits from ColorGroup.
Gradient gradient
gradient:Set(color:Red(), color:Blue(), color:Green(), color:Gray())
Color corner = gradient:GetTopRight()
output "The color's values are: " + corner:GetRed() + ", " + corner:GetBlue() + ", " + corner:GetGreen() + ", " + corner:GetAlpha()
end
end