Skip to content

Commit

Permalink
Add drawImageRotated example to test-graphics project
Browse files Browse the repository at this point in the history
The `Gear.png` image was custom created in Inkscape.
  • Loading branch information
DanRStevens committed Feb 26, 2025
1 parent 67a6fdb commit 3c9b798
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test-graphics/TestGraphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <NAS2D/Renderer/Renderer.h>
#include <NAS2D/Resource/Font.h>
#include <NAS2D/Math/Rectangle.h>
#include "NAS2D/Math/Angle.h"

#include <functional>
#include <random>
Expand Down Expand Up @@ -42,6 +43,9 @@ namespace


TestGraphics::TestGraphics() :
mTimer{},
mGear1{"Gear.png"},
mGear2{"Gear.png"},
mDxImage{"Test_DirectX.png"},
mOglImage{"Test_OpenGL.png"}
{}
Expand Down Expand Up @@ -109,6 +113,10 @@ NAS2D::State* TestGraphics::update()
r.drawPoint(NAS2D::Point{84, 60} + offset, NAS2D::Color{grey, grey, grey});
}

const auto angle = NAS2D::Angle::degrees(static_cast<float>(mTimer.tick() * 360 / 10 / 1000));
r.drawImageRotated(mGear1, {158, 60}, angle);
r.drawImageRotated(mGear2, {219, 60}, -angle);

r.drawImage(mDxImage, {10, 134});
r.drawImage(mOglImage, {10 + 512, 134});

Expand Down
4 changes: 4 additions & 0 deletions test-graphics/TestGraphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include "NAS2D/State.h"
#include "NAS2D/EventHandler.h"
#include "NAS2D/Timer.h"
#include "NAS2D/Resource/Image.h"


Expand All @@ -22,6 +23,9 @@ class TestGraphics : public NAS2D::State
void onWindowResized(int w, int h);

private:
NAS2D::Timer mTimer;
NAS2D::Image mGear1;
NAS2D::Image mGear2;
NAS2D::Image mDxImage;
NAS2D::Image mOglImage;
};
Binary file added test-graphics/data/Gear.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3c9b798

Please sign in to comment.