Skip to content

Commit

Permalink
Remove some dpi stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
gregersn committed Jun 8, 2024
1 parent 0b0ce1f commit 9ff43e7
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion include/pyro/graphics.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ namespace Pyro
* @param width The width of the canvas
* @param height The height of the canvas
*/
Graphics *creategraphics(unsigned int width, unsigned int height, GraphicsMode mode = GraphicsMode::CAIRO, unsigned int dpi = 72, Unit unit = Unit::PX);
Graphics *creategraphics(unsigned int width, unsigned int height, GraphicsMode mode = GraphicsMode::CAIRO);

};

Expand Down
10 changes: 8 additions & 2 deletions screenshot-tests/test-resolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ TEST_CASE("Test varied DPI")
{
SECTION("Check result matching")
{
Pyro::Graphics *pa = Pyro::creategraphics(508, 254, testmode, 100, Pyro::Unit::MM);
Pyro::Graphics *pa = Pyro::creategraphics(508, 254, testmode);
pa->set_dpi(100);
pa->set_unit(Pyro::Unit::MM);
pa->init();

REQUIRE(pa->width() == 2000);
REQUIRE(pa->height() == 1000);

Pyro::Graphics *pb = Pyro::creategraphics(508, 254, testmode, 200, Pyro::Unit::MM);
Pyro::Graphics *pb = Pyro::creategraphics(508, 254, testmode);
pb->set_dpi(200);
pb->set_unit(Pyro::Unit::MM);
pb->init();

REQUIRE(pb->width() == 4000);
REQUIRE(pb->height() == 2000);
Expand Down
2 changes: 1 addition & 1 deletion screenshot-tests/test-shapes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ TEST_CASE("Variable side count ellipses", "[shapes]")

TEST_CASE("Complex shapes", "[shapes]")
{
Pyro::Graphics *p = Pyro::creategraphics(100, 100, testmode, Pyro::ARGB);
Pyro::Graphics *p = Pyro::creategraphics(100, 100, testmode);
SECTION("Draw shape with hole")
{
std::string filename = "shape_multi_contour.png";
Expand Down
5 changes: 4 additions & 1 deletion screenshot-tests/test-units.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ SCENARIO("Check that different units can be used.")
{
SECTION("Check using current unit")
{
Pyro::Graphics *p = Pyro::creategraphics(4, 4, testmode, 72u, Pyro::Unit::IN);
Pyro::Graphics *p = Pyro::creategraphics(4, 4, testmode);
p->set_dpi(72);
p->set_unit(Pyro::Unit::IN);
p->init();
std::string filename = "using_current_unit.png";
p->nostroke();
p->background(192);
Expand Down
4 changes: 2 additions & 2 deletions src/graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ namespace Pyro
this->background(192);
}

Graphics *creategraphics(unsigned int width, unsigned int height, GraphicsMode mode, unsigned int dpi, Unit unit)
Graphics *creategraphics(unsigned int width, unsigned int height, GraphicsMode mode)
{

switch (mode)
{
case GraphicsMode::CAIRO:
default:
Graphics *g = new GraphicsCairo(width, height, ARGB, dpi, unit);
Graphics *g = new GraphicsCairo(width, height, ARGB, 72, Unit::PX);
g->init();
return g;
}
Expand Down
3 changes: 2 additions & 1 deletion src/pyro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ namespace Pyro
}
Pyro::width = (unsigned int)width * multiplier;
Pyro::height = (unsigned int)height * multiplier;
pg = creategraphics(width, height, GraphicsMode::CAIRO, dpi, unit);
pg = creategraphics(width, height, GraphicsMode::CAIRO);
// , 100, Pyro::Unit::MM
}

void loadpixels()
Expand Down

0 comments on commit 9ff43e7

Please sign in to comment.