Lua Drawings - General Help and Assistance on using CHDK stable releases - CHDK Forum supplierdeeply

Lua Drawings

  • 5 Replies
  • 1719 Views
Lua Drawings
« on: 04 / August / 2022, 08:00:12 »
Advertisements
@reyalp

Would you consider adding the following functionality to Lua drawings.

At the moment, unless I'm missing a trick, I can't simply clear all the drawing objects from the screen, and leave them in memory, ie to be switched back on.

Say a command like this:

draw.show(0 or 1)

*

Offline Caefix

  • *****
  • 947
  • Sorry, busy deleting test shots...
All lifetime is a loan from eternity.

*

Offline reyalp

  • ******
  • 14118
Re: Lua Drawings
« Reply #2 on: 04 / August / 2022, 17:01:45 »
Maybe  :-[ ... set_config_value(1,0) ...
https://chdk.setepontos.com/index.php?topic=13286.msg135122#msg135122
https://forum.chdk-treff.de/viewtopic.php?f=7&t=1911
What? How could set_config_value possibly relate to pigeonhill's question about the drawing library?  :blink:

@pigeonhill it looks to me like the current drawings are stored in the global SCREEN_DRAWINGS
So you might be able to do something like
saved_drawings = SCREEN_DRAWINGS
SCREEN_DRAWINGS = {}

and then to re-enable
SCREEN_DRAWINGS = saved_drawings

Note I haven't tested this, it could break things if the contents of SCREEN_DRAWINGS are referenced through other variables. From a quick skim I don't think it should be a problem, but I didn't go over the whole file in detail.
Don't forget what the H stands for.

Re: Lua Drawings
« Reply #3 on: 04 / August / 2022, 17:04:51 »
Maybe  :-[ ... set_config_value(1,0) ...
https://chdk.setepontos.com/index.php?topic=13286.msg135122#msg135122
https://forum.chdk-treff.de/viewtopic.php?f=7&t=1911
What? How could set_config_value possibly relate to pigeonhill's question about the drawing library?  :blink:

@pigeonhill it looks to me like the current drawings are stored in the global SCREEN_DRAWINGS
So you might be able to do something like
saved_drawings = SCREEN_DRAWINGS
SCREEN_DRAWINGS = {}

and then to re-enable
SCREEN_DRAWINGS = saved_drawings

Note I haven't tested this, it could break things if the contents of SCREEN_DRAWINGS are referenced through other variables. From a quick skim I don't think it should be a problem, but I didn't go over the whole file in detail.

@reyalp

Thanks for the idea. I’ll give it a try and report back.

Cheers

Garry


*

Offline philmoz

  • *****
  • 3450
    • Photos
Re: Lua Drawings
« Reply #4 on: 04 / August / 2022, 18:33:21 »
@reyalp

Would you consider adding the following functionality to Lua drawings.

At the moment, unless I'm missing a trick, I can't simply clear all the drawing objects from the screen, and leave them in memory, ie to be switched back on.

Say a command like this:

draw.show(0 or 1)


An alternative to reyalp's suggestion would be to implement your own 'draw_redraw' function that tested a local variable to decide whether to call the draw.redraw module function or not. If you want to erase the current drawing from the screen you can call 'draw_clear' (not draw.clear) like the draw.redraw function does in drawings.lua.


The drawings module code is in CHDK/LUALIB/drawings.lua so you could also modify your copy of this to extend it - if you make some worthwhile changes we can always merge them into the CHDK source repository.


Phil.

CHDK ports:
  sx30is (1.00c, 1.00h, 1.00l, 1.00n & 1.00p)
  g12 (1.00c, 1.00e, 1.00f & 1.00g)
  sx130is (1.01d & 1.01f)
  ixus310hs (1.00a & 1.01a)
  sx40hs (1.00d, 1.00g & 1.00i)
  g1x (1.00e, 1.00f & 1.00g)
  g5x (1.00c, 1.01a, 1.01b)
  g7x2 (1.01a, 1.01b, 1.10b)

Re: Lua Drawings
« Reply #5 on: 05 / August / 2022, 03:40:49 »
@reyalp @philmoz

All is right with the world  :)

Thanks to your suggestions, I looked at the LUALIB drawings and realised I could achieve what I was after simply like this:

Code: [Select]
elseif (is_key("display") and get_alt_mode()) then
        if show then
            draw_clear()
            show = false
        elseif not show then
            draw.overdraw()
            show = true
        end
    end
« Last Edit: 05 / August / 2022, 04:07:15 by pigeonhill »

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal