xxxxxxxxxx
93
function setup() {
createCanvas(400, 400);
}
function touchStarted(){runonce=true;}
var col=['red', 'orange', 'yellow', 'green', 'blue', 'purple', 'cyan', 'magenta', 'teal'];
var numChoices;
var runonce=true;
var x;
var y;
var r;
var etics=[];
var a=45; // angle of the arrow
var avel=20;
var offset;
var bg='white'; // background color
function draw() {
if(runonce)
{
x=width/2;
y=width/2;
r=height/2;
avel=Math.floor(random(5,50));
numChoices=Math.floor(random(3,9));
for(var i=0; i<numChoices; i++)
{
etics[i]=Math.floor(random(5,48))
}
offset=360/numChoices;
runonce=false;
}
background(bg);
strokeWeight(1)
stroke(0);
fill(0);
textSize(20);
text("Fuels ETIC Calculator", (width/2)-100, 30);
textSize(15)
text("Cause Fuck It", (width/2)-50, 50);
// Draw you pies
for(var i=0; i<numChoices; i++)
{
strokeWeight(1);
fill(col[i]);
//circle(width/2, height/2, 100);
arc(x,y, r,r, radians(i*offset), radians(i*offset+offset));
textx= ((r/2)+2) * cos(radians(i*offset+(offset/2))) +x;
texty= ((r/2)+2) * sin(radians(i*offset+(offset/2))) +y;
stroke(0)
fill(0)
textSize(20)
push()
translate(textx,texty)
rotate(radians((i*offset+offset/2)+90))
text(etics[i], 0,0);
//text(etics[i], textx, texty)
pop()
}
// Draw your arrow
strokeWeight(8);
point(x,y);
x2= ((r/2)-10) * cos(radians(a)) + x;
y2= ((r/2)-10) * sin(radians(a)) + y;
bg=col[Math.floor(a/offset)]
//console.log()
line(x, y, x2, y2);
a+=avel;
if(a>=360)
{
a=0;
}
avel*=0.99
if(avel<0.1)
{
avel=0;
strokeWeight(1)
stroke(0);
fill(0);
textSize(20);
final=etics[Math.floor(a/offset)]
if(final >10)
{
text("Etic: " + final + " hr(s).", x-50, y+height/3)
}
else
{
text("Etic: Parts + " + final + " hr(s).", x-75, y+height/3)
}
}
}