Possible approach for SVG clipping



  • Hi,
    Clipping of SVG vectors could be useful for many users. At present Qt does not support clipping of these vectors, i.e. slicing of SVG images. Of course there are commercial tools that slice SVGs amazingly well.
    Below is one approach I had in mind for some time (with inputs from Gunnar) and thought better document here ...

    1. Use QSvgRenderer to read svg file
    2. Modified/extend QSvgGenerator's drawPath (or drawXXXX) methods to slice various vectors
    3. Use Qpainter with QSvgGenerator as the paint device, to generate svg, which now has the vectors sliced
    4. For complex shapes, one could use the QPathClipper class to help out

    Thoughts/comments?



  • SVG clipping is more like buddy system....My point of view is data centric to add to above API centric info..

    SVG is a collection of drawn blocks..Now these blocks are drawn and can be clipped but clips are formed with nearby blocks combining together just like buddy system from memory allocation.
    http://en.wikipedia.org/wiki/Buddy_memory_allocation

    My thought is on to get data structure out for storing and forming clip so that if possible clips can be SVG or other desired format in the effecient way.



  • @aviral, qpainter allows u to clip regular raster images very well, I actually tried to use the same on a SVG image due to some requirement I had. Then noticed that svg clipping was not handled.

    Which other formats do you think we should target in the solution.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.