# How to draw a pie chart?

0 favourites
• 7 posts
• The problem is that the DrawingCanvas object doesn't have an Arc-function. (I just added it to the feature requests.) That would probably be the easiest way, but isn't available for Construct3 (why??). It was available in Construct 2 and there's even a nice tutorial: https://www.construct.net/en/tutorials/draw-slices-dynamically-label-1295.

Some requirements for the arc/pie:

- Pixel-perfect alignment with backgroundpicture in the project.

- The pie must change every second because it's a kind of clock.

I tried:

- iFrame and use the Arc function of the Canvas, but aligning the arc with the background picture and make this work on every platform and screen size seems to be very complex.

- I thought that maybe by using scripting, I could get the context of the DrawingCanvas and use that to draw the arc, but 'GetContext' isn't available as a method of the Drawing Canvas Script Interface.

Thanks!

Wim

#### Tagged:

• Actually you can draw the arc by drawing multiple lines from the center of circle to every points on the circle:

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• You can draw sectors and arcs using different drawing blends. Here is an example:

• Dear Maverick1912 and dop2000,

The method of Maveric1912 seems the best of the two answers to me.

Maverick, do you have a .c3p file of upbeat-payne-96f97b.netlify.app ?

In the solution of dop2000 recalculating the sectors for every possible angle seems very complex (e.g. every quadrant needs a completely different polygon)

Thanks!

Wim

• In the solution of dop2000 recalculating the sectors for every possible angle seems very complex

It's not very complex. You can use these expressions to draw a line from the center of the circle at any angle:

``````X=centerX+length*cos(angle)
Y=centerY+length*sin(angle)
``````

.

• Thank you very much! Both your solutions are almost the same now.

Wim