A simple Python module for creating and manipulating a grid with colored symbols.
This Python module provides a Grid
class that allows you to create a grid and set colored symbols at specific coordinates. The module uses ANSI escape codes for terminal color formatting.
-
Install the colorama library:
pip install colorama
-
Download the
colorful_grid.py
file from this repository.
-
Import the
Grid
class fromcolorful_grid.py
:from colorful_grid import Grid
-
Create a
Grid
object with the desired width and height:my_grid = Grid(5, 5)
-
Use the
create_symbol
method to set a colored symbol at specific coordinates:my_grid.create_symbol('R', 0, 0, 255, 0, 0)
-
Use the
delete_symbol
method to remove a symbol at specific coordinates:my_grid.delete_symbol(2, 2)
-
Draw the grid using the
draw_grid
method:my_grid.draw_grid()
Here's a simple example demonstrating the usage:
from colorful_grid import Grid
my_grid = Grid(5, 5)
my_grid.create_symbol('R', 0, 0, 255, 0, 0)
my_grid.create_symbol('G', 2, 2, 0, 255, 0)
my_grid.create_symbol('B', 4, 4, 0, 0, 255)
my_grid.draw_grid()
my_grid.delete_symbol(2, 2)
my_grid.draw_grid()
This project is licensed under the MIT License - see the LICENSE file for details.