Radio rendering pixel-exact: the display's circle routine
Harvested the cir/cirs output for every radius 1..159 from Nextion Editor's simulator and derived the incremental midpoint rule that reproduces all of them; radio = width-sized circle clipped to the box, dot radius r//2. Basic rendering coverage 18/20. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6f8341c66c
commit
9b50eea03f
7 files changed
+83
-14
No files matched your search
@@ -71,6 +71,25 @@ class Render(unittest.TestCase):
|
||||
img = self.render(p)
|
||||
self.assertEqual(img.getpixel((10, 0)), (65, 68, 65)) # dark top edge when on
|
||||
|
||||
def test_circle_routine(self):
|
||||
from nxhmi.render import circle_octant, disc_rows
|
||||
# measured from the Editor simulator (`cir 240,160,39,0`)
|
||||
self.assertEqual(circle_octant(39), [(39, 0), (39, 1), (39, 2), (39, 3), (39, 4), (39, 5), (38, 6), (38, 7),
|
||||
(38, 8), (38, 9), (37, 10), (37, 11), (37, 12), (36, 13), (36, 14), (36, 15),
|
||||
(35, 16), (35, 17), (34, 18), (34, 19), (33, 20), (32, 21), (32, 22), (31, 23),
|
||||
(30, 24), (29, 25), (28, 26), (27, 27)])
|
||||
self.assertEqual(circle_octant(13)[-1], (9, 9)) # diagonal point kept
|
||||
self.assertEqual(disc_rows(19)[19], 3)
|
||||
|
||||
def test_radio(self):
|
||||
p = C.new_page("p", w=100, h=100)
|
||||
C.add(p, "radio", x=0, y=0, w=80, h=80, val=1, bco=0xFFE0, pco=0x001F)
|
||||
img = self.render(p)
|
||||
self.assertEqual(img.getpixel((0, 39)), (65, 68, 65)) # ring, radius 39 around (39, 39)
|
||||
self.assertEqual(img.getpixel((39, 39)), (0, 0, 255)) # dot radius 19
|
||||
self.assertEqual(img.getpixel((39 + 19, 39)), (0, 0, 255))
|
||||
self.assertEqual(img.getpixel((39 + 20, 39)), (255, 255, 0))
|
||||
|
||||
def test_demo_pages_render(self):
|
||||
from nxhmi.render import Renderer
|
||||
r = Renderer(HMIFile.load(FIXTURE))
|
||||
|
||||
Reference in new issue
Block a user