Empty path

Discuss any general programming issues here
Post Reply
Flinx
Posts: 188
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Empty path

Post by Flinx »

For graphics that adjust to the window size, I got the error message "Cannot draw empty path!", which may be correct at this point, but not optimally worded in combination with IsPathEmpty(), I think. Or should IsPathEmpty() return a different result here?

Code: Select all

StartPath(1)
MoveTo(1, 1, 1)
LineTo(1, 1, 1)
LineTo(1, 1, 1)
ClosePath(1)
If Not IsPathEmpty(1)
	id=PathToBrush(Nil, {{ID=1, Color=#WHITE, X=9, Y=9}})
	FreePath(1)
	DisplayBrush(id, xpos, ypos, {Name="test"})
	FreeBrush(id)
EndIf
WaitLeftMouse
Ralf
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Empty path

Post by airsoftsoftwair »

True, the wording is a bit confusing. For DrawPath() and PathToBrush() a path is empty in case there's nothing to draw. For IsPathEmpty() a path is empty if there are no vertices...
Flinx
Posts: 188
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

Re: Empty path

Post by Flinx »

"Nothing to draw" would be a candidate for a better error message for me. But maybe it makes sense to just draw a dot?

Ralf
User avatar
airsoftsoftwair
Posts: 5425
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: Empty path

Post by airsoftsoftwair »

Code: Select all

- Change: When using DrawPath() on a path whose width/height is 0, nothing will be drawn; in the case of
  PathToBrush(), you'll get a 1x1 fully transparent brush
Post Reply