Question about alpha blending and low level drawing on widgets

  • Thread starter Gabriele Farina *DarkBard*
  • Start date
G

Gabriele Farina *DarkBard*

Hi, sorry for the strange title, but I have to ask you if you can help me:
I'm planning to start a project where I need a Macromedia-Flash-like
drawing canvas. I started implementing my own using wxPython but I
sopped myself when I undestood that there was no way to draw primitives
filling them with opaque colors.
So I tried to include a Pygame inside wxPython (I need a multi platform
GUI engine), but there where 2 problems:
1) the pygame window flips a lot on resize;
2) when I try to run my simple example on Linux (Suze 9.1) it crashes,
giveing me this error:

(test.py:2772): Gdk-WARNING **: gdkdrawable-x11.c:1012 drawable is not a
pixmap or window
The program 'test.py' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadWindow (invalid Window parameter)'.
(Details: serial 42 error_code 3 request_code 3 minor_code 0)
(Note to programmers: normally, X errors are reported asynchronously;
that is, you will receive the error a while after causing it.
To debug your program, run it with the --sync command line
option to change this behavior. You can then get a meaningful
backtrace from your debugger if you break on the gdk_x_error()
function.)


.....

I think there are some problems with the window handle I use to set the
window where SDL must draw, but I can't understand where ...

So I thought other ways:
1) using PyOpengl (tha supports alpha whe drawing primitives, supports
very well zooming and gradient filling), but I think it is not a good
choice because of some problems related to videocards ...
2) Use TK Canvas, but I think it does not understand alpha (am I right??) ..
3) Use QT, but I need a multiplatform application, and under windows QT
are not totally free ...

So my question is:
how can i solve my problem ?? :)
There is a GUI toolkit (maybe FOX??) that gives me a way to make low
level drawing using alpha??
There is a way to implement alpha drawing in wxPython??

tnx a lot, sorry for my cursed english ;)

bye,
Gabriele
 
C

Christopher T King

2) Use TK Canvas, but I think it does not understand alpha (am I right??) ..

The Tk Canvas doesn't understand alpha per se, but it does allow you to
stipple objects -- i.e. fill in only a certain percentage of points in the
object. You only get a few different stippling levels (10, 25, 50, 75, and
90%, I think) and it's not true alpha blending, but it looks decent and
may satisfy your needs. This will be the easiest option by far, since Tk
is multiplatform and has a very powerful Canvas widget.
 
J

John Hunter

"Gabriele" == Gabriele Farina *DarkBard* <Gabriele> writes:

Gabriele> So I thought other ways: 1) using PyOpengl (tha supports
Gabriele> alpha whe drawing primitives, supports very well zooming
Gabriele> and gradient filling), but I think it is not a good
Gabriele> choice because of some problems related to videocards
Gabriele> ... 2) Use TK Canvas, but I think it does not
Gabriele> understand alpha (am I right??) .. 3) Use QT, but I
Gabriele> need a multiplatform application, and under windows QT
Gabriele> are not totally free ...

matplotlib - http://matplotlib.sf.net - has a tkagg backend. This
uses the antigrain graphics library (alpha, antialiasing, etc)
rendered on a tk canvas. So even though tk may not support alpha, all
of the alpha blending is done in the front end by matplotlib +
antigrain, and the result is transferred onto the tk canvas. This is
not mind numbingly fast, but may be fast enough for your purposes.

The src distribution (*.tar.gz or *.zip) comes with an example showing
how to embed matplotlib in a tk application; see
examples/embedding_in_tk.py.

matplotlib/tkagg has been tested under windows, linux, mac os X and
other unix platforms, and is distributed under a PSF style license.

Hope this helps,
John Hunter
 
G

Greg Ewing

Gabriele said:
tnx a lot, sorry for my cursed english ;)
^^^^^^^^^^^^^^

That's an interesting concept...

"May the khriavbog mangle my English if I lie!"

(I'm reading Jacqueline Carey's "Kushiel's Chosen"
at the moment, if anyone's wondering where that
comes from.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top