diff options
author | Sven Gothel <[email protected]> | 2022-12-26 05:16:05 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2022-12-26 05:16:05 +0100 |
commit | 447031c72313ee782ba9b6ca5221e4ac9d4769b5 (patch) | |
tree | 93a8652372db9d8f3882caf8bcad12e0ea58255a /include/pixel/pixel.hpp | |
parent | 7166b9eabe4fbe5d8088fd2593968020a5b60b52 (diff) |
pixel::f2::rect_t: Fix ctor w/ top-left and dimension, height was taken in opposite dir; Give texture_t::draw separate optional factors; Minor freefall01 adjustments.
Diffstat (limited to 'include/pixel/pixel.hpp')
-rw-r--r-- | include/pixel/pixel.hpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/include/pixel/pixel.hpp b/include/pixel/pixel.hpp index 42d30e1..68f01f0 100644 --- a/include/pixel/pixel.hpp +++ b/include/pixel/pixel.hpp @@ -176,9 +176,13 @@ namespace pixel { /** y-axis height of the cartesian coordinate system. */ constexpr float height() const noexcept { return y2 - y1; } + /** Convert cartesian x-axis value to framebuffer pixel value. */ + int to_fb_dx(const float dx) const noexcept { return round_to_int( dx / w_to_fbw ); } + /** Convert cartesian y-axis value to framebuffer pixel value. */ + int to_fb_dy(const float dy) const noexcept { return round_to_int( dy / h_to_fbh ); } + /** Convert cartesian x-axis coordinate to framebuffer coordinate in pixels. */ int to_fb_x(const float x) const noexcept { return round_to_int( ( x - x1 ) / w_to_fbw ); } - /** Convert cartesian y-axis coordinate in pixels to framebuffer coordinate in pixels. */ int to_fb_y(const float y) const noexcept { return fb_height - round_to_int( ( y - y1 ) / h_to_fbh ); } @@ -279,7 +283,7 @@ namespace pixel { void destroy() noexcept; - void draw(const int x_pos, const int y_pos, const float scale=1.0f) noexcept; + void draw(const int x_pos, const int y_pos, const float scale_x=1.0f, const float scale_y=1.0f) noexcept; }; typedef std::shared_ptr<texture_t> texture_ref; |