This is a triangle thingy, that’s what the file is called so I’m going with that name, i made it a couple months ago, pretty simple but i think it turned out great, click the coloured circles to move the triangle
float x1 = 250; float y1 = 100; float x2 = 100; float y2 = 400; float x3 = 400; float y3 = 400;
float pointSize = 30;
color c1 = #FF0000; color c2 = #00FF00; color c3 = #0000FF;
float a; float b; float c;
float a1; float a2; float a3;
float s; float area;
void setup(){
size(500,500);
textSize(20);
}
void draw(){
background(200);
//lines
line(x1,y1,x2,y2);
line(x2,y2,x3,y3);
line(x3,y3,x1,y1);
//points
fill(c1); ellipse(x1,y1,pointSize,pointSize);
fill(c2); ellipse(x2,y2,pointSize,pointSize);
fill(c3); ellipse(x3,y3,pointSize,pointSize);
//find lengths of sides
a = (sqrt(sq(x2-x1) + sq(y2-y1))); //R-G
b = (sqrt(sq(x3-x2) + sq(y3-y2))); //G-B
c = (sqrt(sq(x1-x3) + sq(y1-y3))); //B-R
//find angles
a1 = degrees(acos((b * b + c * c - a * a) / (2 * b * c)));
a2 = degrees(acos((c * c + a * a - b * b) / (2 * c * a)));
a3 = degrees(acos((a * a + b * b - c * c) / (2 * a * b)));
//Area
s = (a+b+c)/2;
area = sqrt(s * (s-a) * (s-b) * (s-c));
//text
fill(255,0,0); text(str(int(x1))+","+str(int(y1))+" "+str(a1)+"°",10,20);
fill(0,255,0); text(str(int(x2))+","+str(int(y2))+" "+str(a2)+"°",10,40);
fill(0,0,255); text(str(int(x3))+","+str(int(y3))+" "+str(a3)+"°",10,60);
fill(0); text("Area:"+area,10,80);
}
void mousePressed(){
//change the colour of the points as they're dragged
if (mouseX >= x1-(pointSize/2) & mouseX <= x1+(pointSize/2) & mouseY >= y1-(pointSize/2) & mouseY <= y1+(pointSize/2)){c1 = #C80000;}
if (mouseX >= x2-(pointSize/2) & mouseX <= x2+(pointSize/2) & mouseY >= y2-(pointSize/2) & mouseY <= y2+(pointSize/2)){c2 = #00C800;}
if (mouseX >= x3-(pointSize/2) & mouseX <= x3+(pointSize/2) & mouseY >= y3-(pointSize/2) & mouseY <= y3+(pointSize/2)){c3 = #0000C8;}
}
void mouseDragged(){
//Move the points
if (mouseX >= x1-(pointSize/2) & mouseX <= x1+(pointSize/2) & mouseY >= y1-(pointSize/2) & mouseY <= y1+(pointSize/2)){
x1 = mouseX;
y1 = mouseY;}
else if (mouseX >= x2-(pointSize/2) & mouseX <= x2+(pointSize/2) & mouseY >= y2-(pointSize/2) & mouseY <= y2+(pointSize/2)){
x2 = mouseX;
y2 = mouseY;}
else if (mouseX >= x3-(pointSize/2) & mouseX <= x3+(pointSize/2) & mouseY >= y3-(pointSize/2) & mouseY <= y3+(pointSize/2)){
x3 = mouseX;
y3 = mouseY;}
}
void mouseReleased(){
//change them to their original colour when released
c1 = #FF0000; c2 = #00FF00; c3 = #0000FF;
}