ELEC2645 (2018/19) / Mbed 2 deprecated el17cd

Dependencies:   mbed

Revision:
6:75031d14fc0d
Parent:
4:759a5c34e239
Child:
7:15543cb10a14
--- a/Rasturizer/Rasturizer.cpp	Fri Feb 22 19:15:50 2019 +0000
+++ b/Rasturizer/Rasturizer.cpp	Sat Feb 23 16:19:29 2019 +0000
@@ -15,11 +15,13 @@
             points[vertex][axis] = face.getVertexValue(vertex, axis);
         }
     }
+    
+    
     int diffX1 = points[0][0]-points[1][0];
     int diffY1 = points[0][1]-points[1][1];
     int diffX2 = points[2][0]-points[3][0];
     int diffY2 = points[2][1]-points[3][1];
-
+    /*
     if (abs(diffX1) > abs(diffX2)){
         
         float step = (float)diffY1/(float)diffX1;
@@ -27,8 +29,12 @@
         float stepSmall2 = (float)diffY2/(float)diffX1;
         lcd.printString("top",0,0);
         for(int s = 0; s<= abs(diffX1)-1; s++){
-            lcd.drawLine(points[0][0]+s, rint(points[0][1]+step*s), rint(points[3][0]-stepSmall1*s), rint(points[3][1]-stepSmall2*s), 0); 
-            lcd.drawLine(points[0][0]+s+1, rint(points[0][1]+step*s), rint(points[3][0]-stepSmall1*s-1), rint(points[3][1]-stepSmall2*s), 0); 
+            lcd.drawLine((rint(points[0][0]+s)/points[0][2]), rint((points[0][1]+step*s)/points[0][2]), rint((points[3][0]-stepSmall1*s)/points[3][2]), rint((points[3][1]-stepSmall2*s)/points[3][2]), 0); 
+            lcd.drawLine((rint(points[0][0]+s+1)/points[0][2]), rint((points[0][1]+step*s)/points[0][2]), rint((points[3][0]-stepSmall1*s-1)/points[3][2]), rint((points[3][1]-stepSmall2*s)/points[3][2]), 0); 
+            
+            //lcd.drawLine(points[0][0]+s, rint(points[0][1]+step*s), rint(points[3][0]-stepSmall1*s), rint(points[3][1]-stepSmall2*s), 0); 
+            //lcd.drawLine(points[0][0]+s+1, rint(points[0][1]+step*s), rint(points[3][0]-stepSmall1*s-1), rint(points[3][1]-stepSmall2*s), 0); 
+            
         }
     }
     else{
@@ -38,21 +44,24 @@
         float stepSmall2 = (float)diffY1/(float)diffX2;
         
         for(int s = 0; s<= abs(diffX2)-1; s++){
-            lcd.drawLine(points[0][0]-stepSmall1*s, rint(points[0][1]-stepSmall2*s),rint(points[3][0]+s), rint(points[3][1]+step*s), 0); 
-            lcd.drawLine(points[0][0]-stepSmall1*s-1, rint(points[0][1]-stepSmall2*s),rint(points[3][0]+s+1), rint(points[3][1]+step*s), 0); 
+            lcd.drawLine(rint((points[0][0]-stepSmall1*s)*(40/points[0][2])), rint((points[0][1]-stepSmall2*s)*(40/points[0][2])),rint((points[3][0]+s)*(40/points[3][2])), rint((points[3][1]+step*s)*(40/points[3][2])), 0); 
+            lcd.drawLine(rint((points[0][0]-stepSmall1*s-1)*(40/points[0][2])), rint((points[0][1]-stepSmall2*s)*(40/points[0][2])),rint((points[3][0]+s+1)*(40/points[3][2])), rint((points[3][1]+step*s)*(40/points[3][2])), 0); 
         }
-    }
+    }*/
+    
     for (int i = 0; i < 3; i++){
-    lcd.drawLine(points[i][0],
-                 points[i][1],
-                 points[i+1][0],
-                 points[i+1][1],
+        
+    lcd.drawLine(rint(points[i][0]*(40/points[i][2]))+42,
+                 rint(points[i][1]*(40/points[i][2]))+21,
+                 rint(points[i+1][0]*(40/points[i+1][2]))+42,
+                 rint(points[i+1][1]*(40/points[i+1][2]))+21,
                  1);
+                 
     }
-    lcd.drawLine(points[0][0],
-                 points[0][1],
-                 points[3][0],
-                 points[3][1],
+    lcd.drawLine(rint(points[0][0]*(40/points[0][2]))+42,
+                 rint(points[0][1]*(40/points[0][2]))+21,
+                 rint(points[3][0]*(40/points[3][2]))+42,
+                 rint(points[3][1]*(40/points[3][2]))+21,
                  1);
 }
 void Rasturizer::clear(){