#include <fcntl.h>
#include <libfreenect.h>
#include <libfreenect_sync.h>
#include <string.h>
#include <unistd.h>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <stdlib.h>
#include"svg.h"
//gcc k.c svg.c -std=c11 -o main
#define WIDTH 640
#define HEIGHT 480
//--------------------------------------------------------
// FUNCTION PROTOTYPES
//--------------------------------------------------------
void drawrectangles(void);
//--------------------------------------------------------
// FUNCTION main
//--------------------------------------------------------
int main(void){
drawrectangles();
return EXIT_SUCCESS;
}
// --------------------------------------------------------
// FUNCTION drawrectangles
// --------------------------------------------------------
void drawrectangles(void){
svg* psvg;
psvg = svg_create(WIDTH, HEIGHT); //overall size
if(psvg == NULL){
puts("psvg is NULL");
} else {
char *RED="#FF0000";
char *ORANGE="#FFA500";
char *YELLOW="#FFFF00";
char *GREEN="#00FF00";
char *BLUE="#0000FF";
char *INDIGO="FF00FF";
char *VIOLET="#C0C0FF";
char *WHITE="#FFFFFF";
char *BLACK="#000000";
int x = 0;
int y = 0;
int index = 0; //index 0 to 307840
for (x=0; x<=WIDTH; x++){ //I expect 640 numbers by 480
//index = y * WIDTH+x;
index = x;
//printf(" %d %d ", x, y);
printf(" Index: %d ",index);
if(index<100){
switch (index) {
case 0 ... 5 :
printf("White\n");
//(svg* psvg, int width, int height, int x, int y, char* fill, char* stroke, int strokewidth, int radiusx, int radiusy)
svg_rectangle(psvg, 1, 1, x, y, WHITE, WHITE, 1, 0, 0);
break;
case 6 ... 15:
printf("red\n");
svg_rectangle(psvg, 1, 1, x, y, RED, RED, 1, 0, 0);
break;
case 16 ... 30:
printf("orange\n");
svg_rectangle(psvg, 1, 1, x, y, ORANGE, ORANGE, 1, 0, 0);
break;
case 31 ... 51:
printf("yellow\n");
svg_rectangle(psvg, 1, 1, x, y, YELLOW,YELLOW, 1, 0, 0);
break;
case 52 ... 75:
printf("green\n");
svg_rectangle(psvg, 1, 1, x, y, GREEN,GREEN, 1, 0, 0);
break;
case 76 ... 80:
printf("blue\n");
svg_rectangle(psvg, 1, 1, x, y, BLUE,BLUE, 1, 0, 0);
break;
case 81 ... 90:
printf("indigo\n");
svg_rectangle(psvg, 1, 1, x, y, INDIGO,INDIGO, 1, 0, 0);
break;
case 91 ... 100:
printf("violet\n");
svg_rectangle(psvg, 1, 1, x, y, VIOLET,VIOLET, 1, 0, 0);
break;
default:
printf("black\n");
svg_rectangle(psvg, 1, 1, x, y, BLACK, BLACK, 1, 0, 0);
break;
}
}
}
// svg_rectangle(psvg, 1, 1, 0, 0, RED, "black", 1, 0, 0);
svg_finalize(psvg);
svg_save(psvg, "balls.svg");
svg_free(psvg);
}
}