一个方程实现液体下流效果

  • 来源: 编程中国 作者: 若水   2008-05-07/14:40
  • #include<stdio.h>
    #include<math.h>
    #include<graphics.h>
    #define PI 3.14
    int main()
    {
        float i ,j ,x ,y;
        int MAXX2 ,MAXY2;
        int gd = DETECT,gm = 0;

        initgraph(&gd,&gm,"");

        MAXX2 = getmaxx()/2;
        MAXY2 = getmaxy()/2;

        setcolor(15);
        setfillstyle(1 ,2);

        for(j = 0;j < MAXY2*2;j+=40)
        {
            rectangle(1 ,j ,i+39 ,j+21);
            for(i = 0;i < MAXX2*2;i+=40)
            {
                rectangle(i ,j+1 ,i+39 ,j+20);
                floodfill(i+3 ,j+3 ,getcolor());
                rectangle(i+20 ,j+21 ,i+59 ,j+40);
                floodfill(i+23 ,j+23 ,getcolor());
            }
            rectangle(21 ,j+21 ,i+59 ,j+41);
            floodfill(3 ,j+23 ,getcolor());
        }

        for(i = -3*PI-1;i < 0;i +=0.005)
        {
            for(j = -4*PI;j < 4*PI;j += 0.01)
            {
                x = cos(i*2+j)*20+j*30;
                y = sin(i-j*2)*20+i*30*sin(i/2)+sin(x/25)*30;

                putpixel(x+MAXX2 ,y+MAXY2 ,4);

                if(kbhit())
                 exit(0);
            }
        }
        getch();
    }

     

     


    评论 {{userinfo.comments}}

    {{money}}

    {{question.question}}

    A {{question.A}}
    B {{question.B}}
    C {{question.C}}
    D {{question.D}}
    提交

    驱动号 更多