Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

draw octants directly rather than relying on font #5433

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dankamongmen
Copy link

  • implement yQuads() and draw_octant(), pretty obvious extensions of existing code. to allocate up to 3 potential remainder lines, consider that octants will often appear in a rectangular subset of the terminal. we want the distributed excess uniformly distributed across such a region. so:
    • one excess row: break symmetry in any direction (pick an arbitrary tetrad and use it everywhere)
    • two excess rows: go to alternating tetrads
    • three excess rows: break symmetry, do not use three contiguous tetrads
  • our Octants are octary arrays of bool, provided as a somewhat opaque constant table
  • the 8-line copy-and-paste draw based on the Octant is not the prettiest thing in the known universe
    • we could generalize draw_sextant() and draw_octant() like notcurses did, almost certainly
    • oh bird thou never wert

with that said, i don't think draw_octant() is actually being called lol, so let's not merge this yet. happy to hear early feedback, though.

@dankamongmen
Copy link
Author

hrmmm, do the builtin draws only run when we can't find these glyphs in the font? that would explain things. i'd suggest giving them primacy should that be the case, but can understand going the other way.

@jcollie
Copy link
Collaborator

jcollie commented Jan 30, 2025

hrmmm, do the builtin draws only run when we can't find these glyphs in the font? that would explain things. i'd suggest giving them primacy should that be the case, but can understand going the other way.

Take a look at this. There are a couple of places in Box.zig and Face.zig where the glyphs need to be "linked in" in order for them to be drawn.

const OctantMin = 0x1cd00;
const OctantMax = 0x1cde5;
const Octants = [OctantMax - OctantMin + 1][8]bool{
[_]bool{ false, false, true, false, false, false, false, false },
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems rather tedious and error-prone to convert the name of the octant from "BLOCK OCTANT-12345" to a boolean array like this. With comptime strings and inline for loops this can be made so much easier.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hrmmm, i agree that using the language's native features for this kind of thing would be far less opaque. i'm intrigued, but doubt i'll get to it this weekend--feel encouraged to use this PR as a starting point to do something better. i have no emotional ties to this matrix.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the pointers to the ziggery, though!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't reviewed this PR yet but I agree this code is very C (no surprise!). Zig's comptime facilities should allow us to do something much nicer here I believe.

@dankamongmen
Copy link
Author

hrmmm, do the builtin draws only run when we can't find these glyphs in the font? that would explain things. i'd suggest giving them primacy should that be the case, but can understand going the other way.

Take a look at this. There are a couple of places in Box.zig and Face.zig where the glyphs need to be "linked in" in order for them to be drawn.

got it, much appreciated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants