Class Stroke
- All Implemented Interfaces:
Proxy
GskStroke
struct collects the parameters that influence
the operation of stroking a path.-
Constructor Summary
ConstructorDescriptionStroke
(float lineWidth) Creates a newGskStroke
with the givenlineWidth
.Stroke
(MemorySegment address) Create a Stroke proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptioncopy()
Creates a copy of the given this Stroke stroke.static boolean
equal
(@Nullable MemorySegment stroke1, @Nullable MemorySegment stroke2) Checks if 2 strokes are identical.void
free()
Frees aGskStroke
.float[]
getDash()
Gets the dash array in use orNULL
if dashing is disabled.float
Returns the dash_offset of aGskStroke
.Gets the line cap used.Gets the line join used.float
Gets the line width used.float
Returns the miter limit of aGskStroke
.static Type
getType()
Get the GType of the Stroke classvoid
setDash
(@org.jetbrains.annotations.Nullable float[] dash) Sets the dash pattern to use by this stroke.void
setDashOffset
(float offset) Sets the offset into the dash pattern where dashing should begin.void
setLineCap
(LineCap lineCap) Sets the line cap to be used when stroking.void
setLineJoin
(LineJoin lineJoin) Sets the line join to be used when stroking.void
setLineWidth
(float lineWidth) Sets the line width to be used when stroking.void
setMiterLimit
(float limit) Sets the limit for the distance from the corner where sharp turns of joins get cut off.void
toCairo
(org.freedesktop.cairo.Context cr) A helper function that sets the stroke parameters ofcr
from the values found in this Stroke.Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
Stroke
Create a Stroke proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
Stroke
public Stroke(float lineWidth) Creates a newGskStroke
with the givenlineWidth
.- Parameters:
lineWidth
- line width of the stroke. Must be > 0
-
-
Method Details
-
getType
-
equal
public static boolean equal(@Nullable @Nullable MemorySegment stroke1, @Nullable @Nullable MemorySegment stroke2) Checks if 2 strokes are identical.- Parameters:
stroke1
- the firstGskStroke
stroke2
- the secondGskStroke
- Returns:
TRUE
if the 2 strokes are equal,FALSE
otherwise
-
copy
-
free
public void free()Frees aGskStroke
. -
getDash
public float[] getDash()Gets the dash array in use orNULL
if dashing is disabled.- Returns:
- The dash array or
NULL
if the dash array is empty.
-
getDashOffset
public float getDashOffset()Returns the dash_offset of aGskStroke
.- Returns:
- the dash_offset
-
getLineCap
Gets the line cap used.See
Gsk.LineCap
for details.- Returns:
- The line cap
-
getLineJoin
Gets the line join used.See
Gsk.LineJoin
for details.- Returns:
- The line join
-
getLineWidth
public float getLineWidth()Gets the line width used.- Returns:
- The line width
-
getMiterLimit
public float getMiterLimit()Returns the miter limit of aGskStroke
.- Returns:
- the miter limit
-
setDash
public void setDash(@Nullable @org.jetbrains.annotations.Nullable float[] dash) Sets the dash pattern to use by this stroke.A dash pattern is specified by an array of alternating non-negative values. Each value provides the length of alternate "on" and "off" portions of the stroke.
Each "on" segment will have caps applied as if the segment were a separate contour. In particular, it is valid to use an "on" length of 0 with
GSK_LINE_CAP_ROUND
orGSK_LINE_CAP_SQUARE
to draw dots or squares along a path.If
nDash
is 0, if all elements indash
are 0, or if there are negative values indash
, then dashing is disabled.If
nDash
is 1, an alternating "on" and "off" pattern with the single dash length provided is assumed.If
nDash
is uneven, the dash array will be used with the first element indash
defining an "on" or "off" in alternating passes through the array.You can specify a starting offset into the dash with
setDashOffset(float)
.- Parameters:
dash
- the array of dashes
-
setDashOffset
public void setDashOffset(float offset) Sets the offset into the dash pattern where dashing should begin.This is an offset into the length of the path, not an index into the array values of the dash array.
See
setDash(float[])
for more details on dashing.- Parameters:
offset
- offset into the dash pattern
-
setLineCap
Sets the line cap to be used when stroking.See
Gsk.LineCap
for details.- Parameters:
lineCap
- theGskLineCap
-
setLineJoin
Sets the line join to be used when stroking.See
Gsk.LineJoin
for details.- Parameters:
lineJoin
- The line join to use
-
setLineWidth
public void setLineWidth(float lineWidth) Sets the line width to be used when stroking.The line width must be > 0.
- Parameters:
lineWidth
- width of the line in pixels
-
setMiterLimit
public void setMiterLimit(float limit) Sets the limit for the distance from the corner where sharp turns of joins get cut off.The miter limit is in units of line width and must be non-negative.
For joins of type
GSK_LINE_JOIN_MITER
that exceed the miter limit, the join gets rendered as if it was of typeGSK_LINE_JOIN_BEVEL
.- Parameters:
limit
- the miter limit
-
toCairo
public void toCairo(org.freedesktop.cairo.Context cr) A helper function that sets the stroke parameters ofcr
from the values found in this Stroke.- Parameters:
cr
- the cairo context to configure
-