Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Rasturizer/Rasturizer.cpp@2:a5bc7b3779f7, 2019-02-22 (annotated)
- Committer:
- el17cd
- Date:
- Fri Feb 22 13:45:34 2019 +0000
- Revision:
- 2:a5bc7b3779f7
- Parent:
- 1:044238f7bdda
- Child:
- 3:2e31dfcb712a
Working but getting Empty Execution region description for region RW_IRAM1 compiler error when adding lcd in rasteriser;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| el17cd | 1:044238f7bdda | 1 | #include "mbed.h" |
| el17cd | 1:044238f7bdda | 2 | #include "Rasturizer.h" |
| el17cd | 2:a5bc7b3779f7 | 3 | |
| el17cd | 1:044238f7bdda | 4 | |
| el17cd | 2:a5bc7b3779f7 | 5 | Rasturizer::Rasturizer(){//Face face){ |
| el17cd | 2:a5bc7b3779f7 | 6 | /*lcd.init(); |
| el17cd | 2:a5bc7b3779f7 | 7 | float f = face.GetVertexValue(0,0); |
| el17cd | 1:044238f7bdda | 8 | float points[4][2] = {{rand()%20,rand()%20},{20+rand()%20, rand()%20}, {20+rand()%20,20+rand()%20}, {rand()%20,20+rand()%20}}; |
| el17cd | 1:044238f7bdda | 9 | |
| el17cd | 1:044238f7bdda | 10 | int diffX1 = points[0][0]-points[1][0]; |
| el17cd | 1:044238f7bdda | 11 | int diffY1 = points[0][1]-points[1][1]; |
| el17cd | 1:044238f7bdda | 12 | int diffX2 = points[2][0]-points[3][0]; |
| el17cd | 1:044238f7bdda | 13 | int diffY2 = points[2][1]-points[3][1]; |
| el17cd | 1:044238f7bdda | 14 | |
| el17cd | 1:044238f7bdda | 15 | if (abs(diffX1) > abs(diffX2)){ |
| el17cd | 1:044238f7bdda | 16 | |
| el17cd | 1:044238f7bdda | 17 | float step = (float)diffY1/(float)diffX1; |
| el17cd | 1:044238f7bdda | 18 | float stepSmall1 = (float)diffX2/(float)diffX1; |
| el17cd | 1:044238f7bdda | 19 | float stepSmall2 = (float)diffY2/(float)diffX1; |
| el17cd | 1:044238f7bdda | 20 | lcd.printString("top",0,0); |
| el17cd | 1:044238f7bdda | 21 | for(int s = 0; s<= abs(diffX1)-1; s++){ |
| el17cd | 1:044238f7bdda | 22 | 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); |
| el17cd | 1:044238f7bdda | 23 | 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); |
| el17cd | 1:044238f7bdda | 24 | } |
| el17cd | 1:044238f7bdda | 25 | lcd.printString("a",10,0); |
| el17cd | 1:044238f7bdda | 26 | } |
| el17cd | 1:044238f7bdda | 27 | else{ |
| el17cd | 1:044238f7bdda | 28 | lcd.printString("bottom",0,0); |
| el17cd | 1:044238f7bdda | 29 | float step = (float)diffY2/(float)diffX2; |
| el17cd | 1:044238f7bdda | 30 | float stepSmall1 = (float)diffX1/(float)diffX2; |
| el17cd | 1:044238f7bdda | 31 | float stepSmall2 = (float)diffY1/(float)diffX2; |
| el17cd | 1:044238f7bdda | 32 | |
| el17cd | 1:044238f7bdda | 33 | for(int s = 0; s<= abs(diffX2)-1; s++){ |
| el17cd | 1:044238f7bdda | 34 | 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); |
| el17cd | 1:044238f7bdda | 35 | 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); |
| el17cd | 1:044238f7bdda | 36 | } |
| el17cd | 1:044238f7bdda | 37 | } |
| el17cd | 1:044238f7bdda | 38 | for (int i = 0; i < 3; i++){ |
| el17cd | 1:044238f7bdda | 39 | lcd.drawLine(points[i][0], |
| el17cd | 1:044238f7bdda | 40 | points[i][1], |
| el17cd | 1:044238f7bdda | 41 | points[i+1][0], |
| el17cd | 1:044238f7bdda | 42 | points[i+1][1], |
| el17cd | 1:044238f7bdda | 43 | 1); |
| el17cd | 1:044238f7bdda | 44 | } |
| el17cd | 1:044238f7bdda | 45 | lcd.drawLine(points[0][0], |
| el17cd | 1:044238f7bdda | 46 | points[0][1], |
| el17cd | 1:044238f7bdda | 47 | points[3][0], |
| el17cd | 1:044238f7bdda | 48 | points[3][1], |
| el17cd | 1:044238f7bdda | 49 | 1); |
| el17cd | 2:a5bc7b3779f7 | 50 | */ |
| el17cd | 1:044238f7bdda | 51 | } |