种子填充的递归算法!
by827 2004-11-07 01:49:24 Dim c As Single
'种子填充的递归算法过程
Private Sub seed_filling(xStart As Single, yStart As Single, fill_color As Single, boundary_color As Single)
c = Point(xStart, yStart) '取得当前象素的颜色
If ((c <> boundary_colr) And (c <> fill_color)) Then
Picture1.PSet (yStart, yStart), fill_color '填一个象素点
Call seed_filling(xStart + 1, yStart, fill_color, boundary_color)
Call seed_filling(xStart - 1, yStart, fill_color, boundary_color)
Call seed_filling(xStart, yStart + 1, fill_color, boundary_color)
Call seed_filling(xStart, yStart - 1, fill_color, boundary_color)
End If
End Sub
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Call seed_filling(X, Y, Picture1.ForeColor, Picture1.ForeColor)
End Sub
Private Sub Picture1_Paint()
Picture1.Circle (1000, 1000), 1000 '先画一个圆,然后要在这个圆填充颜色!
End Sub
这是一个种子填色算法的实现
运行时左击圆内时出现"out of stack space"错误提示!我要运行时左击圆内实现圆的填充!
该怎么改呀?
请高人指教!