14 : color(
std::move(color)) {}
26 cairo_pattern_set_extend(pat, CAIRO_EXTEND_REFLECT);
29 cairo_pattern_set_extend(pat, CAIRO_EXTEND_REPEAT);
33 cairo_pattern_set_extend(pat, CAIRO_EXTEND_PAD);
40 auto bbox2user =
Geom::Affine(bbox->width(), 0, 0, bbox->height(), bbox->left(), bbox->top());
48 auto pat = cairo_pattern_create_linear(
x1,
y1,
x2,
y2);
53 for (
auto &stop :
stops) {
55 if (stop.color.has_value()) {
71 double tolerance = cairo_get_tolerance(ct);
76 Geom::Affine bbox2user(bbox->width(), 0, 0, bbox->height(), bbox->left(), bbox->top());
90 double dx = d_user.
x(), dy = d_user.
y();
91 cairo_user_to_device_distance(ct, &dx, &dy);
96 double dl = hypot(dx, dy);
97 double tx = tolerance * dx / dl, ty = tolerance * dy / dl;
98 cairo_device_to_user_distance(ct, &tx, &ty);
99 double tolerance_user = hypot(tx, ty);
101 if (d_user.
length() + tolerance_user > r_user.
length()) {
105 scale *= 1.0 - 2.0 * tolerance / dl;
108 auto pat = cairo_pattern_create_radial(
scale * d.
x() + center.
x(),
scale * d.
y() + center.
y(), focusr, center.
x(), center.
y(), radius);
113 for (
auto &stop :
stops) {
115 if (stop.color.has_value()) {
126 std::cout <<
"sp_meshgradient_create_pattern: " << bbox <<
" " << opacity << std::endl;
129 auto pat = cairo_pattern_create_mesh();
131 for (
int i = 0; i <
rows; i++) {
132 for (
int j = 0; j <
cols; j++) {
135 cairo_mesh_pattern_begin_patch(pat);
136 cairo_mesh_pattern_move_to(pat,
data.points[0][0].x(),
data.points[0][0].y());
138 for (
int k = 0; k < 4; k++) {
139 switch (
data.pathtype[k]) {
144 cairo_mesh_pattern_line_to(pat,
data.points[k][3].x(),
data.points[k][3].y());
148 cairo_mesh_pattern_curve_to(pat,
data.points[k][1].x(),
data.points[k][1].y(),
149 data.points[k][2].x(),
data.points[k][2].y(),
150 data.points[k][3].x(),
data.points[k][3].y());
154 std::cerr <<
"sp_mesh_create_pattern: path error" << std::endl;
157 if (
data.tensorIsSet[k]) {
159 cairo_mesh_pattern_set_control_point(pat, k, t.
x(), t.
y());
162 cairo_mesh_pattern_set_corner_color_rgba(pat, k,
166 data.opacity[k] * opacity);
169 cairo_mesh_pattern_end_patch(pat);
176 Geom::Affine bbox2user(bbox->width(), 0, 0, bbox->height(), bbox->left(), bbox->top());
177 gs2user *= bbox2user;
void ink_cairo_pattern_add_color_stop(cairo_pattern_t *ptn, double offset, Inkscape::Colors::Color const &color, double opacity)
void ink_cairo_pattern_set_matrix(cairo_pattern_t *cp, Geom::Affine const &m)
cairo_pattern_t * ink_cairo_pattern_create(Inkscape::Colors::Color const &color, double opacity)
Cairo integration helpers.
3x3 matrix representing an affine transformation.
Affine inverse() const
Compute the inverse matrix.
Affine withoutTranslation() const
Axis-aligned rectangle that can be empty.
Two-dimensional point that doubles as a vector.
Coord length() const
Compute the distance from origin.
constexpr Coord y() const noexcept
constexpr Coord x() const noexcept
void common_setup(cairo_pattern_t *pat, Geom::OptRect const &bbox, double opacity) const
Perform some common initialization steps on the given Cairo pattern.
std::vector< SPGradientStop > stops
cairo_pattern_t * create_pattern(cairo_t *, Geom::OptRect const &bbox, double opacity) const override
Produce a pattern that can be used for painting with Cairo.
cairo_pattern_t * create_pattern(cairo_t *, Geom::OptRect const &bbox, double opacity) const override
Produce a pattern that can be used for painting with Cairo.
std::vector< std::vector< PatchData > > patchdata
virtual ~DrawingPaintServer()=0
cairo_pattern_t * create_pattern(cairo_t *ct, Geom::OptRect const &bbox, double opacity) const override
Produce a pattern that can be used for painting with Cairo.
std::vector< SPGradientStop > stops
DrawingSolidColor(Colors::Color color)
cairo_pattern_t * create_pattern(cairo_t *, Geom::OptRect const &, double opacity) const override
Produce a pattern that can be used for painting with Cairo.
Representation of paint servers used when rendering.
_cairo_pattern cairo_pattern_t
Helper class to stream background task notifications as a series of messages.
@ SP_GRADIENT_SPREAD_REPEAT
@ SP_GRADIENT_SPREAD_REFLECT
@ SP_GRADIENT_UNITS_OBJECTBOUNDINGBOX