Sha256: e9b0c485238de0a582fc9e4bd59888e465ffc67ef2407ea87440c76ee205010c

Contents?: true

Size: 1.49 KB

Versions: 25

Compression:

Stored size: 1.49 KB

Contents

// Default matrices, adapted from original Transform support
// contribution by erisdiscord. Thank you!

#include <Gosu/Graphics.hpp>
#include <Gosu/Math.hpp>
#include <GosuImpl/Graphics/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

25 entries across 25 versions & 1 rubygems

Version Path
gosu-0.7.47.1 GosuImpl/Graphics/Transform.cpp
gosu-0.7.46 GosuImpl/Graphics/Transform.cpp
gosu-0.7.45 GosuImpl/Graphics/Transform.cpp
gosu-0.7.44 GosuImpl/Graphics/Transform.cpp
gosu-0.7.43 GosuImpl/Graphics/Transform.cpp
gosu-0.7.41 GosuImpl/Graphics/Transform.cpp
gosu-0.7.40 GosuImpl/Graphics/Transform.cpp
gosu-0.7.39 GosuImpl/Graphics/Transform.cpp
gosu-0.7.38 GosuImpl/Graphics/Transform.cpp
gosu-0.7.37 GosuImpl/Graphics/Transform.cpp
gosu-0.7.36.2 GosuImpl/Graphics/Transform.cpp
gosu-0.7.35 GosuImpl/Graphics/Transform.cpp
gosu-0.7.33 GosuImpl/Graphics/Transform.cpp
gosu-0.7.32 GosuImpl/Graphics/Transform.cpp
gosu-0.7.31 GosuImpl/Graphics/Transform.cpp
gosu-0.7.30 GosuImpl/Graphics/Transform.cpp
gosu-0.7.29 GosuImpl/Graphics/Transform.cpp
gosu-0.7.28 GosuImpl/Graphics/Transform.cpp
gosu-0.7.27.1 GosuImpl/Graphics/Transform.cpp
gosu-0.7.27 GosuImpl/Graphics/Transform.cpp