From b6cb4612ca9c615323c0540a3b05edc24feec642 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Mon, 17 Sep 2012 11:49:39 -0500 Subject: Add transformation support --- tests/open.png | Bin 0 -> 20782 bytes tests/test-painter.cpp | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 tests/open.png (limited to 'tests') diff --git a/tests/open.png b/tests/open.png new file mode 100644 index 0000000..79beaf8 Binary files /dev/null and b/tests/open.png differ diff --git a/tests/test-painter.cpp b/tests/test-painter.cpp index 0fb811c..6979af4 100644 --- a/tests/test-painter.cpp +++ b/tests/test-painter.cpp @@ -8,6 +8,31 @@ // TQt3 test image only #include +void drawColorWheel(TQPainter *p, double scale) +{ + TQFont f( "times", 18, TQFont::Bold ); + p->setFont( f ); + p->setPen(TQt::black); + p->setWindow( 0, 0, 500*scale, 500*scale ); // defines coordinate system + + for ( int i=0; i<36; i++ ) { // draws 36 rotated rectangles + TQWMatrix matrix; + matrix.translate( 250.0F*scale, 250.0F*scale ); // move to center + matrix.shear( 0.0F*scale, 0.3F*scale ); // twist it + matrix.rotate( (float)i*10 ); // rotate 0,10,20,.. degrees + p->setWorldMatrix( matrix ); // use this world matrix + + TQColor c; + c.setHsv( i*10, 255, 255 ); // rainbow effect + p->setBrush( c ); // solid fill with color c + p->drawRect( 70*scale, -10*scale, 80*scale, 10*scale ); // draw the rectangle + + TQString n; + n.sprintf( "H=%d", i*10 ); + p->drawText( (80+70+5)*scale, 0, n ); // draw the hue number + } +} + void runTests(TQPaintDevice* pd) { TQPainter p(pd); @@ -136,6 +161,12 @@ void runTests(TQPaintDevice* pd) { p.drawCubicBezier(a); } + // Pixmap tests + { + TQPixmap pixmap("open.png"); + p.drawPixmap(200, 10, pixmap, 0, 0, -1, -1); + } + // Font tests { static const char *fonts[] = { "Helvetica", "Courier", "Times", 0 }; @@ -163,6 +194,9 @@ void runTests(TQPaintDevice* pd) { } } + //drawColorWheel(&p, 0.5); + //drawColorWheel(&p, 1.0); + p.end(); } -- cgit v1.2.1