demos/demo_buffer.py
author Radek Brich <radek.brich@devl.cz>
Fri, 14 Mar 2014 10:30:43 +0100
changeset 81 5cd40c30c4f2
parent 79 dbdc38f9981a
permissions -rwxr-xr-x
Add frame method to Buffer.
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!')
81
5cd40c30c4f2 Add frame method to Buffer.
Radek Brich <radek.brich@devl.cz>
parents: 79
diff changeset
    15
buf.frame()
78
6031e99c8ad3 Add Buffer class with basic drawing methods.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    16
6031e99c8ad3 Add Buffer class with basic drawing methods.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    17
for y in range(buf.size.h):
6031e99c8ad3 Add Buffer class with basic drawing methods.
Radek Brich <radek.brich@devl.cz>
parents:
diff changeset
    18
    for x in range(buf.size.w):
79
dbdc38f9981a Add attribute storage to Buffer.
Radek Brich <radek.brich@devl.cz>
parents: 78
diff changeset
    19
        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
    20
    print()