Skip to content

clip_preserve()-related drawing bug on Windows #242

@schmave

Description

@schmave

The sample Python code below draws this on a Mac using pycairo 1.20.1 and cairo 1.16.0 (installed via Homebrew):

example

On Windows using pycairo 1.20.0 and 1.20.1 (installed via pip using the Windows wheel), it draws this:

Screen Shot 2021-09-10 at 2 44 16 PM

import cairo

WIDTH, HEIGHT = 400, 400

surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, WIDTH, HEIGHT)
ctx = cairo.Context(surface)

ctx.scale(WIDTH, HEIGHT)

points = [[200, 100], [222.45139882897308, 169.09830056251377], [295.10565162951536, 169.09830056250527], [236.32712640025804, 211.80339887498624], [258.7785252292473, 280.90169943749476], [200.0, 238.196601125], [141.22147477075268, 280.9016994374947], [163.67287359974196, 211.80339887498624], [104.89434837048466, 169.09830056250522], [177.54860117102692, 169.09830056251377]]

ctx.new_path()
ctx.move_to(points[0][0] / WIDTH, points[0][1] / HEIGHT)
for point in points[1:]:
    ctx.line_to(point[0] / WIDTH, point[1] / HEIGHT)
ctx.close_path()

ctx.set_source_rgb(1, 0 ,0)

ctx.fill_preserve()
ctx.clip_preserve()

ctx.set_source_rgb(0, 1, 0)
ctx.set_line_width(.05)
ctx.stroke()

surface.write_to_png("example.png")

Any ideas what might be causing this? Let me know if I can provide any more information that would be helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions