[cairo] A Small, Almost-Entirely-Useles Application :)
Jeremy Moles
jeremy at emperorlinux.com
Mon May 12 11:21:09 PDT 2008
I've been using this utility I wrote for myself to create UI elements in
a GUI NodeKit I'm writing for OpenSceneGraph. It was born as the result
of my woeful inability to use Inkscape or the Gimp properly, and my
desire to create graphical elements from Python code and not SVG direcly
(which makes it quite easy to parametrize GUI object creation in my
library).
I figured I'd send it to the lists in here in it's current unfinished
status just for fun. It might be useful if you're like me, but anyone
with more advanced art creation skills will find it utterly abysmal. :)
The only really clever part is the Python decorator that adds the
decorated function to the "library", but that's probably not interesting
to non-Pythonites.
Attached is the application itself and a small example file.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cairodraw
Type: text/x-python
Size: 13754 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20080512/0a27ffab/attachment.py
-------------- next part --------------
import cairo
import math
c.rectangle(0, 0, 512, 512)
c.set_source_rgb(0.7, 0.7, 0.7)
c.fill()
c.set_line_width(1)
w2 = w / 2
h2 = h / 2
shadow = createShadow(w2 + 2, h2 + 2, 45.5, 54.5)
c.set_source(shadow)
c.arc(w2 + 2, h2 + 2, 54.5, 0, 2 * math.pi)
c.fill()
c.set_source_rgb(1.0, 1.0, 1.0)
c.arc(w2, h2, 51.5, 0, 2 * math.pi)
c.fill_preserve()
c.clip()
drawRadialGradientCircle(
c,
w2, h2 - 20, 10.5, 45.5,
(0.0, 1.0, 1.0, 1.0),
(0.0, 1.0, 1.0, 0.1)
)
# c.set_operator(cairo.OPERATOR_IN)
c.fill()
More information about the cairo
mailing list