Tuesday, August 17, 2010


Got back from the family holiday in Egypt earlier today and spent a while today working on the implementation of pixbuf drawing routines using cairo and answering various emails from gnocl contributors. The day ended with the addition of two new commands to the gnocl::piuxBuf module: gnocl::screenshot and gnocl::snapshot. The first command will capture the root window display and save it to a new pixbuf whereas gnocl::snapshot will capture the contents of the toplevel window simply by naming any widget in the window tree. This contrasts with the gnocl::pixuf get drawable instruction which, even if applied to a toplevel window, it will never capture the decorative frame.

One use for these functions could be in the creation of desktop movies for tutorials, training etc. These do not capture the position of the mouse pointer,  but this can be composited easily. In fact it would be more desirable to have a larger than life mouse pointer for such purposes, perhaps one with animated effects too!

Here's today's test script:

# basic Tcl/Gnocl Script
#!/bin/sh \
exec tclsh "$0" "$@"

package require Gnocl

set da1 [gnocl::eventBox ]

set win1 [ gnocl::window -defaultWidth 640 -defaultHeight 400 ]

$win1 configure -child $da1

gnocl::draw line $da1 \
    -from {x1 y1} \
    -to {x2 y2} \
    -lineColour red \
    -lineWidth 3 \
    -cap round \
    -dash whatever


set pb1 [gnocl::pixBuf get drawable $win1]
$pb1 save -fileName test1.png -fileType png

set pb2 [gnocl::pixBuf snapshot $win1]
$pb2 save -fileName test2.png -fileType png

set pb3 [gnocl::pixBuf snapshot $da1]
$pb3 save -fileName test3.png -fileType png

set pb4 [gnocl::pixBuf screenshot ]
$pb4 save -fileName test4.png -fileType png


No comments: