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

Implement bounding boxes for SDL::Game::Rect #140

Open
kthakore opened this issue Jul 24, 2011 · 0 comments
Open

Implement bounding boxes for SDL::Game::Rect #140

kthakore opened this issue Jul 24, 2011 · 0 comments
Assignees

Comments

@kthakore
Copy link
Member

The minimum bounding rectangle (MBR), also known as bounding box or envelope, is an expression of the maximum extents of a 2-dimensional object (e.g. point, line, polygon) within its 2-D (x, y) coordinate system, in other words min(x), max(x), min(y), max(y). The MBR is a 2-dimensional case of the minimum bounding box.

SDL::Game::Rect could have bounding values for coordinates and size. Something like:

$rect->min_x(0);
$rect->max_x(100);
$rect->min_height(3);
$rect->max_height(7);

they should probably be "paired" methods as well:

$rect->min_pos(0, 0); # x, y
$rect->max_pos(102, 109); # x, y

$rect->min_size(10, 18); # width, height
$rect->max_size(42, 42); # width, height

I don't like this API:

$rect->min_boundbox(2, 2, undef, 7); # x, y, w, h
$rect->max_boundbox(2, 2, undef, 7); # x, y, w, h

I like this one better (or something like that):

$rect->size_boundbox(2, 2, undef, 7); # min_w, min_h, max_w, max_h
$rect->pos_boundbox (2, 2, undef, 7); # min_x, min_y, max_w, max_h

There should also be a way to do this inside the constructor, something like:

my $rect = SDL::Game::Rect->new(
-top => 0,
-left => 0,
-width => 10,
-height => 10,
-min_x => 0,
-max_width => 42,
);

or something like that. Since there are several things to be done on SDL Perl before tackling this, just feel free to comment on the suggested API, or suggest your own while we're not there yet.

@ghost ghost assigned garu Jul 24, 2011
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

No branches or pull requests

2 participants