box aspect function

This commit is contained in:
frank 2021-07-21 02:08:45 -04:00
parent 569e203409
commit 14759a1c79
4 changed files with 27 additions and 17 deletions

25
README
View File

@ -1,8 +1,10 @@
++~~~~~~~~~~~~~~~~~~~~~~~++ ++~~~~~~~~~~~~~~~~~~~~~~~++
++~~~~~~~~~~~~~~~~~~~~~~~++
:: :: :: ::
:: SFW (SDL Framework) :: :: SFW (SDL Framework) ::
:: :: :: ::
++~~~~~~~~~~~~~~~~~~~~~~~++ ++~~~~~~~~~~~~~~~~~~~~~~~++
++~~~~~~~~~~~~~~~~~~~~~~~++
SFW is a C++ framework that facilitates the creation of SDL projects. It SFW is a C++ framework that facilitates the creation of SDL projects. It
provides generic game objects that can be used, extended or overwritten. Games provides generic game objects that can be used, extended or overwritten. Games
@ -88,24 +90,25 @@ License
The original code for this framework is licensed to freely use, copy, modify and The original code for this framework is licensed to freely use, copy, modify and
sell, without restriction under the zlib license. See LICENSE.txt for details. sell, without restriction under the zlib license. See LICENSE.txt for details.
BPmono.ttf is licensed under the Creative Commons Attribution - No Derivative Included libraries are included under various permissive licenses:
Works 3.0 license. See LICENSE_BPmono.txt for details.
gif-h is unlicensed, public domain code released under the The Unlicense. See - BPmono.ttf is licensed under the Creative Commons Attribution - No Derivative
lib/gif-h/LICENSE Works 3.0 license. See LICENSE_BPmono.txt for details.
GLEW is included under a permissive license in lib/glew/LICENSE.txt - gif-h is unlicensed, public domain code released under the The Unlicense. See
lib/gif-h/LICENSE
GLM is included under the MIT license in lib/glm/LICENSE - GLEW is included under a permissive license in lib/glew/LICENSE.txt
nlohmann's json library is included under the MIT license in - GLM is included under the MIT license in lib/glm/LICENSE
lib/json/LICENSE.MIT
SDL2 GFX is included under a permissive license in lib/sdl2-gfx/LICENSE - nlohmann's json library is included under the MIT license in
lib/json/LICENSE.MIT
superxbr.cpp is included under a permissive license at the top of - SDL2 GFX is included under a permissive license in lib/sdl2-gfx/LICENSE
lib/superxbr.cpp
- superxbr.cpp is included under a permissive license at the top of
lib/superxbr.cpp
Business Business
```````` ````````

View File

@ -21,7 +21,7 @@
generate documentation from comments, get resource function, automatically generate documentation from comments, get resource function, automatically
update animations, add arguments list to animation call, queue multiple calls update animations, add arguments list to animation call, queue multiple calls
to animation, print list of chunk and music decoders available, allow nodes to animation, print list of chunk and music decoders available, allow nodes
that aren't connected to root that aren't connected to root, add imagemagick to library, add curl to library
:) SWEATY HANDS :) OILY SNACKS :) AND BAD HYGIENE :) :) SWEATY HANDS :) OILY SNACKS :) AND BAD HYGIENE :)

View File

@ -57,11 +57,6 @@ glm::vec2 Box::get_size() const
return glm::vec2(get_w(), get_h()); return glm::vec2(get_w(), get_h());
} }
float Box::get_area() const
{
return get_w() * get_h();
}
void Box::set_size(const glm::vec2& size, bool preserve_center) void Box::set_size(const glm::vec2& size, bool preserve_center)
{ {
glm::vec2 center = get_center(); glm::vec2 center = get_center();
@ -73,6 +68,17 @@ void Box::set_size(const glm::vec2& size, bool preserve_center)
} }
} }
/* Returns width divided by height regardless of which side is longer */
float Box::aspect() const
{
return get_w() / get_h();
}
float Box::get_area() const
{
return get_w() * get_h();
}
float Box::get_top() const float Box::get_top() const
{ {
return get_y(); return get_y();

View File

@ -29,6 +29,7 @@ public:
void set_h(float); void set_h(float);
glm::vec2 get_size() const; glm::vec2 get_size() const;
void set_size(const glm::vec2&, bool = false); void set_size(const glm::vec2&, bool = false);
float aspect() const;
float get_area() const; float get_area() const;
float get_top() const; float get_top() const;
float get_right() const; float get_right() const;