Kamil Ondrousek
/
Sierpin-Tri
Sierpinski triangle fractal - only modified algo for 4DGL - original code Eric Wieser - THANKS
Diff: main.cpp
- Revision:
- 0:66e8e6fa8997
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Jan 23 17:32:41 2011 +0000 @@ -0,0 +1,38 @@ +#include "TFT_4DGL.h" + +TFT_4DGL lcd(p9,p10,p11); + +#define PI 3.14159265 + +struct point +{ + int x; + int y; +}; + +point points[3]; +point current; + +int main() { + + int n = WHITE; + + for(int i=0; i<3; i++) + { + points[i].x = 150*sin(2*PI*i/3); + points[i].y = 150*cos(2*PI*i/3); + } + + current = points[rand()%3]; + + while(1) + { + + lcd.pixel(80+current.y,160+current.x,n); + + point nextpoint = points[rand()%3]; + + current.x = (current.x + nextpoint.x)/2; + current.y = (current.y + nextpoint.y)/2; + } +} \ No newline at end of file