Skip to content

Commit f0e0c13

Browse files
DaveSpraguemarcelstoer
authored andcommitted
Reverting Circle Drawing Functions Back to Working Version (#257)
A recently pull request, #236, made breaking changes to the circle draw calculations. This PR reverts those three functions to their previously working version.
1 parent 42d9d63 commit f0e0c13

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.vscode

src/OLEDDisplay.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ void OLEDDisplay::drawCircle(int16_t x0, int16_t y0, int16_t radius) {
212212
int16_t dp = 1 - radius;
213213
do {
214214
if (dp < 0)
215-
dp = dp + (++x) << 1 + 3;
215+
dp = dp + (x++) * 2 + 3;
216216
else
217-
dp = dp + (++x) << 1 - (--y) << 1 + 5;
217+
dp = dp + (x++) * 2 - (y--) * 2 + 5;
218218

219219
setPixel(x0 + x, y0 + y); //For the 8 octants
220220
setPixel(x0 - x, y0 + y);
@@ -238,9 +238,9 @@ void OLEDDisplay::drawCircleQuads(int16_t x0, int16_t y0, int16_t radius, uint8_
238238
int16_t dp = 1 - radius;
239239
while (x < y) {
240240
if (dp < 0)
241-
dp = dp + (++x) << 1 + 3;
241+
dp = dp + (x++) * 2 + 3;
242242
else
243-
dp = dp + (++x) << 1 - (--y) << 1 + 5;
243+
dp = dp + (x++) * 2 - (y--) * 2 + 5;
244244
if (quads & 0x1) {
245245
setPixel(x0 + x, y0 - y);
246246
setPixel(x0 + y, y0 - x);
@@ -278,9 +278,9 @@ void OLEDDisplay::fillCircle(int16_t x0, int16_t y0, int16_t radius) {
278278
int16_t dp = 1 - radius;
279279
do {
280280
if (dp < 0)
281-
dp = dp + (++x) << 1 + 3;
281+
dp = dp + (x++) * 2 + 3;
282282
else
283-
dp = dp + (++x) << 1 - (--y) << 1 + 5;
283+
dp = dp + (x++) * 2 - (y--) * 2 + 5;
284284

285285
drawHorizontalLine(x0 - x, y0 - y, 2*x);
286286
drawHorizontalLine(x0 - x, y0 + y, 2*x);

0 commit comments

Comments
 (0)