fdehau / tui-rs

Build terminal user interfaces and dashboards using Rust
MIT License
10.83k stars 484 forks source link

The predefined braille patterns for canvas is not enough #144

Closed bytesnail closed 5 years ago

bytesnail commented 5 years ago

Braille Patterns

@fdehau As noted above, we now use one of them to represent blank, and the other eight are used to render on canvas. To sum up, a cell can represent eight points, but a cell can have at most one renderable point at the same time.

This will cause some problems:

  1. The brightness of the rendering results will be different than expected, it will become much darker #141
  2. This will greatly reduce the ability of the canvas to express. In our expectation, every point in the terminal is renderable. We can at most achieve this resolution [(terminal width 2) x (terminal height 4)]
  3. When the actual style of the points in the specified cell is not among the eight, we will calculate and convert its coordinates, and approximate the use of one of these eight, which will increase the complexity of the rendering part of the logic. Degree, which also causes distortion of the rendering result
  4. Because the same cell can only be rendered with one point at a time, when multiple adjacent cells are put together, there is a high probability that a large number of consecutive non-renderable areas appear in the canvas, which seems to be a lot of appearance black (default background color) line separates the canvas, which results in poor rendering quality #141

In summary, I hope that we can add more braille patterns for rendering, which should actually be all braille patterns between 0x2800--0x28FF.

bytesnail commented 5 years ago

@fdehau I don't know if there are some errors or deviations in my understanding and expression.

fdehau commented 5 years ago

The crate is actually using all the available braille patterns. As shown there, bit masks are used to compute the offset from the blank braille pattern and thus find the correct unicode character to represent all the points within the cells. You wouldn't have the rendering result you get if it was not the case. Some of the artifacts seems to be caused by rounding errors on the floats. The discrete nature of braille patterns (there is always space between them) explains the relatively low overall brightness of the picture. I don't think you can achieve a better result using braille patterns.