GradientSlider
This page talks about GradientSlider
This page talks about GradientSlider
The class provides functionality for creating and displaying gradient sliders in Minecraft Fabric.
width
: The width of the gradient slider.
height
: The height of the gradient slider.
selectedWidget
: The widget that this gradient slider is associated with.
x
: The x position of the gradient slider.
y
: The y position of the gradient slider.
hue
: The hue of the gradient slider.
isDragging
: Whether the handle of the gradient slider is currently being dragged.
Constructs a GradientSlider
object with the given position, size, and selected widget.
Updates the progress and alpha of the gradient slider.
Renders this gradient slider on screen.
Sets the position of this gradient slider.
Handles mouse clicks on this gradient slider. 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 hue of the gradient slider based on the mouse position if the mouse is over the gradient slider.
Returns whether the mouse is currently over this gradient slider.
Handles mouse release events on this gradient slider. This method stops dragging or scaling the handle.
Handles mouse dragging on this gradient slider. This method updates the hue of the gradient slider based on the mouse position if the handle is being dragged.
Returns the current hue of this gradient slider.
Sets the hue of this gradient slider.
In this example, we create a new GradientSlider
with a position of (10, 10) and a size of (100, 20). We then render the GradientSlider
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 using its getter and setter methods.
The GradientSlider is already called and present in . But if you still want to add it yourself somewhere you can do it by:Here's an example of how to use a GradientSlider
in your Minecraft Fabric mod: