I'm drawing a Drawing2D.GraphicsPath
freehand (?selbstgezeichneterPath“). This is definitely a simple, closed figure. From this, I only want to determine the vertical and horizontal extent of the shape.
In yesterday's question, which was concerned with determining whether a point lies within the shape, I said that I know xmin, ..., but now I think my procedure is too slow. Is there a way to work out the 4 points faster?
Dim xmin As Single = 2000
Dim xmax As Single = 0
Dim ymin As Single = 2000
Dim ymax As Single = 0
For i As Integer = 0 To selbstgezeichneterPath.PointCount - 1 Step 1
If selbstgezeichneterPath.PathPoints(i).X < xmin Then
xmin = selbstgezeichneterPath.PathPoints(i).X
End If
If selbstgezeichneterPath.PathPoints(i).Y < ymin Then
ymin = selbstgezeichneterPath.PathPoints(i).Y
End If
If selbstgezeichneterPath.PathPoints(i).X > xmax Then
xmax = selbstgezeichneterPath.PathPoints(i).X
End If
If selbstgezeichneterPath.PathPoints(i).Y > ymax Then
ymax = selbstgezeichneterPath.PathPoints(i).Y
End If
Next
question from:
https://stackoverflow.com/questions/65871183/accelerate-program-how-do-i-find-xmin-xmax-ymin-and-ymax-from-a-drawing2d-gra 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…