From 15996e514ae7fb085c21dca20c827adab69c1f0b Mon Sep 17 00:00:00 2001
From: Raphael Boucherie <raphael.boucherie@inria.fr>
Date: Thu, 6 Apr 2017 14:06:42 +0200
Subject: [PATCH] Can draw basic tree

---
 include/libdraw.h           |  4 +---
 src/treedraw.c              |  4 +---
 testings/testing_treedraw.c | 11 ++++++++++-
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/include/libdraw.h b/include/libdraw.h
index 0824b92..a05c44d 100644
--- a/include/libdraw.h
+++ b/include/libdraw.h
@@ -30,11 +30,9 @@ void libhqr_writeheader(FILE *tree);
 void libhqr_writecss();
 void libhqr_writeend(FILE *tree);
 void libhqr_drawTT(int x, int y, int k, FILE *tree);
-void libhqr_drawTS(int x, int y, FILE *tree);
+void libhqr_drawTS(int x, int y, int x2, int y2, FILE *tree);
 void libhqr_drawline(int x1, int y1, int x2, int y2, FILE *tree);
 
-
-  
 END_C_DECLS
 
 #endif /* _LIBDRAW_H_ */
diff --git a/src/treedraw.c b/src/treedraw.c
index f19307d..a69da52 100644
--- a/src/treedraw.c
+++ b/src/treedraw.c
@@ -34,10 +34,8 @@ void libhqr_drawTT(int x, int y, int k, FILE *tree){
     if(fprintf(tree,"<rect x=\"%d\" y=\"%d\" width=\"50\" height=\"50\" fill=\"red\" /> \n", x, y) < 0 ) return;
 }
 
-void libhqr_drawTS(int x, int y, FILE *tree){
+void libhqr_drawTS(int x, int y, int x2, int y2, FILE *tree){
     if(fprintf(tree,"<rect x=\"%d\" y=\"%d\" width=\"50\" height=\"50\" fill =\"red\" /> \n", x, y) < 0 ) return;
-    int x2 = (x * 4)/3;
-    int y2 = (y * 4)/3;
     if(fprintf(tree,"<rect x=\"%d\" y=\"%d\" width=\"25\" height=\"25\" fill =\"white\"/> \n", x2, y2) < 0 ) return;
 }
 
diff --git a/testings/testing_treedraw.c b/testings/testing_treedraw.c
index d30e06a..2add618 100644
--- a/testings/testing_treedraw.c
+++ b/testings/testing_treedraw.c
@@ -25,8 +25,17 @@ int
 main(int argc, char ** argv)
 {
   FILE *tree = fopen("tree.svg","w+");
+  int x,y,x2,y2,i,j;
   libhqr_writeheader(tree);
-  libhqr_drawTS(30,30,tree);
+  for (i = 1; i < 5; i++){
+      for (j = 1; j < 9; j++){
+          x = 100*i;
+          y = 100*j;
+          x2 = 10 + x;
+          y2 = 10 + y;
+          libhqr_drawTS(x,y,x2,y2,tree);
+      }
+  }
   libhqr_writeend(tree);
   return 1;
 }
-- 
GitLab