Sha256: 47da8c36a7c5b4ab4c13eb2f96b3ae23d1cd49287e96ad12bf7c225940cae4e6
Contents?: true
Size: 1.47 KB
Versions: 3
Compression:
Stored size: 1.47 KB
Contents
// Default matrices, adapted from original Transform support // contribution by erisdiscord. Thank you! #include <Gosu/Graphics.hpp> #include <Gosu/Math.hpp> #include "Common.hpp" #include <cmath> Gosu::Transform Gosu::rotate(double angle, double aroundX, double aroundY) { double c = std::cos(degreesToRadians(angle)); double s = std::sin(degreesToRadians(angle)); Gosu::Transform result = { +c, +s, 0, 0, -s, +c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; if (aroundX != 0 || aroundY != 0) result = multiply(multiply(translate(-aroundX, -aroundY), result), translate(aroundX, aroundY)); return result; } Gosu::Transform Gosu::translate(double x, double y) { Gosu::Transform result = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, x, y, 0, 1 }; return result; } Gosu::Transform Gosu::scale(double factor) { Gosu::Transform result = { factor, 0, 0, 0, 0, factor, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; return result; } Gosu::Transform Gosu::scale(double factorX, double factorY, double aroundX, double aroundY) { Gosu::Transform result = { factorX, 0, 0, 0, 0, factorY, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 }; if (aroundX != 0 || aroundY != 0) result = multiply(multiply(translate(-aroundX, -aroundY), result), translate(aroundX, aroundY)); return result; }
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gosu-0.7.50 | GosuImpl/Graphics/Transform.cpp |
gosu-0.7.49 | GosuImpl/Graphics/Transform.cpp |
gosu-0.7.48 | GosuImpl/Graphics/Transform.cpp |