We are about to switch to a new forum software. Until then we have removed the registration on this forum.
In the examples section on the website, the Pie Chart example refers to the global "angles" array instead of the local function parameter "data". The example works because the sketch only calls pieChart while passing in the "angles" array. But a more robust, more copy-pasteable, less head-scratching example would refer to the "data" local variable instead of the "angle" global variable.
Who can make this change to the example on the website? Also, it is not clear which category this post ought to go into.
Answers
This is a modified version. Yes, I agree, the code in the website should be modified.
Kf
***Edited to reflect all angle calculations in radians
https://GitHub.com/processing/processing-docs/issues
https://GitHub.com/processing/processing-docs/blob/4ad6d1299e3357d4475d73daeed6d6fdc6e29de7/content/examples/Basics/Form/PieChart/PieChart.pde
http://studio.ProcessingTogether.com/sp/pad/export/ro.9cEo3JxuOM3wG
https://forum.processing.org/two/discussion/8115/changing-color-of-piechart
The only change needed is to change the references to the angles array
angles
to thedata
array there is nothing wrong in leaving theangles
array as global.Since these examples as aimed at beginners I don't see the need to over complicate the syntax.
@rtclay since you discovered the error you should have the honour of raising an issue at
https://GitHub.com/processing/processing-docs/issues
If there is a global and local access to data, I would take the local access. This would be a good introductory approach for this example. Just my two cents. Yes, nothing awfully wrong.... Oh wait, one sec. GoToLoop also found something missing: The arc function takes radians instead of degrees as their parameters (from the arc reference ):
Kf
Global vs local I don't mind in this case. The problem was that the method was referring to the array using the global reference AND the parameter reference when should have been only referencing the latter.
The original example converted the angles to radians to degrees before using them so nothing new there.
When I copied the example and I modified, I overlooked the radians part. I modified my post to reflect proper units.
Kf
Submitted a pull request to processing-docs:
https://github.com/processing/processing-docs/pull/530