Class Stroke

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class Stroke extends ProxyInstance
Collects the parameters that are needed when stroking a path.
Since:
4.14
  • Constructor Details

    • Stroke

      public Stroke(MemorySegment address)
      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 new GskStroke with the given lineWidth.
      Parameters:
      lineWidth - line width of the stroke. Must be > 0
      Since:
      4.14
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the Stroke class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • equal

      public static boolean equal(@Nullable MemorySegment stroke1, @Nullable MemorySegment stroke2)
      Checks if two strokes are identical.
      Parameters:
      stroke1 - the first stroke
      stroke2 - the second stroke
      Returns:
      true if the two strokes are equal, false otherwise
      Since:
      4.14
    • copy

      public Stroke copy()
      Creates a copy of a GskStroke.
      Returns:
      a new GskStroke. Use free() to free it
      Since:
      4.14
    • free

      public void free()
      Frees a GskStroke.
      Since:
      4.14
    • getDash

      public @Nullable float @Nullable [] 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

      public LineCap getLineCap()

      Gets the line cap used.

      See Gsk.LineCap for details.

      Returns:
      the line cap
      Since:
      4.14
    • getLineJoin

      public LineJoin 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 float @Nullable [] 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 or Gsk.LineCap.square to draw dots or squares along a path.

      If nDash is 0, if all elements in dash are 0, or if there are negative values in dash, 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 in dash 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

      public void setLineCap(LineCap lineCap)

      Sets the line cap to be used when stroking.

      See Gsk.LineCap for details.

      Parameters:
      lineCap - the line cap
      Since:
      4.14
    • setLineJoin

      public void setLineJoin(LineJoin lineJoin)

      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 type Gsk.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 a GskStroke.
      Parameters:
      cr - the cairo context to configure
      Since:
      4.14