Skip to content

Commit 5f730ff

Browse files
committed
PicoVector: Pass PicoGraphics clip into Pretty Poly.
1 parent c3919bd commit 5f730ff

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

libraries/pico_vector/pico_vector.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
namespace pimoroni {
55
void PicoVector::polygon(std::vector<pretty_poly::contour_t<picovector_point_type>> contours, Point origin, int scale) {
6+
pretty_poly::settings::clip = {graphics->clip.x, graphics->clip.y, graphics->clip.w, graphics->clip.h};
67
pretty_poly::draw_polygon<picovector_point_type>(
78
contours,
89
pretty_poly::point_t<int>(origin.x, origin.y),
@@ -50,6 +51,8 @@ namespace pimoroni {
5051
}
5152

5253
Point PicoVector::text(std::string_view text, Point origin) {
54+
// Copy clipping bounds from the PicoGraphics instance
55+
pretty_poly::settings::clip = {graphics->clip.x, graphics->clip.y, graphics->clip.w, graphics->clip.h};
5356
// TODO: Normalize types somehow, so we're not converting?
5457
pretty_poly::point_t<int> caret = pretty_poly::point_t<int>(origin.x, origin.y);
5558

@@ -109,6 +112,8 @@ namespace pimoroni {
109112
}
110113

111114
Point PicoVector::text(std::string_view text, Point origin, float angle) {
115+
// Copy clipping bounds from the PicoGraphics instance
116+
pretty_poly::settings::clip = {graphics->clip.x, graphics->clip.y, graphics->clip.w, graphics->clip.h};
112117
// TODO: Normalize types somehow, so we're not converting?
113118
pretty_poly::point_t<float> caret(0, 0);
114119

libraries/pico_vector/pico_vector.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ namespace pimoroni {
5050
tile_data += tile.stride - tile.bounds.w;
5151
}
5252
}
53-
}, graphics->supports_alpha_blend() ? pretty_poly::X4 : pretty_poly::NONE, {0, 0, graphics->bounds.w, graphics->bounds.h});
53+
}, graphics->supports_alpha_blend() ? pretty_poly::X4 : pretty_poly::NONE, {graphics->clip.x, graphics->clip.y, graphics->clip.w, graphics->clip.h});
5454
}
5555

5656
void set_antialiasing(pretty_poly::antialias_t antialias) {

0 commit comments

Comments
 (0)