pydemo: extract demo from main module

This commit is contained in:
nick black 2020-02-20 00:25:08 -05:00
parent 1c05fdb013
commit e9818fe8e8
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
2 changed files with 22 additions and 21 deletions

View File

@ -105,23 +105,3 @@ class Ncdirect:
if __name__ == '__main__':
locale.setlocale(locale.LC_ALL, "")
nc = Notcurses()
c = Cell(nc.stdplane())
c.setBgRGB(0x80, 0xc0, 0x80)
nc.stdplane().setBaseCell(c)
dims = nc.stdplane().getDimensions()
r = 0x80
g = 0x80
b = 0x80
for y in range(dims[0]):
for x in range(dims[1]):
nc.stdplane().setFgRGB(r, g, b)
nc.stdplane().setBgRGB(b, r, g)
nc.stdplane().putSimpleYX(y, x, b'X')
b = b + 2
if b == 256:
b = 0
g = g + 2
if g == 256:
g = 0
r = r + 2
nc.render()

View File

@ -4,7 +4,28 @@ import locale
from notcurses import notcurses
def demo():
n = notcurses.Notcurses()
nc = notcurses.Notcurses()
c = notcurses.Cell(nc.stdplane())
c.setBgRGB(0x80, 0xc0, 0x80)
nc.stdplane().setBaseCell(c)
dims = nc.stdplane().getDimensions()
r = 0x80
g = 0x80
b = 0x80
for y in range(dims[0]):
for x in range(dims[1]):
nc.stdplane().setFgRGB(r, g, b)
nc.stdplane().setBgRGB(b, r, g)
nc.stdplane().putSimpleYX(y, x, b'X')
b = b + 2
if b == 256:
b = 0
g = g + 2
if g == 256:
g = 0
r = r + 2
nc.render()
locale.setlocale(locale.LC_ALL, "")
demo()