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

smooth bitmap movement with kitty graphics #1682

Closed
dankamongmen opened this issue May 23, 2021 · 12 comments · Fixed by #2259
Closed

smooth bitmap movement with kitty graphics #1682

dankamongmen opened this issue May 23, 2021 · 12 comments · Fixed by #2259
Assignees
Labels
bitmaps bitmapped graphics (sixel, kitty, mmap) documentation Improvements or additions to documentation enhancement New feature or request

Comments

@dankamongmen
Copy link
Owner

Currently, bitmaps can move only a cell at a time. That leads to jerky movement. With Kitty, we can do subcell placement. With sixel, we can fake it by adding transparent rows/columns. Consider doing so.

Actually, this could apply to all blitters. Quadblitter could move in half-cell increments by adding a transparent row or column of source pixels. hrmmmmmmmmmmmM!

@dankamongmen dankamongmen added documentation Improvements or additions to documentation enhancement New feature or request bitmaps bitmapped graphics (sixel, kitty, mmap) labels May 23, 2021
@dankamongmen dankamongmen self-assigned this May 23, 2021
@dankamongmen
Copy link
Owner Author

note that this isn't just relevant to movement of planes, but also for centering. notcurses-info currently looks like this (see below). i can't get the logo centered, because it's 60 pixels high, on 4x20 pixel high cells. we'd thus want to be halfway into the first row, but that's unavailable, and we're stuck with either the first or second row, 10 pixels away from where we want to be.

2021-06-30-180436_800x1420_scrot

@dankamongmen
Copy link
Owner Author

yeah we ought definitely do this. i think the API is basically "expose pixel coordinates for ncvisual_render(), and get as close to it as possible". with kitty bitmaps, we can get directly there with no further help. with sixel, we'd need insert the transparencies. with cells, we'd always have to do it manually.

@dankamongmen
Copy link
Owner Author

i think it might be better, as mentioned in #2230, to add two new fields to ncvisual_options, pixoffy and pixoffx.

@dankamongmen
Copy link
Owner Author

or maybe we'd like a new function, ncvisual_render_bitmap() which is restricted to NCBLIT_PIXEL and uses absolute x,y pixel coordinates...

@dankamongmen
Copy link
Owner Author

hrmmm. let's go ahead and add the fields to ncvisual_options (not implemented for now) for #1777's sake. we'll only use it with cells when the offsets are 0 or perhaps half. if we want an absolute positioning function later, we can add one.

@dankamongmen
Copy link
Owner Author

so we've got these fields added to ncvisual_options. let's try using them. Kitty support will be trivial, as it allows us to directly specify a cell pixel offset. Sixel will be tougher. Let's create a distinct bug for it, and limit this one to kitty graphics.

@dankamongmen
Copy link
Owner Author

so things this will require:

  • if offsetx is set, our cellwidth goes up by 1
  • if offsety is set, our cellheight goes up by 1
    • these will be reflected in the sprixel cell geometry and the TAM size
  • if offsetx >= cellpixx, error
  • if offsety >= cellpixy, error
    • maybe not? remember that a font size change could invalidate these conditionals later
  • if offsetx and/or offsety, but blitter is not NCBLIT_PIXEL, error
  • pass offsetx/offsety down through blitterargs pixel union
  • in kitty, when preparing TAM, account for offsets
  • in kitty, actual encoded data doesn't change at all, good
  • in kitty, add X and Y params in display (a=d) command

dankamongmen added a commit that referenced this issue Oct 11, 2021
Add pixel offset fields to blitterargs in the pixel
portion of the union. Check in blitter_geom that
pixel offsets are not used with cell blitting.
Prepare the new blitterargs fields. Account for pixel
offsets when calculating cell geometry #1682.
dankamongmen added a commit that referenced this issue Oct 11, 2021
@dankamongmen
Copy link
Owner Author

i've added the BitmapSmoothMove unit test for this functionality

@dankamongmen
Copy link
Owner Author

hrmmmm maybe rather than doing this on a per-blitter basis, we ought just do as suggested in the original filing, and add transparent rows/columns to the source material? that's a lot of extra computation for the pixel blitters, though...nah, i think we'll just have to be badass

dankamongmen added a commit that referenced this issue Oct 11, 2021
@dankamongmen
Copy link
Owner Author

smoothmov.mov

@dankamongmen
Copy link
Owner Author

alright, well there we go. @kovidgoyal, @wez, thanks for the good protocol; we'll support smooth movement in your terminals upon merge. i'll get to the much more annoying task of sixel smooth movements this week, hopefully. this lay down all the necessary infrastructure, though. sweet!

dankamongmen added a commit that referenced this issue Oct 11, 2021
Add pixel offset fields to blitterargs in the pixel
portion of the union. Check in blitter_geom that
pixel offsets are not used with cell blitting.
Prepare the new blitterargs fields. Account for pixel
offsets when calculating cell geometry #1682.
dankamongmen added a commit that referenced this issue Oct 11, 2021
dankamongmen added a commit that referenced this issue Oct 11, 2021
@kovidgoyal
Copy link

You are most welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bitmaps bitmapped graphics (sixel, kitty, mmap) documentation Improvements or additions to documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants