diff --git a/adafruit_ra8875/ra8875.py b/adafruit_ra8875/ra8875.py index 29ac5f7..1f3e82b 100755 --- a/adafruit_ra8875/ra8875.py +++ b/adafruit_ra8875/ra8875.py @@ -573,7 +573,7 @@ def rect(self, x, y, width, height, color): :param int height: The height of the rectangle :param int color: The color of the rectangle """ - self._rect_helper(x, y, width, height, color, False) + self._rect_helper(x, y, x + width - 1, y + height - 1, color, False) def fill_rect(self, x, y, width, height, color): """ @@ -585,7 +585,7 @@ def fill_rect(self, x, y, width, height, color): :param int height: The height of the rectangle :param int color: The color of the rectangle """ - self._rect_helper(x, y, width, height, color, True) + self._rect_helper(x, y, x + width - 1, y + height - 1, color, True) def fill(self, color): """ @@ -593,7 +593,7 @@ def fill(self, color): :param int color: The color to Fill the screen """ - self._rect_helper(0, 0, self.width, self.height, color, True) + self._rect_helper(0, 0, self.width - 1, self.height - 1, color, True) def circle(self, x_center, y_center, radius, color): """ @@ -706,7 +706,7 @@ def hline(self, x, y, width, color): :param int width: The width of the line :param int color: The color of the line """ - self.line(x, y, x + width, y, color) + self.line(x, y, x + width - 1, y, color) def vline(self, x, y, height, color): """ @@ -717,7 +717,7 @@ def vline(self, x, y, height, color): :param int height: The height of the line :param int color: The color of the line """ - self.line(x, y, x, y + height, color) + self.line(x, y, x, y + height - 1, color) def line(self, x1, y1, x2, y2, color): """ @@ -758,13 +758,14 @@ def round_rect(self, x, y, width, height, radius, color): """ self._gfx_mode() self._curve_helper(x + radius, y + radius, radius, radius, 1, color, False) - self._curve_helper(x + width - radius, y + radius, radius, radius, 2, color, False) + self._curve_helper(x + width - radius - 1, y + radius, radius, radius, 2, color, False) self._curve_helper(x + radius, y + height - radius, radius, radius, 0, color, False) - self._curve_helper(x + width - radius, y + height - radius, radius, radius, 3, color, False) - self.hline(x + radius, y, width - (radius * 2), color) - self.hline(x + radius, y + height, width - (radius * 2), color) + self._curve_helper(x + width - radius - 1, y + height - radius, radius, radius, 3, color, + False) + self.hline(x + radius, y, width - (radius * 2) - 1, color) + self.hline(x + radius, y + height, width - (radius * 2) - 1, color) self.vline(x, y + radius, height - (radius * 2), color) - self.vline(x + width, y + radius, height - (radius * 2), color) + self.vline(x + width - 1, y + radius, height - (radius * 2), color) def fill_round_rect(self, x, y, width, height, radius, color): """ @@ -779,11 +780,12 @@ def fill_round_rect(self, x, y, width, height, radius, color): """ self._gfx_mode() self._curve_helper(x + radius, y + radius, radius, radius, 1, color, True) - self._curve_helper(x + width - radius, y + radius, radius, radius, 2, color, True) + self._curve_helper(x + width - radius - 1, y + radius, radius, radius, 2, color, True) self._curve_helper(x + radius, y + height - radius, radius, radius, 0, color, True) - self._curve_helper(x + width - radius, y + height - radius, radius, radius, 3, color, True) - self._rect_helper(x + radius, y, x + width - radius, y + height, color, True) - self._rect_helper(x, y + radius, x + width, y + height - radius, color, True) + self._curve_helper(x + width - radius - 1, y + height - radius, radius, radius, 3, color, + True) + self._rect_helper(x + radius, y, x + width - radius - 1, y + height - 1, color, True) + self._rect_helper(x, y + radius, x + width - 1, y + height - radius - 1, color, True) def _circle_helper(self, x, y, radius, color, filled): """General Circle Drawing Helper""" @@ -800,17 +802,17 @@ def _circle_helper(self, x, y, radius, color, filled): self._write_reg(reg.DCR, reg.DCR_CIRC_START | (reg.DCR_FILL if filled else reg.DCR_NOFILL)) self._wait_poll(reg.DCR, reg.DCR_CIRC_STATUS) - def _rect_helper(self, x, y, width, height, color, filled): + def _rect_helper(self, x1, y1, x2, y2, color, filled): """General Rectangle Drawing Helper""" self._gfx_mode() # Set X and Y - self._write_reg16(0x91, x) - self._write_reg16(0x93, y + self.vert_offset) + self._write_reg16(0x91, x1) + self._write_reg16(0x93, y1 + self.vert_offset) # Set Width and Height - self._write_reg16(0x95, width) - self._write_reg16(0x97, height + self.vert_offset) + self._write_reg16(0x95, x2) + self._write_reg16(0x97, y2 + self.vert_offset) self.set_color(color) diff --git a/examples/ra8875_simpletest.py b/examples/ra8875_simpletest.py index 958bd7d..8cc558b 100644 --- a/examples/ra8875_simpletest.py +++ b/examples/ra8875_simpletest.py @@ -45,17 +45,17 @@ display.circle(100, 100, 50, BLACK) display.fill_circle(100, 100, 49, BLUE) -display.fill_rect(11, 11, 398, 198, GREEN) +display.fill_rect(10, 10, 400, 200, GREEN) display.rect(10, 10, 400, 200, BLUE) display.fill_round_rect(200, 10, 200, 100, 10, RED) -display.round_rect(199, 9, 202, 102, 12, BLUE) +display.round_rect(200, 10, 200, 100, 10, BLUE) display.pixel(10, 10, BLACK) display.pixel(11, 11, BLACK) display.line(10, 10, 200, 100, RED) +display.fill_triangle(200, 15, 250, 100, 150, 125, YELLOW) display.triangle(200, 15, 250, 100, 150, 125, BLACK) -display.fill_triangle(200, 16, 249, 99, 151, 124, YELLOW) +display.fill_ellipse(300, 100, 100, 40, BLUE) display.ellipse(300, 100, 100, 40, RED) -display.fill_ellipse(300, 100, 98, 38, BLUE) display.curve(50, 100, 80, 40, 2, BLACK) display.fill_curve(50, 100, 78, 38, 2, WHITE)