ThingPulse / esp8266-oled-ssd1306

Driver for the SSD1306 and SH1106 based 128x64, 128x32, 64x48 pixel OLED display running on ESP8266/ESP32
https://thingpulse.com
Other
2.03k stars 643 forks source link

drawRect and fillRect produce rects of different size #66

Closed igrr closed 8 years ago

igrr commented 8 years ago

Currently the code in OLEDDisplay::drawRect is as follows:

  drawHorizontalLine(x, y, width);
  drawVerticalLine(x, y, height);
  drawVerticalLine(x + width, y, height);
  drawHorizontalLine(x, y + height, width);

Compared to fillRect function, this draws a rectangle which is 1 pixel wider and 1 pixel higher. Also it lacks a pixel at the lower-right corner.

media-20160710

If I change that to x + width - 1 and y + height - 1, i get same size as for fillRect. I'm not sure if such a "fix" qualifies as a change in API though :)

And by the way, why is fillRect using drawHorizontalLine? Isn't drawVerticalLine faster because it can set up to 8 pixels at a time?

FWeinb commented 8 years ago

Thanks for reporting, this won't qualify as a change in API because this is clearly a bug in the code. Good idea to improve fillRect by using drawVerticalLine!

FWeinb commented 8 years ago

Thanks for reporting. We decided to release this in 4.0.0 with some other fixes that could possible break existing code.