Best way to draw and fill a polygon


I am trying to create an artificial horizon - part of this involves drawing four-six sided shapes that update frequently and are filled. I have tried for example drawing one line at a time using line commands, but this seems to slow the Nextion down. I’ve also tried using a PIC approach but unfortunately the pics are too large when uploaded. Any ideas about a fast and nimble way to draw polygons using the Nextion editor?

Filling polygons is a mathematical challenge and ways above the head of a Cortex M0 CPU (at least if you want an acceptable timing) like the one on the Nextion HMIs, even on assembly level.
Most polygon filling algorithms rely on painting the boundaries first, and then start filling the interior until an already colored boundary pixel is found. The use of these is not possible on the Nextion since you have no means to read back the color of a specific pixel.
You could instead use one of the algorithms of the scan line techniques group. But since you can’t read out pixels, you’d have to calculate several intersection points with the polygon edges for each single scan line before you start drawing along this specific line. This could be done in Nextion code, but I’d worry about execution speed.
There are special graphic processors (GPUs) which have polygon drawing commands and the ability to decompose a complex polygon into several simpler ones in their hardware instruction set. But then, we are in the >300USD Nvidia product range and not longer on a 20USD HMI…