Here is what I submitted to Melange, let me know if anything else is necessary:
Inkscape requires several high level path manipulation routines to implement some of its effects:
- Boolean operations on paths. - Stroke-to-path conversion: given a path and stroke parameters, compute the shape of the stroke and return it as a new path. - Path offset.
These operations are both available directly to the user and used as a building block for more complex effects. The current implementation uses a grid-based algorithm which rounds all coordinates to a multiple of some arbitrary quantum. This has several shortcomings - most notably it does not preserve the dimensions of the operands (see [1]).
To provide a robust foundation for further feature development, this project will implement robust Boolean and stroke-to-path operations. The API will look as follows:
class Path { ... void stroke(Coord width); void stroke(Coord width, std::vector<Coord> dash_array, Coord dash_offset); Geom::OptRect strokedBounds(Coord width); Geom::OptRect strokedBounds(Coord width, std::vector<Coord> dash_array, Coord dash_offset);
Path &operator|=(Path const &p); Path &operator&=(Path const &p); Path &operator^=(Path const &p); Path &operator-=(Path const &p);
bool contains(Path const &p); };
Operator helpers will allow developers to write code such as:
Path result = path_a & path_b;
Boolean operations will be implemented by copying the algorithm used by CGAL [2]. If necessary, CGAL will be added as a dependency of 2Geom, but will be hidden from users of the library (CGAL headers will not be required to build programs using 2Geom). Stroking operations will be based on the existing curve offset code for single paths available in 2Geom's offset toy. The stroke will be computed as an union of the offsets of all curves and the resulting shape will be post-processed to add joins and caps.
Once the new operations are available, the Inkscape codebase will be modified to make use of them, and the current implementation from the livarot library will be removed.
Additionally, the following smaller work-items will be done in the preparatory phase:
- 2Geom's Path class will be renamed to Subpath, and the PathVector class will be renamed to Path, to mirror SVG terminology. - Copy-on-write functionality will be moved from Subpath to Path. - Various helper methods will be added to Path to simplify existing code. - The SPCurve class will be removed.
Schedule:
- before June 10: complete the items from the preparatory list, bounding box computation for stroked paths, read CGAL code and determine if adding it as a dependency is required - June 10 - June 30: final exams at my university - after June 30: implementation of boolean operations, implementation of stroking
[1] https://bugs.launchpad.net/inkscape/+bug/168158 [2] http://doc.cgal.org/latest/Boolean_set_operations_2/index.html
Regards, Krzysztof
participants (1)
-
Krzysztof Kosiński