mrcrackpot Creative Commons License 2009.02.07 0 0 190

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <X11/Xlib.h>
Display *dp;
Window win;
GC gc;


void pix(int x1,int y1,int col){
XSetForeground(dp,gc,col);
XDrawPoint(dp, win, gc, x1,y1 );
}
int main(){
int x,y,i;
float p=300;

dp = XOpenDisplay((0));
win = XCreateSimpleWindow(dp, DefaultRootWindow(dp), 0,0, 500, 500,0,0,0);
XSelectInput(dp, win, StructureNotifyMask);
XMapWindow(dp, win);

gc = XCreateGC(dp, win, 0, (0));
XSetForeground(dp,gc,0);
while(1) { XEvent e;XNextEvent(dp, &e);if (e.type == MapNotify) break; }


for(y=0;y<500;y++)
for(x=0;x<500;x++) {
int szin=(128* ( sin(M_PI*(x+y)/5)+sin(M_PI*(x-y)/5) ));
if(szin<0) szin=-szin;
else szin=szin*65536;
pix(x,y,szin);
}
for(y=0;y<500;y++){
x=p;
int szin=(128* ( sin(M_PI*(x+y)/5)+sin(M_PI*(x-y)/5) ));
if(szin<0) szin=-szin;
else szin=szin*65536;
for(x=p;x<500;x++)
pix(x,y,szin);
p=p-0.1;
}


XFlush(dp);
getchar();

return 0;
}
Előzmény: mrcrackpot (189)