Terminal-Print
Terminal-Print copied to clipboard
Add area-filling routines
This includes filled shapes, area between (possibly curved) paths, flood fill, etc.
So basically:
- Start at fill point.
- For direction < right left >:
- For direction < up down >:
- If cell is empty, fill
- If cell is not empty, end loop
- ???
- PROFIT
Of course, one can always use Google and cheat, ala: https://en.wikipedia.org/wiki/Flood_fill#The_algorithm
Sure, flood fill is pretty much a requirement, but it's inefficient if e.g. you just want to display simple polygons or elliptical arcs for e.g. pie charts.
I can think two signatures for such a routine. Let me know if you have a problem with these:
- fill(row, column, pattern)
- fill(row, column, oldPattern, newPattern)
Pattern is a colored character cell (or however we are describing characters in T::P)
The first is basically a wrapper for the second, where oldPattern defaults to the blank (or space) character.
The second will just replace oldPattern with newPattern, and edge detection is determined by any cell that does not contain oldPattern.
There are other issues that bear discussion, though. What happens if we want to fill based on contents of the cell rather than color, or color rather than contents?
I will be digging in to T::P to see if I can answer my own question, soon.