pxltrm icon indicating copy to clipboard operation
pxltrm copied to clipboard

Use half blocks to keep pixel ration squared

Open numaru opened this issue 7 years ago • 5 comments

There is a trick to keep the pixel ratio squared. The idea is to split a rectangular char into 2 pixels. To do so, Unicode lower half blocks u'\u2584' is used to draw the bottom pixel and the background color to draw the top one (or vice versa).

It is used in these projects:

  • pixterm (go) https://github.com/eliukblau/pixterm
  • termpix (rust) https://github.com/hopey-dishwasher/termpix
  • term-img (python) https://github.com/keithieopia/term-img

Pros

  • Pixel squared
  • Can still draw a blinky cursor
  • Cool hacking solution 🐱‍💻

Cons

  • Might loose mouse support since this require to get which one of the 2 pixels has been clicked
  • Require Unicode 1.1.0 (June, 1993) support

numaru avatar Jun 07 '18 04:06 numaru

I like the idea, I’ll work on this.

dylanaraps avatar Jun 07 '18 04:06 dylanaraps

This will be difficult as we can't change the cursor shape, nor can we move the cursor in half blocks.

dylanaraps avatar Jun 07 '18 06:06 dylanaraps

Yes it must be "faked" by drawing a blinky pixel. I was not sure if the idea could be implemented while keeping this project simple but I wanted to share the idea.

numaru avatar Jun 07 '18 17:06 numaru

If you had the write characters for it (top half, bottom half blocks) could you do this by having one key for drawing the top half and a different key for drawing the bottom half?

Amar1729 avatar Jun 12 '18 20:06 Amar1729

If you had the right characters

Unicode has U+2580 UPPER HALF BLOCK ▀ (and U+2584 LOWER HALF BLOCK ▄, but we only need one)

u9000-Nine avatar May 25 '22 17:05 u9000-Nine