Hi Bradley, I’d like to see that too, and I think others as well. Could you post it somewhere?

In the meantime I made the non-accurate version of what I said above with Dave’s code.

[code]//to a Window (or Canvas) add this event

Sub Paint(g As Graphics, areas() As REALbasic.Rect)

g.ForeColor = &c000000

g.PenWidth = 2

g.PenHeight = 2

dim xpos() As double = Array(0.0, g.Width, 0.0) //control points

dim ypos() As double = Array(0.0, 0.0, g.Height)

dim dashes() As double = Array(10.0, 10.0, 20.0, 10.0) //~10 pixels on, 10 off, 20 on, 10 off, loop

//draw bezier curve xpos/ypos using dashes and 1000 segments

drawDashedBezier(g, xpos, ypos, dashes, 1000)

End Sub

//and add these 2 methods

Sub drawDashedBezier(g As Graphics, xpos() As double, ypos() As double, dashes() As Double, resolution As integer = 500)

if dashes.Ubound = -1 then dashes = Array(100.0, 0.0) //fix dashes() if no elements

//tracking vars

dim dashIsOn As boolean = true //treat first dashes() element as dash ON

dim summedDist As double = 0.0 //total curve distance traveled

dim curDashIdx As integer = 0 //current index into dashes()

dim nextDashPointDist As double = dashes(curDashIdx) //distance to end of current dash

dim dashCount As integer = dashes.Ubound + 1 //for wrapping curDashIdx

dim x0, y0, x1, y1 As double //segment endpoints

dim xDiff, yDiff, dist As double //temps

sampleBezier(0.0, xpos, ypos, x0, y0) //sample t=0.0 of curve xpos/ypos into point x0,y0

for i As integer = 1 to resolution

```
sampleBezier(i / resolution, xpos, ypos, x1, y1) //sample t=i/res into x1,y1
xDiff = x1 - x0 //measure and sum distance
yDiff = y1 - y0
dist = Sqrt(xDiff * xDiff + yDiff * yDiff)
summedDist = summedDist + dist
while summedDist > nextDashPointDist //while past the current dash distance
dashIsOn = not dashIsOn //flip dash state
curDashIdx = (curDashIdx + 1) mod dashCount //step to next dash
nextDashPointDist = nextDashPointDist + dashes(curDashIdx) //and add in it's distance
wend
if dashIsOn then g.DrawLine x0, y0, x1, y1 //draw segment if ON
x0 = x1 //roll coords
y0 = y1
```

next

End Sub

Sub sampleBezier(t As double, xpos() As double, ypos() As double, byref x As double, byref y As double)

dim t2, tm, tm2, t3 As double

t2=t*t*

tm=(1-t)

tm2=tmtm

t3=tm*t*2

x = tm2 * xpos(0) + t3 * xpos(2) + t2 * xpos(1)

y = tm2 * ypos(0) + t3 * ypos(2) + t2 * ypos(1)

End Sub[/code]

Because lines only start or stop on sampled points the resolution needs to be high enough to approximate dash lengths, otherwise the pattern aliases. Using a high resolution is inefficient and ‘hardens’ the lines though.

Needs segment interpolation and possibly adaptive sampling. I think the Sqrt could be removed.