Skip to content
New issue

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

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

Already on GitHub? # to your account

Feature: allow different snap modes used for grid size and offset #38

Merged
merged 1 commit into from
Aug 15, 2024

Conversation

mwtoews
Copy link
Owner

@mwtoews mwtoews commented Aug 15, 2024

This feature adds more control on the evaluation of grid size and offset from input bounds, which is used with most Grid classmethods.

The default snap mode full will snap bounds to a multiple of resolution, which has been the only mode up until now.

Some other modes include:

  • half: snap to half-resolution, for instance when creating a finite-element grid where the representative value is at grid corners, thus it need to be shifted by a half grid resolution.
  • top-left, top-right, bottom-left, or bottom-right: snap to corner, without rounding any digits.
  • A coordinate tuple (snapx, snapy): directly specify a point on the grid, although the grid may not necessarily include the coordinate if it is outside.

There are a few instances where the behaviour has changed, only when a buffer distance was also provided. These previous grids were not large enough to contain the original bounds, and is corrected here.

Also, some classmethods have been modified to force some keywords to be specified (rather than just positional).

@mwtoews mwtoews merged commit 1562a1e into main Aug 15, 2024
6 checks passed
@mwtoews mwtoews deleted the snap-mode branch August 15, 2024 03:08
@mwtoews mwtoews linked an issue Aug 15, 2024 that may be closed by this pull request
@mwtoews mwtoews added the enhancement New feature or request label Aug 22, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose some controls on bounds snapping
1 participant