Skip to content

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.

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.

ReturnsSignatureSummary
ColorGradientof(Color startColor, Color endColor, Point startPoint, Point endPoint) factoryCreates 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).

ReturnsSignatureSummary
voiduse(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.
voiduse(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.
ColorgetStartColor()Returns the color at the start point and before it.
ColorgetEndColor()Returns the color at the end point and after it.
PointgetStartPoint()Returns the start point, on 1 of the drawn area.
PointgetEndPoint()Returns the end point, on 1 of the drawn area.
booleanequals(Object other)If true, the other object is of the same class with the same colors and points.
inthashCode()Returns a hash of the values that equals compares.

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

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.


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

Report a problem with this page