cdmalcl 发表于 2007-4-26 00:33

[原创]美丽蝴蝶

<P>#include&lt;stdio.h&gt;<BR>#include&lt;math.h&gt;<BR>#include&lt;graphics.h&gt;<BR>#define PI 3.14<BR>int main()<BR>{<BR>    float i ,j ,x ,y;<BR>    int MAXX2 ,MAXY2;<BR>    int gd = DETECT,gm = 0;</P>
<P>    initgraph(&amp;gd,&amp;gm,"");</P>
<P>    MAXX2 = getmaxx()/2;<BR>    MAXY2 = getmaxy()/2;</P>
<P>    for(i = -5*PI;i &lt; 5*PI;i +=0.01)<BR>    for(j = -5*PI;j &lt; 5*PI;j += 0.01)<BR>    {<BR>        y = sin(i-j*2)*5+i*j;<BR>        x = cos(i*2+j)*y+3*y;<BR>        putpixel(x+MAXX2 ,y*j/2+MAXY2 ,((int)abs(i+j)*4)%15+1);<BR>    }</P>
<P>    getch();<BR>} </P>

cdmalcl 发表于 2007-4-26 01:06

<P>#include&lt;stdio.h&gt;<BR>#include&lt;math.h&gt;<BR>#include&lt;graphics.h&gt;<BR>#define PI 3.14<BR>int main()<BR>{<BR>    float i ,j ,x ,y;<BR>    int MAXX2 ,MAXY2;<BR>    int gd = DETECT,gm = 0;</P>
<P>    initgraph(&amp;gd,&amp;gm,"");</P>
<P>    MAXX2 = getmaxx()/2;<BR>    MAXY2 = getmaxy()/2;</P>
<P>    for(i = -6*PI;i &lt; 6*PI;i +=0.02)<BR>    for(j = -3*PI;j &lt; 3*PI;j += 0.02)<BR>    {<BR>        y = sin(i-j*2)*i*3+j*5;<BR>        x = cos(i*2+y)*j+2*y;<BR>        putpixel(y*i/5+MAXX2 ,MAXY2*1.5-x*j/5 ,((int)abs(i+j)*4)%15+1);<BR>        if(kbhit())<BR>         exit(0);<BR>    }</P>
<P>    getch();<BR>} </P>

cdmalcl 发表于 2007-4-26 01:08

<DIV class=quote><B>以下是引用<U>cdmalcl</U>在2007-4-26 1:06:53的发言:</B><br>
<P>#include&lt;stdio.h&gt;<br>#include&lt;math.h&gt;<br>#include&lt;graphics.h&gt;<br>#define PI 3.14<br>int main()<br>{<br>    float i ,j ,x ,y;<br>    int MAXX2 ,MAXY2;<br>    int gd = DETECT,gm = 0;</P>
<P>    initgraph(&amp;gd,&amp;gm,"");</P>
<P>    MAXX2 = getmaxx()/2;<br>    MAXY2 = getmaxy()/2;</P>
<P>    for(i = -6*PI;i &lt; 6*PI;i +=0.02)<br>    for(j = -3*PI;j &lt; 3*PI;j += 0.02)<br>    {<br>        y = sin(i-j*2)*i*3+j*5;<br>        x = cos(i*2+y)*j+2*y;<br>        putpixel(y*i/5+MAXX2 ,MAXY2*1.5-x*j/5 ,((int)abs(i+j)*4)%15+1);<br>        if(kbhit())<br>         exit(0);<br>    }</P>
<P>    getch();<br>} </P></DIV>
<P>((int)abs(i+j)*4)%3+3</P><br><br>或者<br><br> x = cos(2+i*y)*j+2*y;
[align=right][color=#000066][此贴子已经被作者于2007-4-26 1:09:34编辑过][/color][/align]

卧龙孔明 发表于 2007-5-6 20:40

第二个效果不错[em17]

蔡蔡 发表于 2007-5-8 12:46

厉害!厉害!高手,不知我什么时候才能和你们一样`~~~~~[em11]

wswwang 发表于 2007-5-16 22:56

niu

fangfangff 发表于 2007-6-9 22:38

<P>不错,顶一个!!!!!!!!</P>

killer_l 发表于 2007-6-10 10:49

TC2.0里无法运行啊<BR><BR>提示BGI Error:Graphics not initialized(use 'intigraph')[em13]

a429499381 发表于 2007-6-16 18:45

[em13][em02] 我的编译成功后黑了一下就退出来了, 不知道怎么??<BR> 可能我的系统原因吧?<BR>   我的2003企业版的, 不知道是不是这个原因, 而且在这个系统上无法玩魔兽, ???+

dexingtuohai 发表于 2007-7-10 17:32

<P>太牛拉,代码那少也写出这么厉害的图[em17]</P>

一笔苍穹 发表于 2007-7-10 17:43

WIN 2003对虚拟DOS的支持不够好。要跑DOS程序还得改一些地方,这个页面里有,你看看行不(里面介绍的是WIN 2000《我在Windows 2000下运行用NEO编译的DOS程序,但发现无法运行里面的实例,为什么?》):<BR><a href="http://www.ds0101.com/neosdk/docs/end/faq.htm" target="_blank" >http://www.ds0101.com/neosdk/docs/end/faq.htm</A>

cdmalcl 发表于 2007-7-10 23:56

<P>董哥 帮我写个WINDOWS下的动画程序呗!<BR>我写这个不是即时的那种![em04]<BR><BR>[CODE]#include &lt;windows.h&gt;<BR>#include &lt;math.h&gt;<BR>#define PI 3.14<BR>int  cxClient, cyClient ;<BR>float i, j, x, y ;<BR>LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;<BR>int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,<BR>                   PSTR szCmdLine, int iCmdShow)<BR>{<BR>    static TCHAR szAppName[] = TEXT ("SineWave") ;<BR>    MSG           msg ;<BR>    WNDCLASS      wndclass;<BR>    HWND hwnd ;<BR>    wndclass.style        = CS_HREDRAW | CS_VREDRAW ;<BR>    wndclass.lpfnWndProc= WndProc ;<BR>    wndclass.cbClsExtra   = 0 ;<BR>    wndclass.cbWndExtra   = 0 ;<BR>    wndclass.hInstance    = hInstance ;<BR>    wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;<BR>    wndclass.hCursor      = LoadCursor (NULL, IDC_ARROW) ;<BR>    wndclass.hbrBackground= (HBRUSH) GetStockObject (LTGRAY_BRUSH) ;<BR>    wndclass.lpszMenuName  = NULL ;<BR>    wndclass.lpszClassName = szAppName ;<BR>    if (!RegisterClass (&amp;wndclass))<BR>    {<BR>            MessageBox (  NULL, TEXT ("Program requires Windows NT!"),<BR>                   szAppName, MB_ICONERROR) ;<BR>                   return 0 ;<BR>    }<BR>    hwnd = CreateWindow ( szAppName, TEXT ("美丽蝴蝶"),<BR>                          WS_OVERLAPPEDWINDOW,<BR>                           10, 10,<BR>                           800, 600,<BR>                           NULL, NULL, hInstance, NULL) ;<BR>    ShowWindow (hwnd, iCmdShow) ;<BR>    UpdateWindow (hwnd) ;<BR>    while (GetMessage (&amp;msg, NULL, 0, 0))<BR>    {<BR>            TranslateMessage (&amp;msg) ;<BR>            DispatchMessage (&amp;msg) ;<BR>    }<BR>    return msg.wParam ;<BR>}<BR>LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)<BR>{<BR>    HDC         hdc ;<BR>    PAINTSTRUCT ps ;<BR>    RECT rect;<BR>    HBRUSH hBrush ;<BR>    HBITMAP  bit;<BR>    HINSTANCE hinst ;</P>
<P>    switch (message)<BR>    {<BR>    case    WM_CREATE:<BR>            return 0 ;<BR>    case    WM_SIZE:<BR>            cxClient = LOWORD (lParam) ;<BR>            cyClient = HIWORD (lParam) ;<BR>            InvalidateRect (hwnd, NULL, FALSE) ;<BR>            return 0;<BR>    case    WM_PAINT:<BR>            hdc = BeginPaint (hwnd, &amp;ps) ;<BR>            for(i = -6*PI;i &lt; 6*PI;i +=0.02)<BR>             for(j = -3*PI;j &lt; 3*PI;j += 0.02)<BR>             {<BR>                    y = sin(i-j*2)*i*3+j*5 ;<BR>                    x = cos(i*2+y)*j+2*y ;<BR>                    SetPixel(hdc<BR>                            , y*i/5+cxClient/2<BR>                            , (cyClient/2)*1.5-x*j/5<BR>                            , RGB(abs(i*j)%255,abs(2*j*j)%255,abs(i*j*5+i*30)%255)) ;<BR>             }<BR>            EndPaint (hwnd, &amp;ps) ;<BR>            return 0 ;<BR>    case    WM_DESTROY:<BR>            PostQuitMessage (0) ;<BR>            return 0 ;<BR>    }<BR>    return DefWindowProc (hwnd, message, wParam, lParam) ;<BR>}[/CODE]</P>

一笔苍穹 发表于 2007-7-12 16:48

Timer方面的API不难,稍微查点资料就可以完成。<BR>我现在在公司赶工~~~命苦哇

cdmalcl 发表于 2007-7-12 19:25

<P>我就是用TIMER事件<BR>但是没弄出来</P>

cdmalcl 发表于 2007-7-12 19:38

关键是重画问题<BR>我不知道用什么好办法记录已经画的图形

页: [1]

编程论坛