VB中给圆填充颜色的算法如何写
VB中给圆填充颜色的算法怎么写
这是我画的一个圆
------解决方案--------------------
建个工程,添加如下代码,你什么都明白了。
Private Sub Form_Paint()
'这段代码演示了如何使用VB的Circle方法绘制各种各样的圆。
Form1.ScaleMode = vbPixels ' 设置绘图单位为像素
Form1.Circle (60, 60), 40, vbRed '画一个圆心(60,60)半径40的红色的圆(默认空心)
Form1.FillStyle = 0 '设定填充模式为实心
Form1.FillColor = vbBlue '设定填充色蓝色
Form1.Circle (190, 60), 40, vbRed '下来画出来的就是填充了实心蓝色的圆了
Form1.DrawWidth = 3 '设定边框宽度为3
Form1.Circle (60, 190), 40, vbRed '这次绘制出来的圆边框粗细为3
Form1.DrawStyle = 5 '设定边框不可见
Form1.FillColor = vbRed '设定填充色红色
Form1.Circle (190, 190), 40 '这次绘制出来一个无边框、填充颜色是红色的圆
End Sub
------解决方案--------------------
Picdraw.Cls
Picdraw.FillColor = RGB(0, 0, 0)
Picdraw.FillStyle = vbSolid
Picdraw.Circle ((a + X) / 2, (b + Y) / 2), (((a - X) ^ 2 + (b - Y) ^ 2) ^ 0.5) / 2, RGB(0, 0, 0)
------解决方案--------------------
FloodFill
The FloodFill function fills an area of the display surface with the current brush. The area is assumed to be bounded as specified by the crFill parameter.
Note The FloodFill function is included only for compatibility with 16-bit versions of Windows. For Win32-based applications, use the ExtFloodFill function with FLOODFILLBORDER specified.
BOOL FloodFill(
HDC hdc, // handle to device context
int nXStart, // x-coordinate, where fill begins
int nYStart, // y-coordinate, where fill begins
COLORREF crFill // fill color
);
Parameters
hdc
Handle to a device context.
nXStart
Specifies the logical x-coordinate of the point where filling is to begin.
nYStart
Specifies the logical y-coordinate of the point where filling is to begin.
crFill
Specifies the color of the boundary or of the area to be filled.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero.
Windows NT: To get extended error information, callGetLastError.
Remarks
Following are reasons this function might fail:
The fill could not be completed.
The given point has the boundary color specified by the crFill parameter.
The given point lies outside the current clipping region — that is, it is not visible on the device.
See Also
Bitmaps Overview, Bitmap Functions, ExtFloodFill
------解决方案--------------------
ExtFloodFill
The ExtFloodFill function fills an area of the display surface with the current brush.
BOOL ExtFloodFill(
HDC hdc, // handle to device context
这是我画的一个圆
Dim a As Single
Dim b As Single
Private Sub picdraw_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
a = X
b = Y
End Sub
Private Sub picdraw_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
Picdraw.Cls
Picdraw.Circle ((a + X) / 2, (b + Y) / 2), (((a - X) ^ 2 + (b - Y) ^ 2) ^ 0.5) / 2, RGB(0, 0, 0)
End If
End Sub
------解决方案--------------------
建个工程,添加如下代码,你什么都明白了。
Private Sub Form_Paint()
'这段代码演示了如何使用VB的Circle方法绘制各种各样的圆。
Form1.ScaleMode = vbPixels ' 设置绘图单位为像素
Form1.Circle (60, 60), 40, vbRed '画一个圆心(60,60)半径40的红色的圆(默认空心)
Form1.FillStyle = 0 '设定填充模式为实心
Form1.FillColor = vbBlue '设定填充色蓝色
Form1.Circle (190, 60), 40, vbRed '下来画出来的就是填充了实心蓝色的圆了
Form1.DrawWidth = 3 '设定边框宽度为3
Form1.Circle (60, 190), 40, vbRed '这次绘制出来的圆边框粗细为3
Form1.DrawStyle = 5 '设定边框不可见
Form1.FillColor = vbRed '设定填充色红色
Form1.Circle (190, 190), 40 '这次绘制出来一个无边框、填充颜色是红色的圆
End Sub
------解决方案--------------------
Picdraw.Cls
Picdraw.FillColor = RGB(0, 0, 0)
Picdraw.FillStyle = vbSolid
Picdraw.Circle ((a + X) / 2, (b + Y) / 2), (((a - X) ^ 2 + (b - Y) ^ 2) ^ 0.5) / 2, RGB(0, 0, 0)
------解决方案--------------------
FloodFill
The FloodFill function fills an area of the display surface with the current brush. The area is assumed to be bounded as specified by the crFill parameter.
Note The FloodFill function is included only for compatibility with 16-bit versions of Windows. For Win32-based applications, use the ExtFloodFill function with FLOODFILLBORDER specified.
BOOL FloodFill(
HDC hdc, // handle to device context
int nXStart, // x-coordinate, where fill begins
int nYStart, // y-coordinate, where fill begins
COLORREF crFill // fill color
);
Parameters
hdc
Handle to a device context.
nXStart
Specifies the logical x-coordinate of the point where filling is to begin.
nYStart
Specifies the logical y-coordinate of the point where filling is to begin.
crFill
Specifies the color of the boundary or of the area to be filled.
Return Values
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero.
Windows NT: To get extended error information, callGetLastError.
Remarks
Following are reasons this function might fail:
The fill could not be completed.
The given point has the boundary color specified by the crFill parameter.
The given point lies outside the current clipping region — that is, it is not visible on the device.
See Also
Bitmaps Overview, Bitmap Functions, ExtFloodFill
------解决方案--------------------
ExtFloodFill
The ExtFloodFill function fills an area of the display surface with the current brush.
BOOL ExtFloodFill(
HDC hdc, // handle to device context