╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ Title.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
381 "#..#.#", 382 "#..#.#", 383 "#.#..#", 384 "#.#..#", 385 "##...#", 386 "#....#", 387 ".####.", 388 }, 389 '1' => .{ 390 "..##..", 391 ".###..", 392 "..##..", 393 "..##..", 394 "..##..", 395 "..##..", 396 "..##..", 397 "..##..", 398 "######", 399 }, 400 '2' => .{ 401 ".####.", 402 "#....#", 403 ".....#", 404 "....#.", 405 "...#..", 406 "..#...", 407 ".#....", 408 "#.....", 409 "######", 410 }, 411 '3' => .{ 412 ".####.", 413 "#....#", 414 ".....#", 415 ".....#", 416 ".####.", 417 ".....#", 418 ".....#", 419 "#....#", 420 ".####.", 421 }, 422 '4' => .{ 423 "....#.", 424 "...##.", 425 "..#.#.", 426 ".#..#.", 427 "#...#.", 428 "######", 429 "....#.", 430 "....#.", 431 "....#.", 432 }, 433 '5' => .{ 434 "######", 435 "#.....", 436 "#.....", 437 "#.....", 438 "#####.", 439 ".....#", 440 ".....#", 441 "#....#", 442 ".####.", 443 }, 444 '6' => .{ 445 ".####.", 446 "#....#", 447 "#.....", 448 "#.....", 449 "#####.", 450 "#....#", 451 "#....#", 452 "#....#", 453 ".####.", 454 }, 455 '7' => .{ 456 "######", 457 ".....#", 458 "....#.", 459 "....#.", 460 "...#..", 461 "...#..", 462 "..#...", 463 "..#...", 464 ".#....", 465 }, 466 '8' => .{ 467 ".####.", 468 "#....#", 469 "#....#", 470 "#....#", 471 ".####.", 472 "#....#", 473 "#....#", 474 "#....#", 475 ".####.", 476 }, 477 '9' => .{ 478 ".####.", 479 "#....#", 480 "#....#", 481 "#....#", 482 ".#####", 483 ".....#", 484 ".....#", 485 "#....#", 486 ".####.", 487 }, 488 '-' => .{ 489 "......", 490 "......", 491 "......", 492 "......", 493 ".####.", 494 "......", 495 "......", 496 "......", 497 "......", 498 }, 499 '.' => .{ 500 "......", 501 "......", 502 "......", 503 "......", 504 "......", 505 "......", 506 "......", 507 "..##..", 508 "..##..", 509 }, 510 else => null, 511 }; 512 } 513 514 // map a 2x3 sub-pixel pattern to its corresponding sextant codepoint 515 fn sextantCodepoint(pattern: u6) u21 { 516 return switch (pattern) { 517 0b000000 => ' ', 518 0b010101 => 0x258C, // ▌ left half block 519 0b101010 => 0x2590, // ▐ right half block 520 0b111111 => 0x2588, // █ full block 521 else => blk: { 522 var offset: u21 = @as(u21, pattern) - 1; 523 if (pattern > 0b010101) offset -= 1; 524 if (pattern > 0b101010) offset -= 1; 525 break :blk 0x1FB00 + offset; 526 }, 527 }; 528 } 529 530 fn renderTitle(comptime input: []const u8) []const u8 { 531 comptime { 532 @setEvalBranchQuota(100_000); 533 var rows: [3][]const u8 = .{ "", "", "" }; 534 var first = true; 535 for (input) |c| { 536 const glyph = glyphFor(c) orelse continue; 537 538 // row-aligned dither: keep on-pixels only at even bitmap rows. 539 var kept: [9][6]bool = std.mem.zeroes([9][6]bool); 540 for (0..9) |r| { 541 if (r % 2 != 0) continue; 542 for (0..6) |col| { 543 kept[r][col] = glyph[r][col] == '#'; 544 } 545 } 546 547 if (!first) { 548 for (&rows) |*r| { 549 r.* = r.* ++ " "; 550 } 551 } 552 first = false; 553 554 for (0..3) |text_row| { 555 for (0..3) |text_col| { 556 var pattern: u6 = 0; 557 for (0..3) |sub_row| { 558 for (0..2) |sub_col| { 559 const row_idx = text_row * 3 + sub_row; 560 const col_idx = text_col * 2 + sub_col; 561 if (kept[row_idx][col_idx]) { 562 pattern |= @as(u6, 1) << @intCast(sub_row * 2 + sub_col); 563 } 564 } 565 } 566 const cp = sextantCodepoint(pattern); 567 var utf8_buf: [4]u8 = undefined; 568 const len = std.unicode.utf8Encode(cp, &utf8_buf) catch unreachable; 569 rows[text_row] = rows[text_row] ++ utf8_buf[0..len]; 570 } 571 } 572 } 573 return rows[0] ++ "\n" ++ rows[1] ++ "\n" ++ rows[2]; 574 } 575 } 576