# PieChart1.py
from Processing import *
window(500, 500)
background(255)

# Data
sci = 8
soc = 5
hum = 6

total = hum + soc + sci

# Fraction of pie
phum = hum/total
psci = sci/total
psoc = soc/total

# Center and size of chart
x = width()/2 - 100
y = height()/2
w = 200

# Init Legend
kx = x + w/2
ky = y + w/2
kw = 20
ks = 10

angle = 0

# Draw pie of humanities
theta = angle + phum * 2 * PI
fill(31, 149, 14)
arc(x, y, w, w, angle, theta)

rect(kx, ky, kw, kw)
fill(0)
text("% Humanities", kx+kw+ks, ky+kw)

# Draw pie for social sciences
angle = theta
theta = angle + psoc * 2 * PI
fill(214, 124, 13)
arc(x, y, w, w, angle, theta)

ky = ky + 2*kw
rect(kx, ky, kw, kw)
fill(0)
text("% Social Sciences", kx+kw+ks, ky+kw)

# Draw pie for sciences
angle = theta
theta = angle + psci * 2 * PI
fill(214, 13, 211)
arc(x, y, w, w, angle, theta)

ky = ky + 2*kw
rect(kx, ky, kw, kw)
fill(0)
text("% Sciences", kx+kw+ks, ky+kw)
