Sunday, August 22, 2010

Cairo drawing functionality

When I was on holiday I was determined that I would complete the Cairo drawing functionality soon after returning home. Well, I've now got a whole pile of drawing functions implemented. At the moment these only write to a pixbuf, but it should be reasonably straightforward to allow drawing to GtkDrawables too.

Here's the test script just to show how it works...

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

package require Gnocl

proc snap {w} {
    set pb [gnocl::pixBuf snapshot $w]
    #gnocl::draw circle $pb -center {50 50} -radius {20}
    #gnocl::draw line $pb -from {10 10} -to {50 50}
    #gnocl::draw text $pb -position {5 100} -text "Gnocl 0.9.95"
    #gnocl::draw arc $pb -center {50 50} -radius 20 -startAngle 0 -endAngle 135 -fill 1 -negative 1
    #gnocl::draw square $pb -center {50 50} -length 20 -fill 1
    #gnocl::draw square $pb -center {50 100} -length 20
    #gnocl::draw rectangle $pb -center {50 100} -width 50 -height 25 -fill 1
    gnocl::draw curve $pb -points {10 50 20 10 30 50 40 20} -fill 1

    $pb save -fileName test.png -fileType png
 }


set but1 [gnocl::button -text "SnapShot" -onClicked {snap %w}]

set win1 [ gnocl::window -child $but1 -onDelete exit -x 200 -y 200]
$win1 configure -width 100 -height 100

gnocl::mainLoop

No comments: