Beispiel #1
0
def show(filename):
    """Show track FILENAME as PNG file.

    FILENAME is a text file following the track file's conventions.
    """
    track = Track.read(filename)
    track.show()
Beispiel #2
0
def savemd(filename, filename_md, name, description):
    """Save track FILENAME as MD file."""
    track = Track.read(filename, name)
    p = Path(filename)
    if filename_md == '':
        filename_md = p.with_suffix('.md')
    track.save_md(filename_md, description)
Beispiel #3
0
def delcol(filename, col):
    """Delete column COL from track FILENAME.

    COL is the number of the column to delete.
    """
    track = Track.read(filename)
    track.del_col(col)
    track.save_txt(filename)
Beispiel #4
0
def delrow(filename, row):
    """Delete row ROW from track FILENAME.

    ROW is the number of the row to delete.
    """
    track = Track.read(filename)
    track.del_row(row)
    track.save_txt(filename)
Beispiel #5
0
def create(filename, nrow, ncol):
    """Create empty track FILENAME.

    NROW is the number of rows.
    NCOL is the number of columns.
    """
    track = Track.zeros(nrow, ncol)
    track.save_txt(filename)
    click.edit(filename=filename)
Beispiel #6
0
def savepng(filename, filename_png, show):
    """Save track FILENAME as PNG file."""
    track = Track.read(filename)
    p = Path(filename)
    if filename_png == '':
        filename_png = p.with_suffix('.png')
    track.save_img(filename_png)
    if show:
        track.show()
def test_track():
    # Arrays for the track
    tiles = np.array([[3, 2, 3], [2, 11, 2], [3, 2, 3]])
    orient = np.array([[1, 1, 0], [0, 0, 0], [2, 1, 3]])
    name = 'Test track'

    # Creation of the track
    track = Track(tiles, orient, name)
    assert (track.tiles == tiles).all()
    assert (track.orient == orient).all()
    assert track.name == name

    # Test string format
    with open(os.path.join(path, 'track.txt')) as f:
        assert f.read() == str(track)
Beispiel #8
0
def addrow(filename):
    """Add a row to track FILENAME."""
    track = Track.read(filename)
    track.add_row()
    track.save_txt(filename)
Beispiel #9
0
def addcol(filename):
    """Add a column to track FILENAME."""
    track = Track.read(filename)
    track.add_col()
    track.save_txt(filename)
Beispiel #10
0
def write(filename):
    """Write track FILENAME in the command prompt."""
    track = Track.read(filename)
    click.echo(track)
    logging.info('Track writed')
"""
Example 2: Importation of a track and exportation to PNG and MD
"""
from line_track_designer.track import Track

if __name__ == "__main__":
    # Import the track saved in a text file
    track = Track.read('track_colors/track_colors.txt', 'Colors track')
    # Export the track as png and markdown files
    track.save_md('track_colors/track_colors.md', 'A track with colors')
Beispiel #12
0
def rotate(filename, n):
    """Rotate track FILENAME."""
    track = Track.read(filename)
    track.rotate(n)
    track.save_txt(filename)
"""
Example 5: Create a track with zeros
"""
from line_track_designer.track import Track

if __name__ == "__main__":
    # Create an empty track
    track = Track.zeros(2, 3)
    # Set the tiles of the track manually
    track.set_tile(1, 0, 17, 1)
    track.set_tile(1, 1, 3, 3)
    track.set_tile(0, 1, 3, 1)
    track.set_tile(0, 2, 17, 3)
    # Show the track
    track.show()
Beispiel #14
0
"""
Example 4: Edition functions
"""
from line_track_designer.track import Track

if __name__ == "__main__":
    # Import the track saved in a text file
    track = Track.read('track_hard/track_hard.txt', 'Hard track')
    # Export the track as png and markdown files
    track.save_md('track_hard/track_hard.md', 'A very hard track')
    # Delete a row
    track.del_row(1)
    # Rotate the track
    track.rotate()
    # Show the track
    track.show()
def track():
    return Track.read(os.path.join(path, 'track.txt'))
def test_max_shape():
    assert Track.max_shape(2000, 1500) == (10, 7)
    assert Track.max_shape(200, 150) == (1, 0)
"""
Example 3: Importation, exportation and show a track
"""
from line_track_designer.track import Track

if __name__ == "__main__":
    # Import the track saved in a text file
    track = Track.read('track_cool_guy/track_cool_guy.txt', 'Cool guy track')
    # Export the track as png and markdown files
    track.save_md('track_cool_guy/track_cool_guy.md',
                  'It looks like a face...')
    # Show the track
    track.show()
Beispiel #18
0
def printing(filename):
    """Print track FILENAME."""
    if click.confirm('Do you want to print the track?'):
        track = Track.read(filename)
        track.print_track()
Beispiel #19
0
"""
import os
import numpy as np
from line_track_designer.track import Track


if __name__ == "__main__":
    # Creation of a folder
    if not os.path.exists('track_test'):
        os.makedirs('track_test')

    # Arrays for the track
    tiles = np.array([
        [3, 2, 3],
        [2, 11, 2],
        [3, 2, 3]
    ])
    orient = np.array([
        [1, 1, 0],
        [0, 0, 0],
        [2, 1, 3]
    ])

    # Creation of the track
    track = Track(tiles, orient, 'Test track')

    # Save the track
    track.save_txt('track_test/track.txt')
    track.save_img('track_test/track.png')
    track.save_md('track_test/track.md', 'Easy track')
def track_hard():
    return Track.read(os.path.join(path, 'track_hard.txt'))