Skip to content

Commit dd024c8

Browse files
committed
Do not set a default background with creategraphics
1 parent fa09f6d commit dd024c8

7 files changed

Lines changed: 17 additions & 5 deletions

File tree

include/pyro/graphics.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,12 @@ namespace Pyro
244244
GraphicsMode mode = GraphicsMode::CAIRO,
245245
std::filesystem::path filename = "");
246246

247-
Graphics *creategraphics(unsigned int width, unsigned int height, int dpi, Unit unit, GraphicsMode mode = GraphicsMode::CAIRO, std::filesystem::path filename = "");
247+
Graphics *creategraphics(unsigned int width,
248+
unsigned int height,
249+
int dpi,
250+
Unit unit,
251+
GraphicsMode mode = GraphicsMode::CAIRO,
252+
std::filesystem::path filename = "");
248253
}; // namespace Pyro
249254

250255
#endif

screenshot-tests/test-graphics.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ TEST_CASE("Test triangle")
5555
std::filesystem::path filename = "graphics_triangle.png";
5656

5757
Pyro::Graphics *triangle = Pyro::creategraphics(256, 256, mode);
58+
triangle->background(192);
5859
triangle->begindraw();
5960
triangle->fill(1.0f, 0.0f, 1.0f, 1.0f);
6061
triangle->stroke(0.0f, 1.0f, 0.0f, 1.0f);
@@ -71,6 +72,7 @@ TEST_CASE("Test smoothing")
7172
std::filesystem::path filename = "graphics_smooth.png";
7273

7374
Pyro::Graphics *smoothing = Pyro::creategraphics(9 * 50, 50, mode);
75+
smoothing->background(192);
7476
smoothing->begindraw();
7577
smoothing->ellipsemode(Pyro::CENTER);
7678
for (unsigned int i = 0; i < 9; i++)
@@ -92,6 +94,7 @@ TEST_CASE("Test blend modes")
9294
std::filesystem::path filename = "graphics_blend.png";
9395
Pyro::Graphics *blending = Pyro::creategraphics(300, 300, mode);
9496

97+
blending->background(192);
9598
blending->nostroke();
9699

97100
blending->blendmode(Pyro::BLEND);

screenshot-tests/test-image-placements.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ TEST_CASE("Place image in various ways")
2323
}
2424

2525
p = Pyro::creategraphics(img->width(), img->height(), mode);
26+
p->background(192);
2627
p->begindraw();
2728
p->image(img, 0, 0);
2829
p->enddraw();
@@ -41,6 +42,7 @@ TEST_CASE("Place image in various ways")
4142
}
4243

4344
p = Pyro::creategraphics(img->width(), img->height(), mode);
45+
p->background(192);
4446
p->imagemode(Pyro::CENTER);
4547
p->translate(p->width() / 2.0f, p->height() / 2.0f);
4648
p->rotate(Pyro::QUARTER_PI);

screenshot-tests/test-shapes.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ TEST_CASE("Test Rect", "[shapes]")
1212
{
1313
p = Pyro::creategraphics(250, 250, mode);
1414
filename = "shape_rect_corner.png";
15+
p->background(192);
1516
p->nofill();
1617
p->stroke(0.0f, 1.0f);
1718
p->rect(10, 10, 100, 100);
@@ -33,6 +34,7 @@ TEST_CASE("Test Rect", "[shapes]")
3334
{
3435
p = Pyro::creategraphics(250, 250, mode);
3536
filename = "shape_rect_center.png";
37+
p->background(192);
3638
p->rectmode(Pyro::CENTER);
3739
p->nofill();
3840
p->stroke(0.0f, 1.0f);
@@ -134,6 +136,7 @@ TEST_CASE("Complex shapes", "[shapes]")
134136
auto mode = GENERATE(Pyro::GraphicsMode::CAIRO, Pyro::GraphicsMode::SDL);
135137
Pyro::Graphics *p = Pyro::creategraphics(100, 100, mode);
136138
std::filesystem::path filename = "shape_multi_contour.png";
139+
p->background(192);
137140
p->translate(50, 50);
138141
p->stroke(255, 0, 0);
139142
p->beginshape();

screenshot-tests/test-style.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ TEST_CASE("Push and pop style")
99

1010
Pyro::Graphics *p = Pyro::creategraphics(400, 400);
1111

12+
p->background(192);
1213
p->curvedetail(132);
1314

1415
p->ellipse(0, 200, 132, 132); // Left circle

src/graphics.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22
#include "pyro/shape.h"
33
#include <stdexcept>
44
#define _USE_MATH_DEFINES
5-
#include <cmath>
65

76
#include "pyro/graphics.h"
87
#include "pyro/graphics_cairo.h"
98
#include "pyro/graphics_sdl.h"
109
#include "pyro/utils.h"
1110

12-
#include <iostream>
1311
#include <cstring>
1412

1513
namespace Pyro
@@ -32,7 +30,6 @@ namespace Pyro
3230
this->strokeweight(1.0f);
3331
this->textsize(16.0f);
3432
this->strokecap(ROUND);
35-
this->background(192);
3633
}
3734

3835
Graphics *creategraphics(unsigned int width, unsigned int height, GraphicsMode mode, std::filesystem::path filename)

src/pyro.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "pyro/pyro.h"
22
#include <cstdlib>
3-
#include <iostream>
3+
44
namespace Pyro
55
{
66
Graphics *pg{nullptr};
@@ -60,6 +60,7 @@ namespace Pyro
6060
pg->set_dpi(dpi);
6161
pg->set_unit(unit);
6262
pg->init();
63+
pg->background(192);
6364
Pyro::width = pg->width();
6465
Pyro::height = pg->height();
6566
}

0 commit comments

Comments
 (0)