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

Dimensions object #216

Open
benjaminpjones opened this issue Mar 24, 2024 · 0 comments
Open

Dimensions object #216

benjaminpjones opened this issue Mar 24, 2024 · 0 comments
Labels
good first issue Good for newcomers

Comments

@benjaminpjones
Copy link
Collaborator

I often find myself looking at Grid to check whether a position is in bounds. (Grid.isInBounds)

However, if the appropriate Grid is not available, this feels wasteful, since isInBounds is a function of width and height, but not the grid itself (which contains a 2d array). It would be nice to create a Dimensions class that owns height and width and can do any calculations based on these.

Before

const grid = new Grid(3, 4);
grid.isInBounds({ x: 1, y: 2}); // true

After

// when a grid exists
grid.dims.isInBounds({ x: 1, y: 2});

// or when an appropriate grid does not exist
const dims = new Dimensions(3, 4); // no array created :D
dims.isInBounds({ x: 1, y: 2});
@benjaminpjones benjaminpjones added the good first issue Good for newcomers label Mar 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant