Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void print_byte_array(byte* arr, int w, int h) {
- printf("\n[ ");
- for (int y = 0; y < h; y++) {
- for (int x = 0; x < w; x++) {
- printf("%d, ", arr[x+y*h]);
- }
- printf("\n ");
- }
- printf("]\n");
- }
- #define plot(x,y) arr[(x)+((y)*20)] = 1
- void symmetry(int x,int y,int xc,int yc,byte* arr)
- {
- plot(xc+x,yc-y);//For pixel (x,y)
- plot(xc+y,yc-x);//For pixel (y,x)
- plot(xc+y,yc+x);//For pixel (y,-x)
- plot(xc+x,yc+y);//For pixel (x,-y)
- plot(xc-x,yc+y);//For pixel (-x,-y)
- plot(xc-y,yc+x);//For pixel (-y,-x)
- plot(xc-y,yc-x);//For pixel (-y,x)
- plot(xc-x,yc-y);//For pixel (-x,y)
- }
- void raster_circle(int xc,int yc,int rad) {
- byte arr[20*15];
- ZeroMemory(arr,20*15);
- int x = 0;
- int y = rad;
- int p = 1-rad;
- symmetry(x,y,xc,yc,(byte*)arr);
- for(x= 0;y>x;x++)
- {
- if(p<0)
- p += 2*x + 3;
- else
- {
- p += 2*(x-y) + 5;
- y--;
- }
- symmetry(x,y,xc,yc,(byte*)arr);
- }
- print_byte_array((byte*)arr,20,15);
- }
Add Comment
Please, Sign In to add comment