[Qt-interest] QPainter scale and rotate issue
Yawar Amin
yawar.amin at gmail.com
Thu Sep 2 03:42:59 CEST 2010
Hi,
I'm trying to teach myself simple QPainter usage and I have a QWidget-derived class as per attachments. I'm capturing the paint event and trying to draw a Pythagorean tree [1] using a 3-4-5 right triangle as the basis, with the following steps:
1. Draw the square with the 5 side, i.e. the one that corresponds to the hypotenuse, scaled up to 100 units. Draw from the top-left corner of the square and place the square at the bottom of the widget area.
2. Rotate the painter by -120, scale up to 80 units, and draw the square corresponding to the 4 side.
3. Translate the painter to the top right corner of the square, rotate by -120, scale up to 60 units, and draw the square corresponding to the 3 side.
Now according to Pythagoras, the three squares should meet to form a right triangle. But the top two triangles end up never meeting, no matter how much I tweak the rotating and scaling.
Probably I'm doing something glaringly wrong? Can anyone comment?
Thanks,
Yawar
[1] http://en.wikipedia.org/wiki/Pythagoras_tree
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pythagoras_tree_qt.cpp
Type: application/octet-stream
Size: 760 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100901/9af6fe7b/attachment.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pythagoras_tree_qt.h
Type: application/octet-stream
Size: 105 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100901/9af6fe7b/attachment-0001.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pythagoras_tree_qt.pro
Type: application/octet-stream
Size: 344 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100901/9af6fe7b/attachment-0002.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: imperfect_pythag_tree.png
Type: image/png
Size: 31748 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100901/9af6fe7b/attachment.png
-------------- next part --------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 194 bytes
Desc: This is a digitally signed message part
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100901/9af6fe7b/attachment.bin
More information about the Qt-interest-old
mailing list