Terminal-Print icon indicating copy to clipboard operation
Terminal-Print copied to clipboard

Add area-filling routines

Open japhb opened this issue 8 years ago • 3 comments

This includes filled shapes, area between (possibly curved) paths, flood fill, etc.

japhb avatar Dec 12 '16 04:12 japhb

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

Xliff avatar Aug 22 '17 15:08 Xliff

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.

japhb avatar Aug 31 '17 00:08 japhb

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.

Xliff avatar Sep 06 '17 03:09 Xliff