Class Stroke
- All Implemented Interfaces:
Proxy
- Since:
- 4.14
-
Field Summary
Fields inherited from class io.github.jwharm.javagi.base.ProxyInstance
address
-
Constructor Summary
ConstructorsConstructorDescriptionStroke
(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 aGskStroke
.static boolean
equal
(@Nullable MemorySegment stroke1, @Nullable MemorySegment stroke2) Checks if two strokes are identical.void
free()
Frees aGskStroke
.float[]
getDash()
Gets the dash array in use.float
Gets the dash offset.Gets the line cap used.Gets the line join used.float
Gets the line width used.float
Gets the miter limit.static Type
getType()
Get the GType of the Stroke classvoid
setDash
(@org.jetbrains.annotations.Nullable float[] dash) Sets the dash pattern to use.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 miter limit to be used when stroking.void
toCairo
(org.freedesktop.cairo.Context cr) A helper function that sets the stroke parameters of a cairo context from aGskStroke
.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- Since:
- 4.14
-
-
Method Details
-
getType
-
equal
public static boolean equal(@Nullable @Nullable MemorySegment stroke1, @Nullable @Nullable MemorySegment stroke2) Checks if two strokes are identical.- Parameters:
stroke1
- the first strokestroke2
- the second stroke- Returns:
- true if the two strokes are equal, false otherwise
- Since:
- 4.14
-
copy
-
free
public void free()Frees aGskStroke
.- Since:
- 4.14
-
getDash
public float[] getDash()Gets the dash array in use.- Returns:
- the dash array or
NULL
if the dash array is empty - Since:
- 4.14
-
getDashOffset
public float getDashOffset()Gets the dash offset.- Returns:
- the dash offset
- Since:
- 4.14
-
getLineCap
Gets the line cap used.See
Gsk.LineCap
for details.- Returns:
- the line cap
- Since:
- 4.14
-
getLineJoin
Gets the line join used.See
Gsk.LineJoin
for details.- Returns:
- the line join
- Since:
- 4.14
-
getLineWidth
public float getLineWidth()Gets the line width used.- Returns:
- the line width
- Since:
- 4.14
-
getMiterLimit
public float getMiterLimit()Gets the miter limit.- Returns:
- the miter limit
- Since:
- 4.14
-
setDash
public void setDash(@Nullable @org.jetbrains.annotations.Nullable float[] dash) Sets the dash pattern to use.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.LineCap.round
orGsk.LineCap.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- Since:
- 4.14
-
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- Since:
- 4.14
-
setLineCap
Sets the line cap to be used when stroking.See
Gsk.LineCap
for details.- Parameters:
lineCap
- the line cap- Since:
- 4.14
-
setLineJoin
Sets the line join to be used when stroking.See
Gsk.LineJoin
for details.- Parameters:
lineJoin
- the line join to use- Since:
- 4.14
-
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- Since:
- 4.14
-
setMiterLimit
public void setMiterLimit(float limit) Sets the miter limit to be used when stroking.The miter limit is the distance from the corner where sharp turns of joins get cut off.
The limit is specfied in units of line width and must be non-negative.
For joins of type
Gsk.LineJoin.miter
that exceed the miter limit, the join gets rendered as if it was of typeGsk.LineJoin.bevel
.- Parameters:
limit
- the miter limit- Since:
- 4.14
-
toCairo
public void toCairo(org.freedesktop.cairo.Context cr) A helper function that sets the stroke parameters of a cairo context from aGskStroke
.- Parameters:
cr
- the cairo context to configure- Since:
- 4.14
-