Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drawArc doesn't work consistently #201

Open
williamngan opened this issue Sep 18, 2023 · 2 comments
Open

drawArc doesn't work consistently #201

williamngan opened this issue Sep 18, 2023 · 2 comments

Comments

@williamngan
Copy link

Describe the bug
canvas.drawArc() fails silently in some cases

To Reproduce

Code to reproduce as follows. Run this multiple times to see some arcs may fail to draw.

import skia
import numpy as np
import matplotlib.pyplot as plt

width, height = 512, 512
array = np.zeros((height, width, 4), dtype=np.uint8)
rects = np.random.rand(10, 2, 2) * 512

with skia.Surface(array) as canvas:
    for r in rects:
        rect = skia.Rect.MakeLTRB(r[0][0], r[0][1], r[1][0], r[1][1])
        # fill oval in red
        paint = skia.Paint(
            AntiAlias=True,
            Color=0x33ff0000,
            Style=skia.Paint.kFill_Style,
        )
        canvas.drawOval(rect, paint)
        # draw arc in black line
        paint = skia.Paint(
            AntiAlias=True,
            Color=0xFF000000,
            StrokeWidth=5,
            Style=skia.Paint.kStroke_Style,
        )
        canvas.drawArc(rect, 30, 180, False, paint)

plt.imshow(array)
plt.show()

Result I got. Notice that some ovals don't have stroked arcs.
download

Expected behavior
drawArc() should work consistently as drawOval() above.

Desktop (please complete the following information):

  • OS: Ubuntu 20.04.5 LTS
  • Python: 3.11.0
  • skia-python version: 87.5

Additional context
Add any other context about the problem here.

@HinTak
Copy link
Collaborator

HinTak commented Sep 19, 2023

I am wondering if it is some kind of "optimization" where some of the drawing operations are re-ordered and dropped. So it might be interesting to re-write your code with a opengl backend and draw interactively (pause, and in response to a event to draw the next bit), and only convert to CPU array at the end (if you want a graphic file).

I have a suspicion that "earlier" drawarc's are dropped.

@HinTak
Copy link
Collaborator

HinTak commented Sep 19, 2023

So doing a deterministic seed for the random number, and actually writing the order out, which one is missing, would be interesting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants