55.3k views
2 votes
a triangle is defined by the three vertices. write the following functions of the triangle class assume that the point class has already been written for you you may add helper functions as needed

User Castorix
by
5.0k points

1 Answer

6 votes

Answer:

The triangle() function is an inbuilt function in p5.js which is used to draw a triangle in a plane. This function accepts three vertices of triangle.

Syntax:

triangle(x1, y1, x2, y2, x3, y3)

Below programs illustrates the triangle() function in p5.js:

function setup() {

createCanvas(400, 400);

}

function draw() {

background(220);

fill('lightgreen');

// A triangle at (100, 250), (250, 170) and (330, 300)

triangle(100, 250, 250, 170, 330, 300);

}

User Joep
by
5.0k points