1
votes

I tried to find similar issues, tutorials about drawing arcs and circles and found nothing helpful for this question.

I'm playing with cairo and pycairo trying to draw a circle with quadrants.

I'm not sure if I'm getting lost in any point, but what I expect to draw, well, is not what I'm drawing at all.

My goal is to draw a circle with different quadrants, with a different fill color in every quadrant.

I build the surface and the context and I can draw a full circle (2 * PI), half a circle (PI) and when I try to draw only a quadrant (PI/2 -> 90 degrees) the result is something I don't understand.

First example, full circle (360 degress aka 2 * PI radians):

ctx.rectangle(0, 0,1200,1200) # Rectangle(x0,y0,w,h)
ctx.set_source_rgb(1,1,1)
ctx.fill()
ctx.arc(600,600,500,0,2*math.pi)
ctx.set_source_rgb(1,0,0)
ctx.fill()
ctx.stroke()

The result is correct, a full circle:

full circle as supposed to be with 2 * PI radians (360 degrees)

Second example, half circle (180 degrees, PI radians):

ctx.rectangle(0, 0,1200,1200) # Rectangle(x0,y0,w,h)
ctx.set_source_rgb(1,1,1)
ctx.fill()
ctx.arc(600,600,500,0,math.pi)
ctx.set_source_rgb(1,0,0)
ctx.fill()
ctx.stroke()

The result is correct, half circle:

(I have removed the image because I don't have enough reputation yet)

Third example, a quarter/quadrant (90 degrees, PI / 2):

ctx.rectangle(0, 0,1200,1200) # Rectangle(x0,y0,w,h)
ctx.set_source_rgb(1,1,1)
ctx.fill()
ctx.arc(600,600,500,0,math.pi/2)
ctx.set_source_rgb(1,0,0)
ctx.fill()
ctx.stroke()

I do not understand :-? What is happening here?

The supposed to be quadrant, PI/2 90 degrees

Please, someone could help me with this? I'm lost.

1

1 Answers

1
votes

I found a solution by myself, but I don't catch why the behavior is not exactly the same for every radian length.

If you issue a move_to:

ctx.move_to(600,600)

Now it renders perfectly. So thanks to all anyway.