#command-line #text #frame #graphics #drawing #color #user

app shelldraw

A drawing tool for the command line. It's able to build a single frame from a list of graphics commands, then display that frame on the command line as an image.

1 unstable release

0.1.0 Feb 21, 2024

#105 in Graphics APIs

Custom license

11KB
196 lines

Shelldraw

This allows for the user to create a drawing on the command line, by invoking several building commands procedurally.

For example, this will create a series of concentric squares, with the word "hello" starting directly in the center.

#              [r][c]
shelldraw init 11 11  
#              x1 y1 x2 y2 color
shelldraw rect  0  0 10 10 red
shelldraw rect  1  1  9  9 green
shelldraw rect  2  2  8  8 blue
shelldraw rect  3  3  7  7 red
shelldraw rect  4  4  6  6 green
shelldraw rect  5  5  5  5 blue
#               x  y  text
shelldraw text  5  5  hello
shelldraw show

Output

The output of the previous command is hard to show in a readme, because it prints out ansi excape characters. I've base64 encoded the output so that you can see what it looks like though.

echo \
G1s0MW0gG1swbRtbNDFtIBtbMG0bWzQxbSAbWzBtG1s0MW0gG1swbRtbNDFtIBtbMG0bWzQxbSAb\
WzBtG1s0MW0gG1swbRtbNDFtIBtbMG0bWzQxbSAbWzBtG1s0MW0gG1swbRtbNDFtIBtbMG0KG1s0\
MW0gG1swbRtbNDJtIBtbMG0bWzQybSAbWzBtG1s0Mm0gG1swbRtbNDJtIBtbMG0bWzQybSAbWzBt\
G1s0Mm0gG1swbRtbNDJtIBtbMG0bWzQybSAbWzBtG1s0Mm0gG1swbRtbNDFtIBtbMG0KG1s0MW0g\
G1swbRtbNDJtIBtbMG0bWzQ0bSAbWzBtG1s0NG0gG1swbRtbNDRtIBtbMG0bWzQ0bSAbWzBtG1s0\
NG0gG1swbRtbNDRtIBtbMG0bWzQ0bSAbWzBtG1s0Mm0gG1swbRtbNDFtIBtbMG0KG1s0MW0gG1sw\
bRtbNDJtIBtbMG0bWzQ0bSAbWzBtG1s0MW0gG1swbRtbNDFtIBtbMG0bWzQxbSAbWzBtG1s0MW0g\
G1swbRtbNDFtIBtbMG0bWzQ0bSAbWzBtG1s0Mm0gG1swbRtbNDFtIBtbMG0K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tbMG0bWzQxbSAbWzBtG1s0MW0gG1swbRtbNDFtIBtbMG0K | base64 --decode

Next steps

Colored rectangles and text are the basis of graphics, so we can go pretty far with just these 2 things. There's more that can be done though:

  • adding additional colors
  • adding in lines, circles, and other shapes (rounded rects, triangles)

Dependencies

~0.7–1.4MB
~33K SLoC