本帖最后由 bcrun 于 2013-10-28 10:20:29 编辑

解决方案 »

  1.   

    建个工程,添加如下代码,你什么都明白了。
    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
      

  2.   

        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)
      

  3.   

    不是简单的设置fillstyle和fillcolor属性,是要用line的方法给圆填充颜色
      

  4.   

    填充不是有专门的API函数吗?
      

  5.   

    就是规定得用在园内用line画线的方法来做
      

  6.   

    不是简单的设置fillstyle和fillcolor属性,是要用line的方法给圆填充颜色
      

  7.   

    就是规定得用在园内用line画线的方法来做
    不是的,是api函数,参阅:
    http://download.csdn.net/detail/veron_04/2765084
      

  8.   

    就是规定得用在园内用line画线的方法来做
    不是的,是api函数,参阅:
    http://download.csdn.net/detail/veron_04/2765084
    不是要用这个函数的,要的效果是在这个圆内点一下,通过这个点向外发散画线,到与之颜色不一样的圆周为止,以达到填充圆的目的
      

  9.   

    本帖最后由 bcrun 于 2013-10-28 10:21:22 编辑
      

  10.   

    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. Res
    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  
      

  11.   

    ExtFloodFill
    The ExtFloodFill function fills an area of the display surface with the current brush. BOOL ExtFloodFill(
      HDC hdc,          // handle to device context
      int nXStart,      // x-coordinate where filling begins
      int nYStart,      // y-coordinate where filling begins
      COLORREF crColor, // fill color
      UINT fuFillType   // fill type
    );
     
    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. 
    crColor 
    Specifies the color of the boundary or of the area to be filled. The interpretation of crColor depends on the value of the fuFillType parameter. 
    fuFillType 
    Specifies the type of fill operation to be performed. It must be one of the following values: Value Meaning 
    FLOODFILLBORDER The fill area is bounded by the color specified by the crColor parameter. This style is identical to the filling performed by the FloodFill function. 
    FLOODFILLSURFACE The fill area is defined by the color that is specified by crColor. Filling continues outward in all directions as long as the color is encountered. This style is useful for filling areas with multicolored boundaries. 
    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. Res
    Following are some of the reasons this function might fail: The filling could not be completed. 
    The specified point has the boundary color specified by the crColor parameter (if FLOODFILLBORDER was requested). 
    The specified point does not have the color specified by crColor (if FLOODFILLSURFACE was requested). 
    The point is outside the clipping region — that is, it is not visible on the device. 
    If the fuFillType parameter is FLOODFILLBORDER, the system assumes that the area to be filled is completely bounded by the color specified by the crColor parameter. The function begins filling at the point specified by the nXStart and nYStart parameters and continues in all directions until it reaches the boundary. If fuFillType is FLOODFILLSURFACE, the system assumes that the area to be filled is a single color. The function begins to fill the area at the point specified by nXStart and nYStart and continues in all directions, filling all adjacent regions containing the color specified by crColor. Only memory device contexts and devices that support raster-display operations support the ExtFloodFill function. To determine whether a device supports this technology, use the GetDeviceCaps function. QuickInfo
      Windows NT: Requires version 3.1 or later.
      Windows: Requires Windows 95 or later.
      Windows CE: Unsupported.
      Header: Declared in wingdi.h.
      Import Library: Use gdi32.lib.See Also
    Bitmaps Overview, Bitmap Functions, FloodFill, GetDeviceCaps  
      

  12.   

    扫描线种子填充算法参考下面://试题编号:0186
    //海龟圈地
    //难度级别:D; 运行时间限制:1000ms; 运行空间限制:51200KB; 代码长度限制:2000000B
    //试题描述
    //  海龟小蛮在沙滩上趾高气扬地走来走去,并且蛮横地宣布:“凡我足迹所到之处均为本海龟的领地。”
    //  海龟的任何行动均可分解为下面三个基本动作:
    //      f 向前爬一格
    //      l 原地左转90度
    //      r 原地右转90度
    //  由于小蛮不允许别的海龟经过它的领地,所以,由它足迹围成的封闭区域也就都成了它的领地。
    //  你的任务是编程序根据文件输入的小蛮的一系列基本动作,计算出小蛮共霸占了多少格的领地。
    //  程序文件主名为turtle。
    //  为加深对题意的理解,我们观察下面的基本动作序列:
    //      flffflfffrfrrffflf
    //  小蛮在出发点当然会留下足迹#,如果把它开始的方向设为向下,可以把它的足迹(用*标出的位置)画成下面的示意图:
    //       ****
    //       * *
    //      #  *
    //      ****
    //  显然,小蛮的领地总数为15格。
    //输入
    //  其中只有一个长度不超过1000的字符串,且该字符串不包含'f'、'l'、'r'之外的字符。
    //输出
    //  其中只有一个正整数,即领地总格数。
    //输入示例
    //  flffflfffrfrrffflf
    //输出示例
    //  15
    //其他说明
    //  2011年北京市海淀区中学组赛题
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #define MAXN 1000
    static char n[2*MAXN+2][2*MAXN+2];//记录某处被爬过信息:0未爬过|1爬过
    char f;//当前方向'N'|'S'|'W'|'E'
    int x,y;//当前位置
    char p[MAXN+1];
    int i,L;
    int a,b,h,t;
    int sp=0;
    int x1[MAXN];
    int x2[MAXN];
    int y1[MAXN];
    int yy1,xx1,xx2;
    void push(int ay1,int ax1,int ax2) {
        y1[sp]=ay1;
        x1[sp]=ax1;
        x2[sp]=ax2;
        if (sp<MAXN-1) {
            sp=sp+1;
        } else {
            printf("stack overflow!\n");
            exit(1);
        }
    }
    void pop(void) {
        sp=sp-1;
        yy1=y1[sp];
        xx1=x1[sp];
        xx2=x2[sp];
    }
    //void show() {
    //  int zy,zx;
    //
    //  for (zy=0;zy<2*MAXN+2;zy++) {
    //      for (zx=0;zx<2*MAXN+2;zx++) {
    //          printf("%d",n[zy][zx]);
    //      }
    //      printf("\n");
    //  }
    //  printf("\n");
    //}
    void scanlinefill() {
        int xx,ax1,ax2;
        while (1) {
            if (sp<=0) break;//
            pop();
    //      printf("O yy1,xx1,xx2=%d,%d,%d\n",yy1,xx1,xx2);
            for (xx=xx1;xx<=xx2;xx++) n[yy1][xx]=2;//填充本条线
            yy1++;
            if (yy1<=2*MAXN)
            for (xx=xx1;xx<=xx2;xx++) {//从左往右考查紧挨下面一条线各点
                if (n[yy1][xx  ]==0) {
                    ax1=xx-1;
                    while (1) {//向左找非0点
                        if (n[yy1][ax1]!=0) break;
                        ax1--;
                    }
                    ax1++;//非0点右边为新扫描线左点
                }
                if (n[yy1][xx  ]==0) {
                    ax2=xx+1;
                    while (1) {//向右找非0点
                        if (n[yy1][ax2]!=0) break;
                        ax2++;
                    }
                    ax2--;//非0点左边为新扫描线右点
    //              printf("I yy1,ax1,ax2=%d,%d,%d\n",yy1,ax1,ax2);
                    push(yy1,ax1,ax2);//记录新扫描线到堆栈中
                    xx=ax2+1;//下次循环从该新扫描线右点的右边开始考查
                }
            }
        }
    }
    int main() {
        scanf("%s",p);
        f='S';
        y=MAXN;
        x=MAXN;
        n[y][x]=1;
        L=strlen(p);
        for (i=0;i<L;i++) {
            switch (p[i]) {
            case 'f':
                switch (f) {
                case 'N':y--;n[y][x]=1;break;
                case 'S':y++;n[y][x]=1;break;
                case 'W':x--;n[y][x]=1;break;
                case 'E':x++;n[y][x]=1;break;
                }
            break;
            case 'l':
                switch (f) {
                case 'N':f='W';break;
                case 'S':f='E';break;
                case 'W':f='S';break;
                case 'E':f='N';break;
                }
            break;
            case 'r':
                switch (f) {
                case 'N':f='E';break;
                case 'S':f='W';break;
                case 'W':f='N';break;
                case 'E':f='S';break;
                }
            break;
            }
        }
    //  show();
        for (y=0;y<2*MAXN+2;y++) {n[y][0]=2;n[y   ][2*MAXN+1]=2;}
        for (x=0;x<2*MAXN+2;x++) {n[0][x]=2;n[2*MAXN+1][x   ]=2;}
    //  show();
        push(1,1,2*MAXN);//从(y1==1,x1==1,x2==2*MAXN)开始
        scanlinefill();//往下使用扫描线种子填充算法填充2
    //  show();
        a=0;
        for (y=0;y<2*MAXN+1;y++) {
            for (x=0;x<2*MAXN+1;x++) {
                if (n[y][x]!=2) a++;
            }
        }
        printf("%d\n",a);
        return 0;
    }