Simple way to draw a dotted line...

The title says it all!

Does anybody have a simple way of drawing dotted (or dashed) line?

A couple interesting responses in the old forums:

Simple response (works best for vertical or horizontal lines):

More complex response, including some work being done by @Karen Atkocius and @Dave S:

I used to do this but when I got to the really convoluted stuff (*) I stopped and just started pushing for vector drawing in Xojo.

I don’t have Feedback installed in this machine so I can’t chase the actual ticket to promote, sadly.

(*)Especifically, when I needed to create a rounded box with a thick dashed border where the dashed segments had round edges, all four corners always covered equally when static and when animated doesn’t skip steps from that initial/end position.

On Windows I use the GdiPlus framework and On OSX I would use the Quartz 2D one.

On Windows the function could look like this:

Sub DrawDottedLineWithArrow(g as Graphics, x1 as integer, y1 as Integer, x2 as integer, y2 as integer, Size as double, Col as Color, Alpha as integer)
  dim gfx as new GdiPlusGraphics( g.Handle( Graphics.HandleTypeHDC ) )
  dim brush as new GdiPlusSolidBrush(new GdiPlusColor( Alpha, col.Red, col.Green, col.Blue ))
  dim s as Status
  s = gfx.SetSmoothingMode(SmoothingMode.AntiAlias)
  dim arrow as GdiPlusAdjustableArrowCap
  dim pen as GdiPlusPen
  pen = new GdiPlusPen( brush, Size )
  s = pen.SetColor( new GdiPlusColor( 255, Col.Red, Col.Green, Col.Blue ) )
  arrow =  new GdiPlusAdjustableArrowCap( 2+Size*2, 2+Size*2, true )
  s = pen.SetCustomEndCap( arrow )
  s = pen.SetDashStyle( DashStyle.Dot)
  s = gfx.DrawLine( pen, x1, y1, x2, y2 )
end Sub

Eduardo, Thank you for the response. I wanted a simple solution and this was it.

Alain, I forgot to mention I am on a Mac, but thank you anyway.