GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
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:
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
$rect->min_boundbox(2, 2, undef, 7); # x, y, w, h
$rect->max_boundbox(2, 2, undef, 7); # x, y, w, h
$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.