Click here for a list: http://gurakura.sakura.ne.jp/series/美大生のためのプログラミング入門/
Qiita version general table of contents: https://qiita.com/iigura/items/37180d127da93d0b8abb
The rectangle drawn by the function rect was a rectangle composed of horizontal and vertical line segments. However, rectangles are not the only rectangles, and the definition of a rectangle also includes more free-form rectangles.
The quad function is a function for drawing such a free rectangle. The arguments are quad (x1, y1, x2, y2, x3, y3, x4, y4), respectively.
x1, y1: x and y coordinates of the first vertex x2, y2: x and y coordinates of the second vertex x3, y3: x and y coordinates of the 3rd vertex x4, y4: x and y coordinates of the 4th vertex
It will be.
This kind of notation seems a bit redundant, so after that, for i = 1, ..., 4,
It may also be written as.
Let's actually draw a rectangle using the quad function
background(250,250,250); size(500,500); strokeWeight(10); stroke(0,64,255); fill(255,0,0); quad(70,50, 80,400, 400,300, 250,280);
At first glance, this rectangle looks like a group of triangles, but it is a solid rectangle with four vertices.
Since the quad function only draws a shape connecting the four specified vertices, it may not be a quadrangle depending on the parameters given (see the program and figure below).
Even in such a case, Processing does not issue any error or warning, so always check that the rectangle is drawn as intended.
background(250,250,250); size(500,500); strokeWeight(10); stroke(0,64,255); fill(255,0,0); quad(70,50, 80,400, 400,300, 150,480);