GradientBox
This page talks about GradientBox
This page talks about GradientBox
The class provides functionality for creating and displaying gradient boxes in Minecraft Fabric.
size
: The size of the gradient box.
selectedWidget
: The widget that this gradient box is associated with.
x
: The x position of the gradient box.
y
: The y position of the gradient box.
hue
: The hue of the gradient box.
saturation
: The saturation of the gradient box.
value
: The value of the gradient box.
isDragging
: Whether the handle of the gradient box is currently being dragged.
Constructs a GradientBox
object with the given position, size, and selected widget.
Updates the alpha of the gradient box.
Renders this gradient box on screen.
Sets the position of this gradient box.
Handles mouse clicks on this gradient box. This method sets the dragging state to true if the mouse is over the handle and the left mouse button was clicked. It also updates the saturation and value of the gradient box based on the mouse position if the mouse is over the gradient box.
Returns whether the mouse is currently over this gradient box.
Handles mouse release events on this gradient box. This method stops dragging or scaling the handle.
Handles mouse dragging on this gradient box. This method updates the saturation and value of the gradient box based on the mouse position if the handle is being dragged.
Sets the hue of this gradient box.
Sets the saturation of this gradient box.
Sets the value of this gradient box.
Returns the current color of this gradient box as an RGB integer.
In this example, we create a new GradientBox
with a position of (10, 10) and a size of 100 pixels. We then render the GradientBox
on screen using its render
method. We also handle mouse input by calling its onClick
, onDrag
, and onRelease
methods.
Finally, we get and set values for hue, saturation, and value using its getter and setter methods.
The GradientBox is already called and present in . But if you still want to add it yourself somewhere you can do it by: