| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2936 人关注过本帖
标题:[原创]美丽蝴蝶
取消只看楼主 加入收藏
cdmalcl
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:4091
专家分:524
注 册:2005-9-23
结帖率:74.19%
收藏
 问题点数:0 回复次数:5 
[原创]美丽蝴蝶

#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;

for(i = -5*PI;i < 5*PI;i +=0.01)
for(j = -5*PI;j < 5*PI;j += 0.01)
{
y = sin(i-j*2)*5+i*j;
x = cos(i*2+j)*y+3*y;
putpixel(x+MAXX2 ,y*j/2+MAXY2 ,((int)abs(i+j)*4)%15+1);
}

getch();
}

搜索更多相关主题的帖子: 蝴蝶 美丽 
2007-04-26 00:33
cdmalcl
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:4091
专家分:524
注 册:2005-9-23
收藏
得分:0 

#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;

for(i = -6*PI;i < 6*PI;i +=0.02)
for(j = -3*PI;j < 3*PI;j += 0.02)
{
y = sin(i-j*2)*i*3+j*5;
x = cos(i*2+y)*j+2*y;
putpixel(y*i/5+MAXX2 ,MAXY2*1.5-x*j/5 ,((int)abs(i+j)*4)%15+1);
if(kbhit())
exit(0);
}

getch();
}

2007-04-26 01:06
cdmalcl
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:4091
专家分:524
注 册:2005-9-23
收藏
得分:0 
以下是引用cdmalcl在2007-4-26 1:06:53的发言:

#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;

for(i = -6*PI;i < 6*PI;i +=0.02)
for(j = -3*PI;j < 3*PI;j += 0.02)
{
y = sin(i-j*2)*i*3+j*5;
x = cos(i*2+y)*j+2*y;
putpixel(y*i/5+MAXX2 ,MAXY2*1.5-x*j/5 ,((int)abs(i+j)*4)%15+1);
if(kbhit())
exit(0);
}

getch();
}

((int)abs(i+j)*4)%3+3



或者

x = cos(2+i*y)*j+2*y;

[此贴子已经被作者于2007-4-26 1:09:34编辑过]

2007-04-26 01:08
cdmalcl
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:4091
专家分:524
注 册:2005-9-23
收藏
得分:0 

董哥 帮我写个WINDOWS下的动画程序呗!
我写这个不是即时的那种!

[CODE]#include <windows.h>
#include <math.h>
#define PI 3.14
int cxClient, cyClient ;
float i, j, x, y ;
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
static TCHAR szAppName[] = TEXT ("SineWave") ;
MSG msg ;
WNDCLASS wndclass;
HWND hwnd ;
wndclass.style = CS_HREDRAW | CS_VREDRAW ;
wndclass.lpfnWndProc= WndProc ;
wndclass.cbClsExtra = 0 ;
wndclass.cbWndExtra = 0 ;
wndclass.hInstance = hInstance ;
wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION) ;
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW) ;
wndclass.hbrBackground= (HBRUSH) GetStockObject (LTGRAY_BRUSH) ;
wndclass.lpszMenuName = NULL ;
wndclass.lpszClassName = szAppName ;
if (!RegisterClass (&wndclass))
{
MessageBox ( NULL, TEXT ("Program requires Windows NT!"),
szAppName, MB_ICONERROR) ;
return 0 ;
}
hwnd = CreateWindow ( szAppName, TEXT ("美丽蝴蝶"),
WS_OVERLAPPEDWINDOW,
10, 10,
800, 600,
NULL, NULL, hInstance, NULL) ;
ShowWindow (hwnd, iCmdShow) ;
UpdateWindow (hwnd) ;
while (GetMessage (&msg, NULL, 0, 0))
{
TranslateMessage (&msg) ;
DispatchMessage (&msg) ;
}
return msg.wParam ;
}
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc ;
PAINTSTRUCT ps ;
RECT rect;
HBRUSH hBrush ;
HBITMAP bit;
HINSTANCE hinst ;

switch (message)
{
case WM_CREATE:
return 0 ;
case WM_SIZE:
cxClient = LOWORD (lParam) ;
cyClient = HIWORD (lParam) ;
InvalidateRect (hwnd, NULL, FALSE) ;
return 0;
case WM_PAINT:
hdc = BeginPaint (hwnd, &ps) ;
for(i = -6*PI;i < 6*PI;i +=0.02)
for(j = -3*PI;j < 3*PI;j += 0.02)
{
y = sin(i-j*2)*i*3+j*5 ;
x = cos(i*2+y)*j+2*y ;
SetPixel(hdc
, y*i/5+cxClient/2
, (cyClient/2)*1.5-x*j/5
, RGB(abs(i*j)%255,abs(2*j*j)%255,abs(i*j*5+i*30)%255)) ;
}
EndPaint (hwnd, &ps) ;
return 0 ;
case WM_DESTROY:
PostQuitMessage (0) ;
return 0 ;
}
return DefWindowProc (hwnd, message, wParam, lParam) ;
}[/CODE]

2007-07-10 23:56
cdmalcl
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:4091
专家分:524
注 册:2005-9-23
收藏
得分:0 

我就是用TIMER事件
但是没弄出来

2007-07-12 19:25
cdmalcl
Rank: 7Rank: 7Rank: 7
等 级:贵宾
威 望:24
帖 子:4091
专家分:524
注 册:2005-9-23
收藏
得分:0 
关键是重画问题
我不知道用什么好办法记录已经画的图形
2007-07-12 19:38
快速回复:[原创]美丽蝴蝶
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015488 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved