Skip to content

Commit

Permalink
Merge pull request #9851 from FoamyGuy/vectorio_rotation_fix
Browse files Browse the repository at this point in the history
fix vectorio rotation issue
  • Loading branch information
tannewt authored Dec 2, 2024
2 parents 4e3cd7d + 526b151 commit 0c9aa80
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ CIRCUITPY_CODEOP = 0
CIRCUITPY_FLOPPYIO = 0
CIRCUITPY_JPEGIO = 0
CIRCUITPY_SYNTHIO = 0
CIRCUITPY_VECTORIO = 0

# We don't have room for the fonts for terminalio for certain languages,
# so turn off terminalio, and if it's off and displayio is on,
Expand Down
1 change: 1 addition & 0 deletions ports/atmel-samd/boards/metro_m4_express/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ CIRCUITPY_CODEOP = 0
CIRCUITPY_FLOPPYIO = 0
CIRCUITPY_JPEGIO = 0
CIRCUITPY_SYNTHIO = 0
CIRCUITPY_VECTORIO = 0

# We don't have room for the fonts for terminalio for certain languages,
# so turn off terminalio, and if it's off and displayio is on,
Expand Down
1 change: 1 addition & 0 deletions ports/atmel-samd/boards/openbook_m4/mpconfigboard.mk
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ LONGINT_IMPL = MPZ
CIRCUITPY_KEYPAD = 1
CIRCUITPY_SYNTHIO = 0
CIRCUITPY_JPEGIO = 0
CIRCUITPY_FLOPPYIO = 0
12 changes: 9 additions & 3 deletions shared-module/vectorio/VectorShape.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,12 @@ static void _get_screen_area(vectorio_vector_shape_t *self, displayio_area_t *ou
x = self->absolute_transform->x + self->absolute_transform->dx * self->y;
y = self->absolute_transform->y + self->absolute_transform->dy * self->x;
if (self->absolute_transform->dx < 1) {
x -= 1;
out_area->y1 = out_area->y1 * -1 + 1;
out_area->y2 = out_area->y2 * -1 + 1;
}
if (self->absolute_transform->dy < 1) {
y -= 1;
out_area->x1 = out_area->x1 * -1 + 1;
out_area->x2 = out_area->x2 * -1 + 1;
}
Expand All @@ -109,10 +111,12 @@ static void _get_screen_area(vectorio_vector_shape_t *self, displayio_area_t *ou
y = self->absolute_transform->y + self->absolute_transform->dy * self->y;

if (self->absolute_transform->dx < 1) {
x -= 1;
out_area->x1 = out_area->x1 * -1 + 1;
out_area->x2 = out_area->x2 * -1 + 1;
}
if (self->absolute_transform->dy < 1) {
y -= 1;
out_area->y1 = out_area->y1 * -1 + 1;
out_area->y2 = out_area->y2 * -1 + 1;
}
Expand All @@ -132,24 +136,25 @@ static void screen_to_shape_coordinates(vectorio_vector_shape_t *self, uint16_t
VECTORIO_SHAPE_PIXEL_DEBUG(" a(%3d, %3d)", *out_shape_x, *out_shape_y);
if (self->absolute_transform->dx < 1) {
*out_shape_y *= -1;
*out_shape_y -= 1;
}
if (self->absolute_transform->dy < 1) {
*out_shape_x *= -1;
*out_shape_x -= 1;
}
VECTORIO_SHAPE_PIXEL_DEBUG(" b(%3d, %3d)", *out_shape_x, *out_shape_y);
} else {
*out_shape_x = x - self->absolute_transform->x - self->absolute_transform->dx * self->x;
*out_shape_y = y - self->absolute_transform->y - self->absolute_transform->dy * self->y;

VECTORIO_SHAPE_PIXEL_DEBUG(" a(%3d, %3d)", *out_shape_x, *out_shape_y);
if (self->absolute_transform->dx < 1) {
*out_shape_x *= -1;
*out_shape_x -= 1;
}
if (self->absolute_transform->dy < 1) {
*out_shape_y *= -1;
*out_shape_y -= 1;
}
VECTORIO_SHAPE_PIXEL_DEBUG(" b(%3d, %3d)", *out_shape_x, *out_shape_y);

// It's mirrored via dx. Maybe we need to add support for also separately mirroring?
// if (self->absolute_transform->mirror_x) {
// pixel_to_get_x = (shape_area.x2 - shape_area.x1) - (pixel_to_get_x - shape_area.x1) + shape_area.x1 - 1;
Expand All @@ -158,6 +163,7 @@ static void screen_to_shape_coordinates(vectorio_vector_shape_t *self, uint16_t
// pixel_to_get_y = (shape_area.y2 - shape_area.y1) - (pixel_to_get_y - shape_area.y1) + +shape_area.y1 - 1;
// }
}
VECTORIO_SHAPE_PIXEL_DEBUG(" b(%3d, %3d)", *out_shape_x, *out_shape_y);
}

static void check_bounds_and_set_x(vectorio_vector_shape_t *self, mp_int_t x) {
Expand Down

0 comments on commit 0c9aa80

Please sign in to comment.