olikraus / u8glib

Arduino Monochrom Graphics Library for LCDs and OLEDs
https://github.com/olikraus/u8glib/wiki
Other
1.25k stars 314 forks source link

Rudimentary global offset implementation #276

Open olikraus opened 9 years ago

olikraus commented 9 years ago

Originally reported on Google Code with ID 277

I found myself wanting global offset support in u8glib. This is useful for reusing graphics,
as it allows you to create graphics independently of where you are using it, without
using explicit offset variables. Similar mechanisms exists in many other libraries,
such as OpenGL's glTranslatef.

Attached is a rudimentary implementation of such a mechanism. It works for box/frame/vline/hline/line,
and that's all I have tested so far.

I hope the idea, if not the implementation, can be incorporated into a future release.

Reported by freespace on 2014-09-05 22:33:13


olikraus commented 9 years ago
Thanks for adding the patch. 
I have some doubts to add this to u8glib, because i do not know how many users will
require or use this feature. On the other side it will slow down and require more flash
rom for all users, if i do add this extension.

Reported by olikraus on 2014-09-07 12:38:07

olikraus commented 9 years ago
Those are valid concerns. I find the extension very useful as it allows me to isolate
the logic of creating a visual element from logic of placing the element, and allows
better encapsulation. I suspect many people implement this explicitly by passing x
and y offsets to drawing functions, which is essentially the same in terms of prog
mem and speed cost, but less elegant.

It is perhaps possible to make this extension controlled via conditional compilation,
so it is only activated by users who need it.

Reported by freespace on 2014-09-07 15:20:59

olikraus commented 9 years ago
I keep the comments and your patch here. Let me think about this. 

Reported by olikraus on 2014-09-07 16:18:20

olikraus commented 9 years ago
No worries :) Thank you very much for your time, u8glib has been an enormous help!

Reported by freespace on 2014-09-07 16:25:27