Review Request: Rectangular and square gradient support
Lukáš Tvrdý
lukast.dev at gmail.com
Wed Oct 5 14:33:34 BST 2011
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/102780/
-----------------------------------------------------------
Review request for Calligra, Jan Hambrecht and Thorsten Zachmann.
Description
-------
Bugs: displays gradient of shapes from bug https://bugs.kde.org/show_bug.cgi?id=274909
Ellipsoid gradient is missing so far.
This patch adds support for ODF gradient style rectangular and square.
First I was trying to integrate gradients into KoGradientBackground, but shortly I noticed
that it is crashing as the editing tools require QGradient and are tied to it. So some abstraction
and re-factoring will be needed to support of creation and editing of the constructed ODF gradients.
Then I decided to introduce new class KoOdfGradientBackground which is not editable and integrate nicely.
Saving and loading of gradients work.
The gradients have many options like position, rotation, border. So far square gradients support
all of them, though rotation of gradient is showing some artifacts, small pixels, I was not able to fix them.
Rectangular type does not support rotation.
Rotation would probably require to compute the gradient per pixel, which might be slow. I was trying to use QPainter and combination of QGradient and
clipping to create the gradients effectively. I found inspiration here http://ariya.ofilabs.com/2011/06/rectangular-gradient.html
for square gradient.Rectangular gradient was done in similar way.
There was some problem with alias when rendering the gradients. First I was trying to solve it by supersampling,
then I wanted to use the exact size of the shape in pixels (without zooming). Then I ended up to compute
the pixel size of the shape on the canvas.
There are two possibilities: to add new parameter KoViewConverter to paint method of the KoShapeBackground,
in the patch you can see it is not that much effort. Zagge was in a favor to not to add that parameter and
he was suggesting to use QPainter's matrix as that one already includes the zooming information.
The patch includes the changes needed to include KoViewConverter, I will drop them if the preferred
way is to use paint's QPainter matrix, which so far works as needed.
Square gradients in words
http://wstaw.org/m/2011/10/05/plasma-desktopoo2237.jpg
Rectangular gradients in words
http://wstaw.org/m/2011/10/05/plasma-desktopLg2237.jpg
Diffs
-----
libs/flake/CMakeLists.txt dad0c9a
libs/flake/KoColorBackground.h 6cf70d3
libs/flake/KoColorBackground.cpp 08692ee
libs/flake/KoGradientBackground.h be21eec
libs/flake/KoGradientBackground.cpp a56b7c3
libs/flake/KoOdfGradientBackground.h PRE-CREATION
libs/flake/KoOdfGradientBackground.cpp PRE-CREATION
libs/flake/KoPathShape.cpp 4c5ffb6
libs/flake/KoPatternBackground.h d372677
libs/flake/KoPatternBackground.cpp 577bf3d
libs/flake/KoShape.cpp 6b07e7c
libs/flake/KoShapeBackground.h 7822c50
Diff: http://git.reviewboard.kde.org/r/102780/diff/diff
Testing
-------
I'm going to test it with cstester, I don't expect any regressions as the code handles previously non-handled ODF gradients.
Thanks,
Lukáš Tvrdý
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/calligra-devel/attachments/20111005/04829084/attachment.htm>
More information about the calligra-devel
mailing list