MicroTeX icon indicating copy to clipboard operation
MicroTeX copied to clipboard

Generate canvas instructions when no direct access to a canvas

Open lazingor opened this issue 4 years ago • 2 comments

I just discovered that the programming language to which I was hoping to link this library does not support callbacks, which means I cannot directly have the library draw on my program's canvas. In other words, I can only pull data from the library, not have the library pull data from my program.

I was thinking of trying to get around this by implementing the interfaces in graphics.h as outputting text, that I could then interpret and lay out in my program's canvas. So I would pull text like

setColor(red)
setFont(...)
drawText(...)

Do you think this is at all feasible? I am a little bit worried about data that the library might need, that it pulls from elsewhere while it is layout out. For example, does the need for TextLayout.getBounds() break the above idea?

lazingor avatar May 02 '20 12:05 lazingor

This is an excellent idea! The first design is for Android and iOS, and no drawing callbacks were taking into account. Your idea is definitely feasible, I'm going to refactor the graphical interface to support callbacks. Any PR is very appreciate!

NanoMichael avatar May 02 '20 14:05 NanoMichael

Refactoring for drawing callbacks would be excellent! I'm only learning about this now, so I probably can't create a PR, but I'll be very happy to test.

lazingor avatar May 15 '20 14:05 lazingor