A tiny drawing library. include line draw and bitmap-font draw.bitmap-font is from linux-kernel-source.

Revision:
1:c2860a9f58b4
Parent:
0:b49309b1b9d3
--- a/tinydraw.cpp	Thu Oct 21 13:52:40 2010 +0000
+++ b/tinydraw.cpp	Sun Oct 31 13:54:04 2010 +0000
@@ -175,3 +175,73 @@
     drawPoint(p2->x,p2->y,col->fore);
 }
 
+#if 0
+void TinyDraw::drawEllipse( int x0, int y0, int r, int a, int b, int col )
+{
+  int x = (int)( (double)r / sqrt( (double)a ) );
+  int y = 0;
+  double d = sqrt( (double)a ) * (double)r;
+  int F = (int)( -2.0 * d ) +     a + 2 * b;
+  int H = (int)( -4.0 * d ) + 2 * a     + b;
+
+  while ( x >= 0 ) {
+    pset( x0 + x, y0 + y, col );
+    pset( x0 - x, y0 + y, col );
+    pset( x0 + x, y0 - y, col );
+    pset( x0 - x, y0 - y, col );
+    if ( F >= 0 ) {
+      --x;
+      F -= 4 * a * x;
+      H -= 4 * a * x - 2 * a;
+    }
+    if ( H < 0 ) {
+      ++y;
+      F += 4 * b * y + 2 * b;
+      H += 4 * b * y;
+    }
+  }
+}
+
+void TinyDraw::drawCircle( int x0, int y0, int r, unsigned int col )
+{
+  int x = r;
+  int y = 0;
+  int F = -2 * r + 3;
+
+  while ( x >= y ) {
+    pset( x0 + x, y0 + y, col );
+    pset( x0 - x, y0 + y, col );
+    pset( x0 + x, y0 - y, col );
+    pset( x0 - x, y0 - y, col );
+    pset( x0 + y, y0 + x, col );
+    pset( x0 - y, y0 + x, col );
+    pset( x0 + y, y0 - x, col );
+    pset( x0 - y, y0 - x, col );
+    if ( F >= 0 ) {
+      x--;
+      F -= 4 * x;
+    }
+    y++;
+    F += 4 * y + 2;
+  }
+}
+
+void TinyDraw::rotatePoint(int p1x,int p1y,int cx,int cy,double deg,int *p2x,int *p2y)
+{
+	double xl1;
+	double yl1;
+	double xl2;
+	double yl2;
+	double _rad = deg * PI / 180;
+	double _cos_rad = cos(_rad);
+	double _sin_rad = sin(_rad);
+
+	xl1 = p1x - cx;
+	yl1 = p1y - cy;
+
+	xl2 = (_cos_rad*xl1) - (_sin_rad*yl1);
+	yl2 = (_sin_rad*xl1) - (_cos_rad*yl1);
+	*p2x = cx + (int)xl2;
+	*p2y = cy + (int)yl2;
+}
+#endif