- Direct Known Subclasses:
LinearGradient
,RadialGradient
-
Constructor Summary
ConstructorDescriptionGradient
(MemorySegment address) Constructor used internally to instantiate a java GradientPattern object for a nativecairo_pattern_t
instance -
Method Summary
Modifier and TypeMethodDescriptionvoid
addColorStopRGB
(double offset, double red, double green, double blue) Adds an opaque color stop to a gradient pattern.void
addColorStopRGBA
(double offset, double red, double green, double blue, double alpha) Adds a translucent color stop to a gradient pattern.int
Gets the number of color stops specified in the given gradient pattern.double[]
getColorStopRGBA
(int index) Gets the color and offset information at the givenindex
for a gradient pattern.Methods inherited from class org.freedesktop.cairo.Pattern
destroy, getDither, getExtend, getFilter, getMatrix, getPatternType, getType, getUserData, setDither, setExtend, setFilter, setMatrix, setUserData, status
-
Constructor Details
-
Gradient
Constructor used internally to instantiate a java GradientPattern object for a nativecairo_pattern_t
instance- Parameters:
address
- the memory address of the nativecairo_pattern_t
instance
-
-
Method Details
-
addColorStopRGB
public void addColorStopRGB(double offset, double red, double green, double blue) Adds an opaque color stop to a gradient pattern. The offset specifies the location along the gradient's control vector. For example, a linear gradient's control vector is from (x0,y0) to (x1,y1) while a radial gradient's control vector is from any point on the start circle to the corresponding point on the end circle.The color is specified in the same way as in
Context.setSourceRGB(double, double, double)
.If two (or more) stops are specified with identical offset values, they will be sorted according to the order in which the stops are added, (stops added earlier will compare less than stops added later). This can be useful for reliably making sharp color transitions instead of the typical blend.
- Parameters:
offset
- an offset in the range [0.0 .. 1.0]red
- red component of colorgreen
- green component of colorblue
- blue component of color- Since:
- 1.0
-
addColorStopRGBA
public void addColorStopRGBA(double offset, double red, double green, double blue, double alpha) Adds a translucent color stop to a gradient pattern. The offset specifies the location along the gradient's control vector. For example, a linear gradient's control vector is from (x0,y0) to (x1,y1) while a radial gradient's control vector is from any point on the start circle to the corresponding point on the end circle.The color is specified in the same way as in
Context.setSourceRGBA(double, double, double, double)
.If two (or more) stops are specified with identical offset values, they will be sorted according to the order in which the stops are added, (stops added earlier will compare less than stops added later). This can be useful for reliably making sharp color transitions instead of the typical blend.
- Parameters:
offset
- an offset in the range [0.0 .. 1.0]red
- red component of colorgreen
- green component of colorblue
- blue component of coloralpha
- alpha component of color- Since:
- 1.0
-
getColorStopCount
public int getColorStopCount()Gets the number of color stops specified in the given gradient pattern.- Returns:
- the number of color stops
- Since:
- 1.4
-
getColorStopRGBA
Gets the color and offset information at the givenindex
for a gradient pattern. Values ofindex
range from 0 to n-1 where n is the number returned bygetColorStopCount()
.Note that the color and alpha values are not premultiplied.
- Parameters:
index
- index of the stop to return data for- Returns:
- a 5-element array with the offset and red, green, blue and alpha color components
- Throws:
IndexOutOfBoundsException
- if index is not valid for the given pattern (seeStatus.INVALID_INDEX
).- Since:
- 1.4
-