41 _ctx.set_group_matrix(tr[0], tr[1], tr[2], tr[3], tr[4], tr[5]);
50 _ctx.cmd_cm(tr[0], tr[1], tr[2], tr[3], tr[4], tr[5]);
56 doc.generator().new_transparency_group_context(
65 capypdf::TransparencyGroupProperties
props;
67 props.set_CS(CAPY_DEVICE_CS_GRAY);
73 _ctx.set_transparency_group_properties(
props);
90 bool isolate = tr !=
Geom::identity() || !style_map.empty() ||
true;
119 }
else if (
auto shape = cast<SPShape>(
item)) {
120 if (shape->curve() && !shape->curve()->empty()) {
123 }
else if (
auto use = cast<SPUse>(
item)) {
125 }
else if (
auto text = cast<SPText>(
item)) {
127 }
else if (
auto flowtext = cast<SPFlowtext>(
item)) {
129 }
else if (
auto image = cast<SPImage>(
item)) {
131 }
else if (
auto group = cast<SPGroup>(
item)) {
134 bool has_ocg =
false;
135 if (group->isLayer()) {
136 if (
auto label = group->label()) {
137 auto ocg = capypdf::OptionalContentGroup(
label);
149 g_warning(
"Unknown object: %s",
get_id(
item).c_str());
160 if (
auto child_item = cast<SPItem>(&obj)) {
163 std::optional<CapyPDF_TransparencyGroupId> mask_id;
169 std::vector<SPObject *> links;
173 if (!is<SPGroup>(child_item) && !mask_id && links.empty() && !
style_needs_group(child_item->style)) {
175 paint_item(child_item, child_item->transform, context_style);
193 for (
auto &child_obj : use->
children) {
194 if (
auto child_item = cast<SPItem>(&child_obj)) {
199 g_warning(
"Couldn't paint clone: '%s'",
get_id(use).c_str());
209 std::optional<CapyPDF_TransparencyGroupId> soft_mask)
222 _ctx.cmd_Do(child_id);
236 auto const style = shape->
style;
276 for (
auto [loc, marker, tr] : shape->
get_markers()) {
static SPStyleProp const props[]
Lookup dictionary for attributes/properties.
3x3 matrix representing an affine transformation.
Axis-aligned rectangle that can be empty.
Sequence of contiguous curves, aka spline.
std::optional< CapyPDF_TransparencyGroupId > item_to_transparency_group(SPItem const *item, SPStyle const *context_style=nullptr, bool is_soft_mask=false)
Render any type of item into a transparency group.
StyleMemory & paint_memory()
std::optional< CapyPDF_GraphicsStateId > get_group_graphics_state(SPStyle const *style, std::optional< CapyPDF_TransparencyGroupId > sm)
Set the style for any graphic from the SVG style.
std::optional< CapyPDF_GraphicsStateId > get_shape_graphics_state(SPStyle const *style)
Like get_graphics_style but for drawing shapes (paths)
bool get_text_enabled() const
unsigned get_filter_resolution() const
std::optional< CapyPDF_TransparencyGroupId > mask_to_transparency_group(SPMask const *mask, Geom::Affine const &transform)
Render a mask out to a transparency group context.
void paint_group(CapyPDF_TransparencyGroupId child_id, SPStyle const *style=nullptr, Geom::Affine const &tr=Geom::identity(), std::optional< CapyPDF_TransparencyGroupId > soft_mask={})
Paint a child group at the requested location.
void paint_item_to_raster(SPItem const *item, Geom::Affine const &tr, double resolution, bool antialias)
Draw an item as a bitmap and return.
void set_matrix(Geom::Affine const &affine)
Set the transformation matrix for this context Group.
void paint_raster(SPImage const *image)
Draw the raster data stored in URI into the PDF context.
void paint_item_clone(SPUse const *use, SPStyle const *context_style)
Paint the given clone object, finding or generating a transparency group from it.
void clip_text_layout(Text::Layout const &layout)
Use the text object as a clipping mask in the PDF.
void start_ocg(CapyPDF_OptionalContentGroupId ocgid)
void set_clip_rectangle(Geom::OptRect const &rect)
Apply the clipping rectangle with a NONZERO fill rule.
bool set_shape_pathvector(Geom::PathVector const &pathv)
void set_clip_path(std::optional< Geom::PathVector > clip, SPStyle *style=nullptr)
Apply the clip path to the existing context.
capypdf::DrawContext _ctx
bool set_shape(SPShape const *shape)
void paint_item(SPItem const *item, Geom::Affine const &tr=Geom::identity(), SPStyle const *context_style=nullptr)
Paint the given object into the given context, making groups if needed.
void paint_shape(SPShape const *shape, SPStyle const *context_style)
Paint a single shape path.
void set_paint_style(StyleMap const &map, SPStyle const *style, SPStyle const *context_style)
Set the style for drawing shapes from the SVG style, this is all the styles that relate to how vector...
void paint_text_layout(Text::Layout const &layout, SPStyle const *context_style)
Paint the given layout into the PDF document Drawing content.
void transform(Geom::Affine const &affine)
Add a transform to the current context stream.
void paint_item_group(SPGroup const *group, SPStyle const *context_style)
GroupContext(Document &doc, Geom::OptRect const &clip, bool soft_mask=false)
ItemContext(Document &doc, SPItem const *item)
ItemCacheKey cache_key() const
StyleMap get_ifset(SPStyle const *style) const
Return a StyleMap of all the set styles, filtered in the same way as get_changes.
auto remember(StyleMap map)
Add the given map to the stack and return a scoped object.
Base class for visual SVG elements.
SPMaskReference & getMaskRef()
SPText const * getClipTextObject() const
Return the text object, IF and only if this item is clipped by a single SPText object.
bool isFiltered() const
Returns true if the item is filtered, false otherwise.
std::optional< Geom::PathVector > getClipPathVector() const
Return the path vector of the clipping region.
SPMask * getObject() const
SPStyle * style
Represents the style properties, whether from presentation attributes, the style attribute,...
Base class for shapes, including <path> element.
std::vector< std::tuple< SPMarkerLoc, SPMarker *, Geom::Affine > > get_markers() const
Lists every marker on this shape along with its transform and marker type.
T< SPAttr::CLIP_RULE, SPIEnum< SPWindRule > > clip_rule
clip-rule: 0 nonzero, 1 evenodd
T< SPAttr::FILL_RULE, SPIEnum< SPWindRule > > fill_rule
fill-rule: 0 nonzero, 1 evenodd
std::unique_ptr< Magick::Image > image
Various utility functions.
Affine identity()
Create an identity matrix.
std::tuple< std::string, std::string, std::string > ItemCacheKey
std::string get_id(SPObject const *obj)
Attempt to get an object's id, even if it's a clone.
std::vector< PaintLayer > get_paint_layers(SPStyle const *style, SPStyle const *context_style)
Get a PDF specific layer painting pattern for fill, stroke and markers.
bool style_needs_group(SPStyle const *style)
Return true if this shape's style requires a PDF transparency group.
static T clip(T const &v, T const &a, T const &b)
TODO: insert short description here.
SVG <image> implementation.
Some things pertinent to all visible shapes: SPItem, SPItemView, SPItemCtx.
SVG <pattern> implementation.
SPRoot: SVG <svg> implementation.
SPStyle - a style object for SPItem objects.