Monday, August 23, 2010

gnocl::draw gradient -type linear | radial

Apart from wasting some time today to debug what eventually proved to be nothing other than a simple typo, the day's coding has been somewhat effective. I've focussed on implementing gradients. An earlier posting showed this done using pure Tcl, but, this is too slow for practical purposed. The Cairo routines are blindingly fast. Here's what the current comment looks like:

gnocl::draw gradient $pb -type linear -from {10 10} -to {90 90} -startColor {1 0 1 1 } -endColor {1 0 0 1 } -startOffset 0 -endOffset 0.5
gnocl::draw gradient $pb -type radial -center1 {50 50} -center2 { 60 60 }  -startColor {1 0 1 1 } -endColor {1 0 0 1 } -startOffset 0 -endOffset 0.5

Needles to say, these are all completely experimental at the moment and once the service funcs are in place the syntax might need re-considering. The gradient, for instance can support multple colours which might result in providing a list of colours, eg:

-colors [list {1 0 1 1 1} {1 0 1 1 0.5} {1 0 1 1 1} ]

Each float within the list being:
r g b a o

Where:
r = red
g = green
b = blue
a = alpha
o = offset

Also, the gradients produces are patterns for subsequent fill operations. This, along with other parameters such as outline, fill colours, line width etc need to be set globally. This, I think will probably be tomorrow's task.
 

No comments: