Help Center

CGpGraphicsPathIterator.NextMarkermethod

Gets the starting index and the ending index of the next marker-delimited section in this iterator's associated path.

GraphicsmethodCGpGraphics.incdocumented

Syntax

FUNCTION NextMarker (BYVAL startIndex AS INT_ PTR, BYVAL endIndex AS INT_ PTR) AS INT
FUNCTION NextMarker (BYVAL pPath AS CGpGraphicsPath PTR) AS INT

Parameters

NameDescription
startIndexPointer to an LONG that receives the starting index.
endIndexPointer to an LONG that receives the ending index.
pPathPointer to a GraphicsPath object. This method sets the data points of this GraphicsPath object to match the data points of the retrieved section.

Return value

This method returns the number of data points in the retrieved section. If there are no more marker-delimited sections to retrieve, this method returns 0.

Description

Gets the starting index and the ending index of the next marker-delimited section in this iterator's associated path.

Gets the next marker-delimited section of this iterator's associated path.

Remarks

A path has an array of data points that define its lines and curves. You can call a path's SetMarker method to designate certain points in the array as markers. Those marker points divide the path into sections.

The first time you call the NextMarker method of an iterator, it gets the first marker-delimited section of that iterator's associated path. The second time, it gets the second section, and so on. Each time you call NextSubpath, it returns the number of data points in the retrieved section. When there are no sections remaining, it returns 0.

Examples

' ======================================================================================== ' Using the NextMarker method to identify marker sections. ' Markers let you segment a path into meaningful chunks. ' NextMarker helps you identify and isolate those chunks for rendering or analysis. ' ======================================================================================== SUB Example_NextMarker (BYVAL hdc AS HDC)

' // Create a graphics object from the window device context DIM graphics AS CGpGraphics = hdc ' // Set the scale transform graphics.ScaleTransformForDpi

' // Create a GraphicsPath with two marker sections DIM path AS CGpGraphicsPath path.AddLine(30, 30, 130, 30) path.AddLine(130, 30, 80, 100) path.CloseFigure() path.SetMarker ' Set marker after first figure

path.StartFigure path.AddLine(160, 40, 210, 90) path.AddLine(210, 90, 160, 140) path.SetMarker ' Set marker after second figure

' // Create a GraphicsPathIterator DIM iterator AS CGpGraphicsPathIterator = @path

' // Create font and brush for drawing marker info DIM fontFamily AS CGpFontFamily = CGpFontFamily("Arial") DIM font AS CGpFont = CGpFont(@fontFamily, AfxGdipPointsToPixels(16, TRUE), FontStyleRegular) DIM brush AS CGpSolidBrush = ARGB_BLACK

' // Iterate through markers and display their start/end indices DIM resultCount AS LONG, startIdx AS LONG, endIdx AS LONG DIM yOffset AS SINGLE = 10.0 DIM markerIndex AS LONG = 1

DO

resultCount = iterator.NextMarker(@startIdx, @endIdx)
  IF resultCount = 0 THEN EXIT DO
  DIM info AS STRING = "Marker " & markerIndex & ": Start=" & startIdx & ", End=" & endIdx
  DIM layout AS GpRectF = (10.0, yOffset, 300.0, 20.0)
  graphics.DrawString(info, -1, @font, @layout, @brush)
  yOffset += 30.0
  markerIndex += 1

LOOP

END SUB ' ========================================================================================

' ======================================================================================== ' Using the NextMarker method to extract and draw marker sections. ' Lets you isolate and render each marker-defined section independently. ' Useful for animations, selective editing, or exporting segments. ' ======================================================================================== SUB Example_NextMarkerPath (BYVAL hdc AS HDC)

' // Create a graphics object from the window device context DIM graphics AS CGpGraphics = hdc ' // Set the scale transform graphics.ScaleTransformForDpi

' // Create a GraphicsPath with two marker sections DIM path AS CGpGraphicsPath path.AddLine(30, 30, 130, 30) path.AddLine(130, 30, 80, 100) path.CloseFigure path.SetMarker

path.StartFigure path.AddLine(160, 40, 210, 90) path.AddLine(210, 90, 160, 140) path.SetMarker

' // Create a GraphicsPathIterator DIM iterator AS CGpGraphicsPathIterator = CGpGraphicsPathIterator(@path)

' // Create pen for drawing DIM pen AS CGpPen = CGpPen(ARGB_BLUE, 2.0)

' // Create font and brush for text DIM fontFamily AS CGpFontFamily = CGpFontFamily("Arial") DIM font AS CGpFont = CGpFont(@fontFamily, AfxGdipPointsToPixels(12, TRUE), FontStyleRegular) DIM brush AS CGpSolidBrush = ARGB_BLACK

' // Extract and draw each marker-defined section DIM resultCount AS LONG DIM yOffset AS SINGLE = 170 DIM markerIndex AS LONG = 1

DO

DIM markerPath AS CGpGraphicsPath
  resultCount = iterator.NextMarker(@markerPath)
  IF resultCount = 0 THEN EXIT DO
  ' // Draw the extracted marker path
  graphics.DrawPath(@pen, @markerPath)
  ' // Display marker info
  DIM info AS STRING = "Marker " & markerIndex & ": Points=" & resultCount
  DIM layout AS GpRectF = (10.0, yOffset, 300.0, 20.0)
  graphics.DrawString(info, -1, @font, @layout, @brush)
  yOffset += 20.0
  markerIndex += 1

LOOP

END SUB ' ========================================================================================

Reference

  • Include file CGpGraphics.inc
  • Defined in AfxNova/CGpPath.inc:689
  • Documented in Graphics/GdiPlus Classes/CGpGraphics Classes.md
  • Topic: CGpGraphics Class