summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test-painter.cpp106
1 files changed, 84 insertions, 22 deletions
diff --git a/tests/test-painter.cpp b/tests/test-painter.cpp
index f932c83..0fb811c 100644
--- a/tests/test-painter.cpp
+++ b/tests/test-painter.cpp
@@ -5,29 +5,11 @@
#include "tqtcairopainter.h"
-int
-main (int argc, char *argv[])
-{
- cairo_surface_t *surface;
- cairo_t *cr;
-
- surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 500, 500);
-// cr = cairo_create (surface);
-
-// /* Examples are in 1.0 x 1.0 coordinate space */
-// cairo_scale (cr, 120, 120);
-//
-// /* Drawing code goes here */
-// cairo_set_line_width (cr, 0.1);
-// cairo_set_source_rgb (cr, 0, 0, 0);
-// cairo_rectangle (cr, 0.25, 0.25, 0.5, 0.5);
-// cairo_stroke (cr);
-
- // Initialize TQApplication required data structures
- new TQApplication(argc, argv, TRUE);
+// TQt3 test image only
+#include <tqpixmap.h>
- TQt3CairoPaintDevice pd(surface);
- TQPainter p(&pd);
+void runTests(TQPaintDevice* pd) {
+ TQPainter p(pd);
// Rectangle tests
{
@@ -132,13 +114,93 @@ main (int argc, char *argv[])
p.drawChord(100, 450, 200, 100, 45*16, 90*16);
}
+ // Line segment tests
+ {
+ TQPointArray a;
+ int x1 = 10;
+ int y1 = 400;
+
+ a.setPoints( 4, x1+0, y1+85, x1+75, y1+75, x1+0, y1+95, x1+75, y1+85 );
+ p.setPen(TQColor(255,128,0));
+ p.drawLineSegments(a);
+ }
+
+ // Bezier curve tests
+ {
+ TQPointArray a;
+ int x1 = 100;
+ int y1 = 400;
+
+ a.setPoints( 4, x1+0, y1+85, x1+75, y1+75, x1+0, y1+95, x1+75, y1+85 );
+ p.setPen(TQColor(0,128,255));
+ p.drawCubicBezier(a);
+ }
+
+ // Font tests
+ {
+ static const char *fonts[] = { "Helvetica", "Courier", "Times", 0 };
+ static int sizes[] = { 10, 12, 18, 24, 36, 0 };
+ int f = 0;
+ int y = 0;
+ while ( fonts[f] ) {
+ int s = 0;
+ while ( sizes[s] ) {
+ TQFont font( fonts[f], sizes[s] );
+ p.setFont( font );
+ TQFontMetrics fm = p.fontMetrics();
+ y += fm.ascent();
+ p.drawText( 10, y, "TQt3 renders via Cairo!" );
+ y += fm.descent();
+ s++;
+ if (y > 500) {
+ break;
+ }
+ }
+ f++;
+ if (y > 500) {
+ break;
+ }
+ }
+ }
+
p.end();
+}
+
+int
+main (int argc, char *argv[])
+{
+ cairo_surface_t *surface;
+ cairo_t *cr;
+
+ surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 500, 500);
+// cr = cairo_create (surface);
+
+// /* Examples are in 1.0 x 1.0 coordinate space */
+// cairo_scale (cr, 120, 120);
+//
+// /* Drawing code goes here */
+// cairo_set_line_width (cr, 0.1);
+// cairo_set_source_rgb (cr, 0, 0, 0);
+// cairo_rectangle (cr, 0.25, 0.25, 0.5, 0.5);
+// cairo_stroke (cr);
+
+ // Initialize TQApplication required data structures
+ new TQApplication(argc, argv, TRUE);
+
+ TQt3CairoPaintDevice pd(surface);
+ runTests(&pd);
/* Write output and clean up */
cairo_surface_write_to_png (surface, "stroke.png");
// cairo_destroy (cr);
cairo_surface_destroy (surface);
+ // Render a TQt3 native test image
+ TQPixmap pm(500, 500);
+ pm.fill(TQt::black);
+ runTests(&pm);
+ pm.save("tqt3.png", "PNG");
+
return 0;
}