Additional flag for StrokePath

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Michael Vogel
Addict
Addict
Posts: 2806
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Additional flag for StrokePath

Post by Michael Vogel »

Not sure if this could be implemented easily but it would help in many situations.

Overlapping line segments are wiped out (similar to overlapping areas of filled paths when #PB_Path_Winding is not used). So a flag for StrokePath to eliminate this effect for lines would be helpful.

Code: Select all

OpenWindow(0, 0, 0, 1400, 500, "Swiss Cheese", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(0, 0, 0, 1400, 500)

StartVectorDrawing(CanvasVectorOutput(0))

If Date()&1
	; Draws circles and boxes with different line widths...
	For j=1 To 8
		n=j*10
		MovePathCursor(j*(n+75)+j*40-40,180)
		AddPathCircle(0,-50,40,0,0,#PB_Path_Relative)
		AddPathBox(-60,220,40,40,#PB_Path_Relative)
		VectorSourceColor($FF0000FF)
		StrokePath(j*20,#PB_Path_RoundCorner)
	Next

Else
	; Draws the same path with a wider and a narrower brush...
	j=10
	MovePathCursor(150,100)
	AddPathArc(200,100,150,150,20)
	AddPathArc(100,200,150,250,20)
	AddPathArc(200,250,150,150,20)
	AddPathArc(100,150,150,100,20)
	ClosePath(); removing ClosePath() does show the lines correctly...
	While j>0
		VectorSourceColor($40FF0000+j*25)
		StrokePath(j*20,#PB_Path_RoundCorner|#PB_Path_Preserve|#PB_Path_RoundEnd)
		j-1-Bool(j=7)*5
	Wend
EndIf

StopVectorDrawing()
Repeat:Until WaitWindowEvent() = #PB_Event_CloseWindow
User avatar
Michael Vogel
Addict
Addict
Posts: 2806
Joined: Thu Feb 09, 2006 11:27 pm
Contact:

Re: Additional flag for StrokePath

Post by Michael Vogel »

I am doing different workarounds now (see code below) which have a lot of drawbacks like:
- the slow drawing speed
- the need for repeating path definitions

So I'd like to know if there is a better solution available and/or if the whole thing is a problem of purebasic or the windows graphic functions?

Code: Select all


Procedure StrokePathWorkaround(color,width.d,mode)

	BeginVectorLayer(color>>24)

	VectorSourceColor($FF000000|color)

	While width>1
		StrokePath(width,mode|#PB_Path_Preserve)
		width-1
	Wend
	StrokePath(width,mode)

	EndVectorLayer()

EndProcedure

OpenWindow(0, 0, 0, 1400, 500, "Swiss Cheese", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CanvasGadget(0, 0, 0, 1400, 500)

StartVectorDrawing(CanvasVectorOutput(0))

If Date()&1
	; Draws circles and boxes with different line widths...
	For j=1 To 8
		n=j*10
		MovePathCursor(j*(n+75)+j*40-40,180)
		AddPathCircle(0,-50,40,0,0,#PB_Path_Relative)
		AddPathBox(-60,220,40,40,#PB_Path_Relative)
		StrokePath(1|#PB_Path_Preserve)

		MovePathCursor(j*(n+75)+j*40-40,180)
		AddPathCircle(0,-50,40,0,0,#PB_Path_Relative)
		AddPathBox(-60,220,40,40,#PB_Path_Relative)
		StrokePathWorkaround($800000FF,j*20,#PB_Path_RoundCorner)
	Next

Else
	; Draws the same path with a wider and a narrower brush...
	j=10

	While j>0
		MovePathCursor(150,100)
		AddPathArc(200,100,150,150,20)
		AddPathArc(100,200,150,250,20)
		AddPathArc(200,250,150,150,20)
		AddPathArc(100,150,150,100,20)
		ClosePath(); removing ClosePath() does show the lines correctly...
		StrokePathWorkaround($40FF0000+j*25,j*20,#PB_Path_RoundCorner|#PB_Path_RoundEnd)
		j-1-Bool(j=7)*5
	Wend

EndIf

StopVectorDrawing()
Repeat:Until WaitWindowEvent() = #PB_Event_CloseWindow
Post Reply