Skip to content

vpype doesn't understand svg clippath #122

Open
@cbmoore

Description

I'm using pycairo to generate PDFs and SVGs including some designs that use the clip functionality in cairo. SVGs generated this way use the clipPath but vpype does not seem to understand it. To be fair, neither does inkscape or the Axidraw software. As a result, designs using clipPath fail to plot correctly. Ideally, vpype would remove the content that is clipped by the clipPath.

Python code that generates the file is below. I attached the PDF so you can see what it should look like. The svg is attached as .txt to make it into a supported file type.

import cairo, math

WIDTH, HEIGHT = 5, 5

NLINES = 50
LWIDTH = 0.004

r1 = 0.19

#surface = cairo.PDFSurface('test_ce.pdf', 72 * WIDTH, 72 * HEIGHT)                                      
surface = cairo.SVGSurface('test_ce.svg', 72 * WIDTH, 72 * HEIGHT)
ctx = cairo.Context(surface)

ctx.scale(72 * WIDTH, 72 *  HEIGHT)  # Normalizing the canvas                                            
ctx.set_source_rgb(0,0,0)
ctx.set_line_width(LWIDTH)
ctx.set_fill_rule(cairo.FillRule.EVEN_ODD)

ctx.arc(.5, .5, r1, 0, 2 * math.pi)
ctx.arc(0.5, 0.5, r1 * 1.43, 0, 2 * math.pi)
ctx.clip()

for i in range(0, NLINES):
    x = float(i)/NLINES + LWIDTH/2.0
    ctx.move_to(x, 0)
    ctx.line_to(x, 1)

ctx.stroke()

test_ce.pdf

test_ce.svg.txt

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions