Skip to content

Commit

Permalink
PicoVector: Update C++ examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gadgetoid committed Aug 12, 2024
1 parent 30e0703 commit 4ff30e8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
13 changes: 7 additions & 6 deletions examples/pico_display_2/pico_display_2_vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,15 @@ int main() {

pp_point_t outline[] = {{-64, -64}, {64, -64}, {64, 64}, {-64, 64}};
pp_point_t hole[] = {{ -32, 32}, { 32, 32}, { 32, -32}, { -32, -32}};
pp_path_t paths[] = {
{.points = outline, .count = 4},
{.points = hole, .count = 4}
};
pp_poly_t poly = {.paths = paths, .count = 2};

pp_poly_t *poly = pp_poly_new();
pp_path_add_points(pp_poly_add_path(poly), outline, sizeof(outline) / sizeof(pp_point_t));
pp_path_add_points(pp_poly_add_path(poly), hole, sizeof(hole) / sizeof(pp_point_t));

pp_mat3_t pos = pp_mat3_identity();
pp_mat3_translate(&pos, 50, 50);
pp_mat3_rotate(&pos, a);
vector.draw(&poly);
vector.draw(poly);
vector.text("Hello World", &pos);

// update screen
Expand All @@ -60,6 +59,8 @@ int main() {
if (a > 359) {
a = 0;
}

pp_poly_free(poly);
}

return 0;
Expand Down
17 changes: 9 additions & 8 deletions examples/pico_w_explorer/pico_w_explorer_vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,15 @@ int main() {

pp_point_t outline[] = {{-128, -128}, {128, -128}, {128, 128}, {-128, 128}};
pp_point_t hole[] = {{ -64, 64}, { 64, 64}, { 64, -64}, { -64, -64}};
pp_path_t paths[] = {
{.points = outline, .count = 4},
{.points = hole, .count = 4}
};
pp_poly_t poly = {.paths = paths, .count = 2};

vector.rotate(&poly, {0, 0}, angle);
vector.translate(&poly, {160, 120});
pp_poly_t *poly = pp_poly_new();
pp_path_add_points(pp_poly_add_path(poly), outline, sizeof(outline) / sizeof(pp_point_t));
pp_path_add_points(pp_poly_add_path(poly), hole, sizeof(hole) / sizeof(pp_point_t));

vector.draw(&poly);
vector.rotate(poly, {0, 0}, angle);
vector.translate(poly, {160, 120});

vector.draw(poly);

//pp_mat3_t t = pp_mat3_identity();
//vector.text("Hello World", {0, 0}, &t);
Expand All @@ -49,6 +48,8 @@ int main() {
st7789.update(&graphics);

angle += 1.0f;

pp_poly_free(poly);
}

return 0;
Expand Down

0 comments on commit 4ff30e8

Please sign in to comment.