Drawing Exercise - Script Writing - CHDK Forum supplierdeeply

Drawing Exercise

  • 4 Replies
  • 3431 Views
Drawing Exercise
« on: 12 / September / 2014, 11:30:22 »
Advertisements
Just a useless mini lua script to test CHDK "graphic" features (...not too many, sadly)  :P

Code: [Select]
--[[
@title Selftimer ICO
@param     g Selftimer (sec)
  @default g 10
  @range   g 0 60
@param     f Start Msg Time (sec)
  @default f 5
  @range   f 0 60
--]]
require("drawings")

function s_ico()                                            -- Selftimer ICO + # sec
        if ( g > 9 ) then xs=174   else xs=188 end
    for i=0,(f*10),1 do
        draw_rect( 138, 93, 222, 147, 258,2)
        draw_rect_filled( 140, 95, 220, 145, 257, 257)
        draw_ellipse( 180, 120, 23, 23, 258)
        draw_ellipse( 180, 120, 22, 22, 258)
        draw_ellipse( 180, 120, 21, 21, 258)
        draw_rect_filled( 155, 95, 166, 110, 257, 257)
        draw_string( 172, 95, "'", 258, 257,2,2)
        draw_string( xs, 114, g, 258, 257,2,2)
        draw_line( 164, 107, 177, 118, 258)
        draw_line( 164, 107, 176, 118, 258)
        draw_line( 164, 107, 175, 118, 258)
        draw_line( 164, 107, 174, 118, 258)
        draw.overdraw()
    sleep(100)
    end
    draw.clear()
end

function ellipse()                                             -- circle
   draw_ellipse_filled( 35, 35, 28, 28, 258)
   draw_ellipse_filled( 35, 35, 23, 23, 256)
end

function blink()                                               -- blinking # sec
    for i=0, g,1 do
    if ( (g-i) > 9 ) then xn=20 else xn=28 end
       set_led(4,1) ellipse() draw_rect_filled( 0, 0, 35, 35, 256, 256) draw_string( xn, 22, (g-i), 258, 256, 2, 2)
       sleep(250)
       set_led(4,0) ellipse() draw_rect_filled( 35, 0, 64, 35, 256, 256) draw_string( xn, 22, (g-i), 258, 256, 2, 2)
       sleep(250)
       set_led(4,1) ellipse() draw_rect_filled( 35, 35, 64, 64, 256, 256) draw_string( xn, 22, (g-i), 258, 256, 2, 2)
       sleep(250)
       set_led(4,0) ellipse() draw_rect_filled( 0, 35, 35, 64, 256, 256) draw_string( xn, 22, (g-i), 258, 256, 2, 2)
       sleep(250)
       draw_clear()
  end
end

function half_press()
    press("shoot_half")
    while(is_pressed("shoot_half")) do sleep(20) end
    release("shoot_half")
    end

function full_press()
    if( g > 0) then
    blink()
    end
    press("shoot_full")
    while(is_pressed("shoot_full")) do sleep(20) end
    release("shoot_full")
    end
-------------------------------------------------------------------
    set_exit_key("no_key")
    set_draw_title_line(0)
    if( g > 0) then s_ico() end
 
    repeat
        repeat
           wait_click(1000)
    until not(is_key("no_key"))
      if (is_key("shoot_full")) then full_press()
        elseif (is_key("shoot_half")) then half_press()
        elseif ( is_key("zoom_in")) then
            press("zoom_in")
            while(is_pressed("zoom_in")) do sleep(20) end
            release("zoom_in")
      elseif ( is_key("zoom_out")) then
          press("zoom_out")
          while(is_pressed("zoom_out")) do sleep(20) end
          release("zoom_out")
          end
    until ( is_key("menu") )


Running script image

I was wondering if we could get a draw.add("image") for a WYSIWYG script/menu interface.

EDIT Corrected the shooting part  ::)
« Last Edit: 12 / September / 2014, 14:55:42 by fabri22 »

Re: Drawing Exercise
« Reply #1 on: 12 / September / 2014, 13:36:58 »
Just a useless mini lua script to test CHDK "graphic" features (...not too many, sadly)  :P
Very nice.  I might have to "steal" this for some of my scripts.

Quote
I was wondering if we could get a draw.add("image") for a WYSIWYG script/menu interface.
That's been asked occasionally in the past I think, but with no resolution.   Some way to store images in some sort of 8 color 320x240 bitmap file format on the SD card doesn't seem unreasonable - especially if it can be buffered in memory for rapid redraws.  That might limit it to one active image at a time but I don't think that would be a problem.  You'd want a file format that common bitmap Paint programs can work with.

update : on second thought,  even a monocolor bitmap would be useful (and take a lot less space and processing time)
« Last Edit: 12 / September / 2014, 14:49:14 by waterwingz »
Ported :   A1200    SD940   G10    Powershot N    G16

Re: Drawing Exercise
« Reply #2 on: 12 / September / 2014, 15:38:28 »
I was thinking to something like this  ::) (8 mini b/w custom bitmaps). Too memory/processing time ??


Re: Drawing Exercise
« Reply #3 on: 12 / September / 2014, 17:14:48 »
I was thinking to something like this  ::) (8 mini b/w custom bitmaps). Too memory/processing time ??
You might want to review this conversation :
http://chdk.setepontos.com/index.php?topic=8151.msg85905#msg85905
I don't think it reached a definite conclusion but it did cover some of the same ground.
Ported :   A1200    SD940   G10    Powershot N    G16


Re: Drawing Exercise
« Reply #4 on: 12 / September / 2014, 18:23:39 »
You might want to review this conversation :
http://chdk.setepontos.com/index.php?topic=8151.msg85905#msg85905
I don't think it reached a definite conclusion but it did cover some of the same ground.

Very intersting thread. It deserves a careful reading (55 pages!).
Surely my above question is a symptom of "smartphone syndrome".
It maybe that philmoz is right when he says "CHDK by it's nature is for 'advanced' users - let's now not get caught up in dumbing it down for the masses."... or someone disabled the icon interface of his own old phones.
:)

 

Related Topics


SimplePortal 2.3.6 © 2008-2014, SimplePortal