Main Content

Drawing Filled Quadrilaterals and Triangles

This is an extension to my graphics libraries to plot filled quadrilaterals and triangles.

It is designed for use with my colour TFT graphics library, Tiny TFT Graphics Library 2.

With one minor change it can also be used with the version of that library that supports reading from supported TFT displays, Reading from a TFT Display. It will probably also work with other graphics libraries.

The triangle and quadrilateral plotting routines share much of the same code, so the resulting routines are quite compact, and should fit on microcontrollers with limited memory.

You may wonder why I didn’t just write a routine to plot filled triangles, and then draw quadrilaterals as two adjacent triangles. The answer is that with the libraries that support exclusive-OR plotting this results in a visible line between the two triangles, because that line is drawn twice; having a dedicated routine to plot quadrilaterals avoids this. In addition, this routine is faster.”

Link to article