demos/demo_buffer.py
author Radek Brich <radek.brich@devl.cz>
Fri, 14 Mar 2014 10:03:36 +0100
changeset 80 573a9e76719d
parent 79 dbdc38f9981a
child 81 5cd40c30c4f2
permissions -rwxr-xr-x
Move UnicodeGraphics to core. Update it.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
78
6031e99c8ad3 Add Buffer class with basic drawing methods.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     1
#!/usr/bin/env python3
6031e99c8ad3 Add Buffer class with basic drawing methods.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     2
6031e99c8ad3 Add Buffer class with basic drawing methods.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     3
import sys
6031e99c8ad3 Add Buffer class with basic drawing methods.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     4
sys.path.append('..')
6031e99c8ad3 Add Buffer class with basic drawing methods.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     5
6031e99c8ad3 Add Buffer class with basic drawing methods.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     6
from tuikit.core.buffer import Buffer
6031e99c8ad3 Add Buffer class with basic drawing methods.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     7
6031e99c8ad3 Add Buffer class with basic drawing methods.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     8
6031e99c8ad3 Add Buffer class with basic drawing methods.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
     9
buf = Buffer(16, 8)
6031e99c8ad3 Add Buffer class with basic drawing methods.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    10
buf.fill(c='#')
6031e99c8ad3 Add Buffer class with basic drawing methods.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    11
buf.hline(1, 1, 14, c='-')
6031e99c8ad3 Add Buffer class with basic drawing methods.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    12
buf.hline(1, 6, 14, c='-')
6031e99c8ad3 Add Buffer class with basic drawing methods.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    13
buf.vline(7, 2, 4, c='|')
6031e99c8ad3 Add Buffer class with basic drawing methods.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    14
buf.puts(8, 4, 'Hello!')
6031e99c8ad3 Add Buffer class with basic drawing methods.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    15
6031e99c8ad3 Add Buffer class with basic drawing methods.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    16
for y in range(buf.size.h):
6031e99c8ad3 Add Buffer class with basic drawing methods.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    17
    for x in range(buf.size.w):
79
dbdc38f9981a Add attribute storage to Buffer.
Radek Brich <radek.brich@devl.cz>
parents: 78
diff changeset
    18
        print(buf.get(x, y)[0], end='')
78
6031e99c8ad3 Add Buffer class with basic drawing methods.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    19
    print()