Reading source code made me wonder if it's possible to add some on-screen drawings for lua. I've also found this request:
http://chdk.setepontos.com/index.php?topic=5502.0I gave it a try and here it is! Patch below this post contains diff from luascript.c file from changeset 1415. If this function will find acceptance it could be added to the trunk. In my opinion simple drawings might be usefull.
Ok, and now, what this patch gives us. New functions:
draw_pixel(x,y,color)
draw_line(x1,y1,x2,y2,color)
draw_rect(x1,y1,x2,y2,color,[thickness])
draw_circle(x,y,r,color)
draw_ellipse(x,y,a,b,color)
draw_clear()
get_screen_width()
get_screen_height()
Most of these functions explain themselves but some additional info:
- when you draw a rect you can specify a thickness - if no thickness is set the value of 1 will be used; if <=0 value is set the rect will be filled with specified color
- thickness (and fill) of circle and ellipse is not supported (yet?)
- get_screen_width() and ...height() don't work as I expect, it would be nice if somebody look into a code and told me why it returns strange value instead of number (is it hex value? value of what?!). These two function could be usefull not only for drawings.
- draw_clear() removes all drawings from the screen
All colors are numbers in decimal.
As in cited topic reyalp said - every time the screen is updated the whole drawing wipes away. But I've observed ot occurs only while I rotate a camera or in situations like this. But then the script console also dissappears so it's the same problem.
I've been trying to use the other way that reyalp suggested in cited thread - to make some possibility to add 'widgets' to OSD from lua. But being not familiar with C I felt lost somewhere between mallocs...
I like to see your comments, if you like it or not.
Regards!