Skip to content

Commit 8b06327

Browse files
committed
Update chess board example to use fill_rect instead of direct drawing
1 parent 9565640 commit 8b06327

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

README.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,8 @@ int main() {
251251
for (std::size_t y = 0; y < image.height(); y += rect_h) {
252252
bmp::Pixel color = is_white ? bmp::White : bmp::Black;
253253
// Fill rect
254-
for (size_t dx = x; dx < x + rect_w; dx++) {
255-
for (size_t dy = y; dy < y + rect_h; dy++) {
256-
image.set(dx, dy, color);
257-
}
258-
}
254+
image.fill_rect(x, y, rect_w, rect_h, color);
255+
// Next rect in will be the opposite color
259256
is_white = !is_white;
260257
}
261258
is_white = !is_white;

examples/chess_board.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,8 @@ int main() {
1515
for (std::size_t y = 0; y < image.height(); y += rect_h) {
1616
bmp::Pixel color = is_white ? bmp::White : bmp::Black;
1717
// Fill rect
18-
for (size_t dx = x; dx < x + rect_w; dx++) {
19-
for (size_t dy = y; dy < y + rect_h; dy++) {
20-
image.set(dx, dy, color);
21-
}
22-
}
18+
image.fill_rect(x, y, rect_w, rect_h, color);
19+
// Next rect in will be the opposite color
2320
is_white = !is_white;
2421
}
2522
is_white = !is_white;

0 commit comments

Comments
 (0)