Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 38d4552b authored by BOUCHERIE Raphael's avatar BOUCHERIE Raphael
Browse files

added global array for color, corrected spelling mistake, removed useless library

parent 89a71d18
No related branches found
No related tags found
1 merge request!4Treewalk
......@@ -9,12 +9,11 @@
*
* @version 1.0.0
* @author Raphael Boucherie
* @author Matthieu Faverge
* @author Mathieu Faverge
* @date 2017-04-04
*
**/
#include <stdio.h>
#ifndef _LIBDRAW_H_
#define _LIBDRAW_H_
......@@ -22,6 +21,12 @@
BEGIN_C_DECLS
/*
* Clobal array for color
*/
extern char *color[4];
/*
* function for treedraw
*/
......
......@@ -18,14 +18,20 @@
#include <stdio.h>
#include "libdraw.h"
/*
* Global array for color
*/
char *color[4] = {"red", "blue", "green", "purple"};
/*
* functions writing in the svg file
*/
void libhqr_writeheader(FILE *tree){
if(fprintf(tree, "<?xml version=\"1.0\" standalone=\"no\"?>\n") < 0) return;
if(fprintf(tree, "<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n ") < 0) return;
if(fprintf(tree, "<svg width=\"2000\" height=\"2000\" version=\"1.1\" \n xmlns=\"http://www.w3.org/2000/svg\">\n") <0) return;
if(fprintf(tree, "<?xml version=\"1.0\" standalone=\"no\"?>\n"
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \n \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n"
"<svg width=\"2000\" height=\"2000\" version=\"1.1\" \n xmlns=\"http://www.w3.org/2000/svg\">\n") <0) return;
}
/*
......@@ -38,41 +44,13 @@ void libhqr_writeheader(FILE *tree){
*/
void libhqr_drawTT(int x, int y, int w, int h, int k, FILE *tree){
switch (k % 4){
case 0 :
if(fprintf(tree,"<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" fill=\"red\" /> \n", x, y, w, h) < 0 ) return;
break;
case 1 :
if(fprintf(tree,"<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" fill=\"blue\" /> \n", x, y, w, h) < 0 ) return;
break;
case 2 :
if(fprintf(tree,"<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" fill=\"green\" /> \n", x, y, w, h) < 0 ) return;
break;
case 3 :
if(fprintf(tree,"<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" fill=\"black\" /> \n", x, y, w, h) < 0 ) return;
break;
default:
if(fprintf(tree,"<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" fill=\"%s\" /> \n", x, y, w, h, color[k%4]) < 0 )
return;
}
}
void libhqr_drawTS(int x, int y, int w, int h, int k, FILE *tree){
switch (k % 4){
case 0 :
if(fprintf(tree,"<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" fill=\"red\" /> \n", x, y, w, h) < 0 ) return;
break;
case 1 :
if(fprintf(tree,"<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" fill=\"blue\" /> \n", x, y, w, h) < 0 ) return;
break;
case 2 :
if(fprintf(tree,"<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" fill=\"green\" /> \n", x, y, w, h) < 0 ) return;
break;
case 3 :
if(fprintf(tree,"<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" fill=\"black\" /> \n", x, y, w, h) < 0 ) return;
break;
default:
if(fprintf(tree,"<rect x=\"%d\" y=\"%d\" width=\"%d\" height=\"%d\" fill=\"%s\" /> \n", x, y, w, h, color[k%4]) < 0 )
return;
}
int x2 = x + (w / 4);
int y2 = y + (h / 4);
int w2 = (w / 2);
......
......@@ -33,7 +33,7 @@ main(int argc, char ** argv)
for (j = 1; j < 9; j++){
x = 100*i;
y = 100*j;
libhqr_drawTS(x,y,WIDTH,HEIGHT,1,tree);
libhqr_drawTS(x,y,WIDTH,HEIGHT,3,tree);
}
}
libhqr_writeend(tree);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment