box-drawing: wedges: fix alignment of inverted wedges

We render the inverted wedges by first rendering a non-inverted triangle, and
then inverting it with PIXMAN_OP_OUT.

In cases where truncating and round():ing the triangle points have different
results, the final, inverted wedge ends up being unaligned with the
corresponding sixel(s).

This patch fixes that by handling the pre-inverted triangles
specifically. I.e. we don’t re-use the same triangle coordinates as the
corresponding non-inverted triangle.
This commit is contained in:
Daniel Eklöf 2021-08-05 18:21:06 +02:00
parent 56d7a51d35
commit 36ecd0baed
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -2151,144 +2151,232 @@ draw_wedge_triangle(struct buf *buf, wchar_t wc)
p1_y = 2 * height / 3; p2_y = p3_y = height;
break;
case 0x1fb52: /* 🭒 */
p1_x = p2_x = 0; p3_x = round(width_f / 2.);
p1_y = round(2. * height_f / 3.); p2_y = p3_y = height;
break;
case 0x1fb3d: /* 🬽 */
p1_x = p2_x = 0; p3_x = width;
p1_y = 2 * height / 3; p2_y = p3_y = height;
break;
case 0x1fb53: /* 🭓 */
p1_x = p2_x = 0; p3_x = width;
p1_y = round(2. * height_f / 3.); p2_y = p3_y = height;
break;
case 0x1fb3e: /* 🬾 */
p1_x = p2_x = 0; p3_x = round(width_f / 2.);
p1_y = height / 3; p2_y = p3_y = height;
break;
case 0x1fb54: /* 🭔 */
p1_x = p2_x = 0; p3_x = round(width_f / 2.);
p1_y = round(height_f / 3.); p2_y = p3_y = height;
break;
case 0x1fb3f: /* 🬿 */
p1_x = p2_x = 0; p3_x = width;
p1_y = height / 3; p2_y = p3_y = height;
break;
case 0x1fb55: /* 🭕 */
p1_x = p2_x = 0; p3_x = width;
p1_y = round(height_f / 3.); p2_y = p3_y = height;
break;
case 0x1fb40: /* 🭀 */
case 0x1fb56: /* 🭖 */
p1_x = p2_x = 0; p3_x = round(width_f / 2.);
p1_y = 0; p2_y = p3_y = height;
break;
case 0x1fb47: /* 🭇 */
case 0x1fb47: /* 🭇 */
p1_x = p2_x = width; p3_x = width / 2;
p1_y = 2 * height / 3; p2_y = p3_y = height;
break;
case 0x1fb48: /* 🭈 */
case 0x1fb5d: /* 🭝 */
p1_x = p2_x = width; p3_x = width / 2;
p1_y = round(2. * height_f / 3.); p2_y = p3_y = height;
break;
case 0x1fb48: /* 🭈 */
p1_x = p2_x = width; p3_x = 0;
p1_y = 2 * height / 3; p2_y = p3_y = height;
break;
case 0x1fb49: /* 🭉 */
case 0x1fb5e: /* 🭞 */
p1_x = p2_x = width; p3_x = 0;
p1_y = round(2. * height_f / 3.); p2_y = p3_y = height;
break;
case 0x1fb49: /* 🭉 */
p1_x = p2_x = width; p3_x = width / 2;
p1_y = height / 3; p2_y = p3_y = height;
break;
case 0x1fb4a: /* 🭊 */
case 0x1fb5f: /* 🭟 */
p1_x = p2_x = width; p3_x = width / 2;
p1_y = round(height_f / 3.); p2_y = p3_y = height;
break;
case 0x1fb4a: /* 🭊 */
p1_x = p2_x = width; p3_x = 0;
p1_y = height / 3; p2_y = p3_y = height;
break;
case 0x1fb4b: /* 🭋 */
case 0x1fb60: /* 🭠 */
p1_x = p2_x = width; p3_x = 0;
p1_y = round(height_f / 3.); p2_y = p3_y = height;
break;
case 0x1fb4b: /* 🭋 */
case 0x1fb61: /* 🭡 */
p1_x = p2_x = width; p3_x = width / 2;
p1_y = 0; p2_y = p3_y = height;
break;
case 0x1fb57: /* 🭗 */
case 0x1fb57: /* 🭗 */
p1_x = p2_x = 0; p3_x = round(width_f / 2.);
p1_y = p3_y = 0; p2_y = round(height_f / 3.);
break;
case 0x1fb58: /* 🭘 */
case 0x1fb41: /* 🭁 */
p1_x = p2_x = 0; p3_x = round(width_f / 2.);
p1_y = p3_y = 0; p2_y = height / 3;
break;
case 0x1fb58: /* 🭘 */
p1_x = p2_x = 0; p3_x = width;
p1_y = p3_y = 0; p2_y = round(height_f / 3.);
break;
case 0x1fb59: /* 🭙 */
case 0x1fb42: /* 🭂 */
p1_x = p2_x = 0; p3_x = width;
p1_y = p3_y = 0; p2_y = height / 3;
break;
case 0x1fb59: /* 🭙 */
p1_x = p2_x = 0; p3_x = round(width_f / 2.);
p1_y = p3_y = 0; p2_y = round(2. * height_f / 3.);
break;
case 0x1fb5a: /* 🭚 */
case 0x1fb43: /* 🭃 */
p1_x = p2_x = 0; p3_x = round(width_f / 2.);
p1_y = p3_y = 0; p2_y = 2 * height / 3;
break;
case 0x1fb5a: /* 🭚 */
p1_x = p2_x = 0; p3_x = width;
p1_y = p3_y = 0; p2_y = round(2. * height_f / 3.);
break;
case 0x1fb5b: /* 🭛 */
case 0x1fb44: /* 🭄 */
p1_x = p2_x = 0; p3_x = width;
p1_y = p3_y = 0; p2_y = 2 * height / 3;
break;
case 0x1fb5b: /* 🭛 */
case 0x1fb45: /* 🭅 */
p1_x = p2_x = 0; p3_x = round(width_f / 2.);
p1_y = p3_y = 0; p2_y = height;
break;
case 0x1fb62: /* 🭢 */
case 0x1fb62: /* 🭢 */
p1_x = p2_x = width; p3_x = width / 2;
p1_y = p3_y = 0; p2_y = round(height_f / 3.);
break;
case 0x1fb4c: /* 🭌 */
p1_x = p2_x = width; p3_x = width / 2;
p1_y = p3_y = 0; p2_y = height / 3;
break;
case 0x1fb63: /* 🭣 */
p1_x = p2_x = width; p3_x = 0;
p1_y = p3_y = 0; p2_y = round(height_f / 3.);
break;
case 0x1fb64: /* 🭤 */
case 0x1fb4d: /* 🭍 */
p1_x = p2_x = width; p3_x = 0;
p1_y = p3_y = 0; p2_y = height / 3;
break;
case 0x1fb64: /* 🭤 */
p1_x = p2_x = width; p3_x = width / 2;
p1_y = p3_y = 0; p2_y = round(2. * height_f / 3.);
break;
case 0x1fb65: /* 🭥 */
case 0x1fb4e: /* 🭎 */
p1_x = p2_x = width; p3_x = width / 2;
p1_y = p3_y = 0; p2_y = 2 * height / 3;
break;
case 0x1fb65: /* 🭥 */
p1_x = p2_x = width; p3_x = 0;
p1_y = p3_y = 0; p2_y = round(2. * height_f / 3.);
break;
case 0x1fb4f: /* 🭏 */
p1_x = p2_x = width; p3_x = 0;
p1_y = p3_y = 0; p2_y = 2 * height / 3;
break;
case 0x1fb66: /* 🭦 */
case 0x1fb50: /* 🭐 */
p1_x = p2_x = width; p3_x = width / 2;
p1_y = p3_y = 0; p2_y = height;
break;
case 0x1fb46: /* 🭆 */
case 0x1fb46: /* 🭆 */
p1_x = 0; p1_y = round(2. * height_f / 3.);
p2_x = width; p2_y = height / 3;
p3_x = width; p3_y = p1_y;
break;
case 0x1fb51: /* 🭑 */
case 0x1fb51: /* 🭑 */
p1_x = 0; p1_y = height / 3;
p2_x = 0; p2_y = round(2. * height_f / 3.);
p3_x = width; p3_y = p2_y;
break;
case 0x1fb5c: /* 🭜 */
case 0x1fb5c: /* 🭜 */
p1_x = 0; p1_y = height / 3;
p2_x = 0; p2_y = round(2. * height_f / 3.);
p3_x = width; p3_y = p1_y;
break;
case 0x1fb67: /* 🭧 */
case 0x1fb67: /* 🭧 */
p1_x = 0; p1_y = height / 3;
p2_x = width; p2_y = p1_y;
p3_x = width; p3_y = round(2. * height_f / 3.);
break;
case 0x1fb6c: /* 🭬 */
case 0x1fb6c: /* 🭬 */
case 0x1fb68: /* 🭨 */
p1_x = 0; p1_y = 0;
p2_x = round(width_f / 2.); p2_y = round(height_f / 2.);
p3_x = 0; p3_y = height;
break;
case 0x1fb6d: /* 🭭 */
case 0x1fb6d: /* 🭭 */
case 0x1fb69: /* 🭩 */
p1_x = 0; p1_y = 0;
p2_x = width / 2; p2_y = round(height_f / 2.);
p3_x = width; p3_y = 0;
break;
case 0x1fb6e: /* 🭮 */
case 0x1fb6e: /* 🭮 */
case 0x1fb6a: /* 🭪 */
p1_x = width; p1_y = 0;
p2_x = width / 2; p2_y = round(height_f / 2.);
p3_x = width; p3_y = height;
break;
case 0x1fb6f: /* 🭯 */
case 0x1fb6f: /* 🭯 */
case 0x1fb6b: /* 🭫 */
p1_x = 0; p1_y = height;
p2_x = width / 2; p2_y = round(height_f / 2.);
p3_x = width; p3_y = height;
@ -2314,18 +2402,6 @@ draw_wedge_triangle(struct buf *buf, wchar_t wc)
static void
draw_wedge_triangle_inverted(struct buf *buf, wchar_t wc)
{
IGNORE_WARNING("-Wpedantic");
switch (wc) {
case 0x1fb41 ... 0x1fb45: wc = wc - 0x1fb41 + 0x1fb57; break;
case 0x1fb4c ... 0x1fb50: wc = wc - 0x1fb4c + 0x1fb62; break;
case 0x1fb52 ... 0x1fb56: wc = wc - 0x1fb52 + 0x1fb3c; break;
case 0x1fb5d ... 0x1fb61: wc = wc - 0x1fb5d + 0x1fb47; break;
case 0x1fb68 ... 0x1fb6b: wc = wc - 0x1fb68 + 0x1fb6c; break;
}
UNIGNORE_WARNINGS;
draw_wedge_triangle(buf, wc);
pixman_image_t *src = pixman_image_create_solid_fill(&white);