Bodmer / TFT_HX8357

Arduino library for HX8357 TFT display
118 stars 52 forks source link

Rotation of the rectangle #28

Closed rafik73github closed 5 years ago

rafik73github commented 5 years ago

Welcome How do you rotate a filled rectangle? I want to draw clock hands in this way. Project based on the TFT_Clock.ino program. Source: https://github.com/Bodmer/TFT_HX8357/tree/master/examples/TFT_Clock

Greetings

Bodmer commented 5 years ago

There is no "draw a rotated rectangle function" in the library so you need to write this yourself.

A rotated rectangle can be drawn using two triangles, so you only need to work out where the corners are using trig. I suspect you want to draw clock hands so in this case maybe single triangles can be used. If you wish to draw "moving" hands you also have to erase the old rectangle before your draw the new one, so expect to get some flickering.

With single line hands the method I used to reduce flickering was:

  1. draw new hand position
  2. erase old hand position (this wipes a few of the new hands pixels near the centre)
  3. draw new hand position again (to replace wiped pixels)