@@ -1734,4 +1734,77 @@ async def test_redirect_to_remote_monitor(api):
17341734 await api .print ('Test finished successfully' )
17351735
17361736
1737+ pixels = '''
1738+ 0000000030030033333333330000000003000000000000000
1739+ 0333300000000033333333300000000000333333000000330
1740+ 0803000000803033333333000000000000880330300003000
1741+ 0800800030330333333333000300883000888880000033000
1742+ 3333000000003333333333300080038880000080000888003
1743+ 33333ddd3333333333333333300000333330000000000d033
1744+ 333dddddd3333333333333333333333333333333333ddd333
1745+ 3333ccdd333333333333344444444333333333333dddddd33
1746+ 333cc33d3333333333334444444444333333333335d3cc33d
1747+ 5ddc33333333333333344444444444433333333333333cd55
1748+ dddc555d3333333333344444444444433333333333d5dc5dd
1749+ d5dd5dd4bbbbbbbbb999b00b00300b3bb9999bbbb4ddddddd
1750+ ddd55444bb999993bbb33390b030bb9999bbbbbbb444ddddd
1751+ 55dd44bbbbbbbbbbbbb9bb3003003bbb339bbbbbbbb44444d
1752+ dd444bbbbbbbbbbb99933bbb0030b999bbbbbbbbbbbbbbb44
1753+ 444bbbbbbbbbbbbbbb9bbb33b309933bbbbbbbbbbbbbbbbbb
1754+ bbbbbbbbbbbbbbbbbbbb9bbbb3bbbb99bbbbbbbbbbbbbbbbb
1755+ bbbbbbbbbbbbbbbbbbbbbb399399bbbbbbbbbbbbbbbbbbbbb
1756+ ''' .strip ()
1757+
1758+
1759+ async def test_paintutils (api ):
1760+ from computercraft .subapis .paintutils import PaintutilsAPI
1761+ tbl = await get_object_table (api , 'paintutils' )
1762+ assert get_class_table (PaintutilsAPI ) == tbl
1763+
1764+ async with api .fs .open ('img.nfp' , 'w' ) as f :
1765+ await f .write (pixels )
1766+
1767+ # from pprint import pprint
1768+ int_pixels = await api .paintutils .loadImage ('img.nfp' )
1769+ assert len (int_pixels ) > 0
1770+ assert len (int_pixels [0 ]) > 0
1771+ assert await api .paintutils .parseImage (pixels ) == int_pixels
1772+
1773+ assert await api .paintutils .drawImage (int_pixels , 1 , 1 ) is None
1774+
1775+ await asyncio .sleep (2 )
1776+
1777+ await api .term .setTextColor (api .colors .white )
1778+ await api .term .setBackgroundColor (api .colors .black )
1779+ await api .term .clear ()
1780+ await api .term .setBackgroundColor (api .colors .green )
1781+
1782+ by = 3
1783+ bx = 3
1784+
1785+ assert await api .paintutils .drawPixel (bx , by ) is None
1786+ assert await api .paintutils .drawPixel (bx + 1 , by , api .colors .red ) is None
1787+
1788+ bx += 5
1789+
1790+ assert await api .paintutils .drawLine (bx , by , bx + 3 , by + 3 ) is None
1791+ assert await api .paintutils .drawLine (bx + 3 , by , bx , by + 3 , api .colors .red ) is None
1792+
1793+ bx += 5
1794+ assert await api .paintutils .drawBox (bx , by , bx + 3 , by + 3 ) is None
1795+ bx += 5
1796+ assert await api .paintutils .drawBox (bx , by , bx + 3 , by + 3 , api .colors .red ) is None
1797+
1798+ bx += 5
1799+ assert await api .paintutils .drawFilledBox (bx , by , bx + 3 , by + 3 ) is None
1800+ bx += 5
1801+ assert await api .paintutils .drawFilledBox (bx , by , bx + 3 , by + 3 , api .colors .red ) is None
1802+
1803+ await api .term .setCursorPos (1 , by + 6 )
1804+
1805+ await asyncio .sleep (2 )
1806+
1807+ await api .print ('Test finished successfully' )
1808+
1809+
17371810# vector won't be implemented, use python equivalent
0 commit comments