Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
Geom::CairoPathSink Class Reference

Output paths to a Cairo drawing context. More...

#include <cairo-path-sink.h>

Inheritance diagram for Geom::CairoPathSink:
Geom::PathSink

Public Member Functions

 CairoPathSink (cairo_t *cr)
 
void moveTo (Point const &p) override
 Move to a different point without creating a segment.
 
void lineTo (Point const &p) override
 Output a line segment.
 
void curveTo (Point const &c0, Point const &c1, Point const &p) override
 Output a quadratic Bezier segment.
 
void quadTo (Point const &c, Point const &p) override
 Output a cubic Bezier segment.
 
void arcTo (Coord rx, Coord ry, Coord angle, bool large_arc, bool sweep, Point const &p) override
 Output an elliptical arc segment.
 
void closePath () override
 Close the current path with a line segment.
 
void flush () override
 Flush any internal state of the generator.
 
- Public Member Functions inherited from Geom::PathSink
virtual bool backspace ()
 Undo the last segment.
 
virtual void feed (Curve const &c, bool moveto_initial=true)
 
virtual void feed (Path const &p)
 Output a subpath.
 
virtual void feed (PathVector const &v)
 Output a path.
 
virtual void feed (Rect const &)
 Output an axis-aligned rectangle, using moveTo, lineTo and closePath.
 
virtual void feed (Circle const &e)
 Output a circle as two elliptical arcs.
 
virtual void feed (Ellipse const &e)
 Output an ellipse as two elliptical arcs.
 
virtual ~PathSink ()
 

Private Attributes

cairo_t_cr
 
Point _current_point
 

Detailed Description

Output paths to a Cairo drawing context.

This class converts from 2Geom path representation to the Cairo representation. Use it to simplify visualizing the results of 2Geom operations with the Cairo library, for example:

CairoPathSink sink(cr);
sink.feed(pv);
cairo_stroke(cr);
Output paths to a Cairo drawing context.

Currently the flush method is a no-op, but this is not guaranteed to hold forever.

Definition at line 57 of file cairo-path-sink.h.

Constructor & Destructor Documentation

◆ CairoPathSink()

Geom::CairoPathSink::CairoPathSink ( cairo_t cr)

Definition at line 40 of file cairo-path-sink.cpp.

Member Function Documentation

◆ arcTo()

void Geom::CairoPathSink::arcTo ( Coord  rx,
Coord  ry,
Coord  angle,
bool  large_arc,
bool  sweep,
Point const &  p 
)
overridevirtual

Output an elliptical arc segment.

See the EllipticalArc class for the documentation of parameters.

Implements Geom::PathSink.

Definition at line 73 of file cairo-path-sink.cpp.

References _cr, _current_point, Geom::EllipticalArc::finalAngle(), Geom::EllipticalArc::initialAngle(), and Geom::EllipticalArc::unitCircleTransform().

◆ closePath()

void Geom::CairoPathSink::closePath ( )
overridevirtual

Close the current path with a line segment.

Implements Geom::PathSink.

Definition at line 107 of file cairo-path-sink.cpp.

References _cr.

◆ curveTo()

void Geom::CairoPathSink::curveTo ( Point const &  c0,
Point const &  c1,
Point const &  p 
)
overridevirtual

Output a quadratic Bezier segment.

Implements Geom::PathSink.

Definition at line 56 of file cairo-path-sink.cpp.

References _cr, _current_point, cairo_curve_to(), Geom::X, and Geom::Y.

◆ flush()

void Geom::CairoPathSink::flush ( )
overridevirtual

Flush any internal state of the generator.

This call should implicitly finish the current subpath. Calling this method should be idempotent, because the default implementations of path() and pathvector() will call it multiple times in a row.

Implements Geom::PathSink.

Definition at line 112 of file cairo-path-sink.cpp.

◆ lineTo()

void Geom::CairoPathSink::lineTo ( Point const &  p)
overridevirtual

Output a line segment.

Implements Geom::PathSink.

Definition at line 50 of file cairo-path-sink.cpp.

References _cr, _current_point, cairo_line_to(), Geom::X, and Geom::Y.

◆ moveTo()

void Geom::CairoPathSink::moveTo ( Point const &  p)
overridevirtual

Move to a different point without creating a segment.

Usually starts a new subpath.

Implements Geom::PathSink.

Definition at line 44 of file cairo-path-sink.cpp.

References _cr, _current_point, cairo_move_to(), Geom::X, and Geom::Y.

◆ quadTo()

void Geom::CairoPathSink::quadTo ( Point const &  c,
Point const &  p 
)
overridevirtual

Output a cubic Bezier segment.

Implements Geom::PathSink.

Definition at line 62 of file cairo-path-sink.cpp.

References _cr, _current_point, cairo_curve_to(), Geom::X, and Geom::Y.

Member Data Documentation

◆ _cr

cairo_t* Geom::CairoPathSink::_cr
private

Definition at line 73 of file cairo-path-sink.h.

Referenced by arcTo(), closePath(), curveTo(), lineTo(), moveTo(), and quadTo().

◆ _current_point

Point Geom::CairoPathSink::_current_point
private

Definition at line 74 of file cairo-path-sink.h.

Referenced by arcTo(), curveTo(), lineTo(), moveTo(), and quadTo().


The documentation for this class was generated from the following files: