Last active
November 4, 2017 13:32
-
-
Save jacopocolo/69663014d276b4dfa56a4493b4315620 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var angles = [ 30, 10, 45, 35, 60, 38, 75, 67 ]; | |
function setup() { | |
createCanvas(400, 300); | |
noStroke(); | |
} | |
function draw() { | |
background(0); | |
pieChart(250, angles); | |
} | |
function pieChart(diameter, data) { | |
var lastAngle = 0; | |
for (var i = 0; i < data.length; i++) { | |
var gray = map(i, 0, data.length, 100, 255); | |
fill(gray); | |
arc(width/2, height/2, diameter, diameter, lastAngle, lastAngle+radians(angles[i])); | |
lastAngle += radians(angles[i]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment