📅  最后修改于: 2023-12-03 15:16:03.300000             🧑  作者: Mango
JavaFX ColorInput is a class that extends the Effect
class and represents an effect that provides access to a specific rectangular region of the input image by its x, y, width and height values. The pixels in this region of the input are used to create a Color object that is used as the output value of the effect.
This effect is useful for applying color correction or other effects to a specific area of the input image.
ColorInput colorInput = new ColorInput(x, y, width, height);
x
: The x-coordinate of the upper-left corner of the rectangular region of the input image.y
: The y-coordinate of the upper-left corner of the rectangular region of the input image.width
: The width of the rectangular region of the input image.height
: The height of the rectangular region of the input image.Rectangle rectangle = new Rectangle(0, 0, 100, 100);
rectangle.setFill(Color.RED);
ColorInput colorInput = new ColorInput(0, 0, 100, 100);
colorInput.setPaint(Color.GREEN);
Group group = new Group(rectangle);
group.setEffect(colorInput);
Scene scene = new Scene(group, 200, 200);
In this example, a rectangle is created and filled with red color. The ColorInput
object is created to represent a rectangular region of the input image that corresponds to the red color of the rectangle. The setPaint
method is used to set the output color of the effect to green. The ColorInput
object is then added as an effect to the rectangle using the setEffect
method. Finally, the rectangle is added to a group and the group is added to a scene.
JavaFX ColorInput is a useful class for creating effects that apply to specific areas of an input image. It can be used to create complex image filters and color corrections.