ColorGradient
final class ColorGradient
Package: dev.joid.lib.color · Module: core · Source: ColorGradient.java
The two stops and the direction of a linear gradient, carried by a gradient Color.
Description
Section titled “Description”You rarely build one yourself: Color.toGradient and Color.decode with gradient(...) create the gradient color for you.
The points are on 1 of the drawn area, so the same gradient fits a node of any size.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
ColorGradient | of(Color startColor, Color endColor, Point startPoint, Point endPoint) factory | Creates a gradient from startColor at startPoint to endColor at endPoint, both points on 1 of the drawn area ((0, 0) to (1, 0) runs from left to right). |
Methods
Section titled “Methods”| Returns | Signature | Summary |
|---|---|---|
void | use(Runnable runnable, BoundingBox canvas) | Runs runnable with the gradient shader bound and spread over canvas, in the coordinates you draw in, then restores the previous shader. |
void | use(boolean hasTexture, Runnable runnable, BoundingBox canvas) | Runs runnable with the gradient shader bound over canvas, then restores the previous shader; if hasTexture is true, the gradient multiplies the bound texture instead of replacing it. |
Color | getStartColor() | Returns the color at the start point and before it. |
Color | getEndColor() | Returns the color at the end point and after it. |
Point | getStartPoint() | Returns the start point, on 1 of the drawn area. |
Point | getEndPoint() | Returns the end point, on 1 of the drawn area. |
boolean | equals(Object other) | If true, the other object is of the same class with the same colors and points. |
int | hashCode() | Returns a hash of the values that equals compares. |
Creation details
Section titled “Creation details”ColorGradient of(Color startColor, Color endColor, Point startPoint, Point endPoint) factory
Creates a gradient from startColor at startPoint to endColor at endPoint, both points on 1 of the drawn area ((0, 0) to (1, 0) runs from left to right).
Method details
Section titled “Method details”void use(Runnable runnable, BoundingBox canvas)
Runs runnable with the gradient shader bound and spread over canvas, in the coordinates you draw in, then restores the previous shader.
void use(boolean hasTexture, Runnable runnable, BoundingBox canvas)
Runs runnable with the gradient shader bound over canvas, then restores the previous shader; if hasTexture is true, the gradient multiplies the bound texture instead of replacing it.
getStartColor
Section titled “getStartColor”Color getStartColor()
Returns the color at the start point and before it.
getEndColor
Section titled “getEndColor”Color getEndColor()
Returns the color at the end point and after it.
getStartPoint
Section titled “getStartPoint”Point getStartPoint()
Returns the start point, on 1 of the drawn area.
getEndPoint
Section titled “getEndPoint”Point getEndPoint()
Returns the end point, on 1 of the drawn area.
equals
Section titled “equals”boolean equals(Object other)
If true, the other object is of the same class with the same colors and points.
hashCode
Section titled “hashCode”int hashCode()
Returns a hash of the values that equals compares.
fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses
