Vanesa Lara Cruz / Mbed 2 deprecated serial-protocol-V2

Dependencies:   mbed

Fork of 02_LAB_serial_protocol by ferney alberto beltran molina

Revision:
15:92cfae44483c
Parent:
14:124051c4524a
Child:
17:a0b884f78802
--- a/draw.cpp	Thu Oct 12 01:13:42 2017 +0000
+++ b/draw.cpp	Thu Oct 12 01:30:06 2017 +0000
@@ -78,20 +78,23 @@
     vertex2d(0 ,0);
 }    
 
-
-
-void line(float xi, float yi, float xf,  float yf)
-{   
+void line_n(float xi, float yi, float xf,  float yf)
+{ 
     float xp; float yp;
     float m= (yf-yi)/(xf-xi);
     float b=yf-m*xf;
     
-    initdraw(xi,yi);
     for (xp =xi;xp<=xf;xp+=RSTEP)
         {
          yp =m*xp+b;
          vertex2d(xp,yp);
         }
+ 
+}
+void line(float xi, float yi, float xf,  float yf)
+{   
+    initdraw(xi,yi);
+    line_n(xi, yi, xf,  yf);
     nodraw();
  
 }
@@ -100,12 +103,13 @@
 void rectangle(float x, float y, float width,float height) {
     
     initdraw(x,y);
+ 
+    line_n(x,y,x+width,y);
+    line_n(x+width,y,x+width,y+height);
+    line_n(x+width,y+height,x,y+height);
+    line_n(x,y+height,x,y);
     
-    vertex2d(x+width, y);
-    vertex2d(x+width, y+height);
-    vertex2d(x, y+height);
-    vertex2d(x, y);
-    
+
     nodraw();
  
 }