From: Kevin A. <al...@se...> - 2001-09-13 19:40:36
|
I needed to get away from the television for a while last night, so I started work on a BitmapDrawing widget for PythonCard. I stayed away from the news coverage this morning as well to make a sample and put together this rambling email. I still feel completely drained by the horrific attacks on Tuesday, so I'm not getting much work done. The first revision which is checked into cvs doesn't do much. It uses an offscreen bitmap, supports setting the foregroundColor and backgroundColor, plot(x, y), line(x1, y1, x2, y2), clear(), refresh(), autoRefresh attribute (1 or 0), and drawText(aString, x, y); drawText uses the default font. All the drawing and updating is brute force, it is unclear at this point what optimizations can be made to speed up some operations. The resourceEditor, Property Editor, and other parts of the framework don't fully support the new widget. One nice aspect of the widget is that it supports all the mouse events just like the other PythonCard widgets. The doodle sample shows off just some of these. There are two samples, doodle and hopalong. Doodle just draws a pixel in the current pen color while the mouse is down. Hopalong draws a mathematical function on the screen based on the input values which can be set with the fields at the top of the window. The drawing time is dramatically slower when autoRefresh is true (roughly 3 - 4 times slower on my machine) and even with autoRefresh off it can take 3.4 seconds on my AMD 1.2GHz machine to draw 100,000 points. There is no way to cancel a drawing operation once it is started (that is a later experiment), so be patient when drawing a large number of points. The designs are often more interesting at the million points or higher range. This is the same hopalong function used in one of the turtle scripts. The BitmapDrawing widget is experimental as are any samples that use it and will likely change often for the next month or so; at this point I don't even have a fixed set of design goals for the widget. I just wanted to get something concrete into the framework to work with and help us generate ideas. I would like to strike a balance between ease of use, flexibility, and speed. The current widget can be placed behind or overlapping any other widgets, thus we can use a BitmapDrawing widget as our bitmap layer in PythonCard probably with more flexibility than the bitmap drawing tools in HyperCard. A separate tool will have to be provided to handle the user interface manipulation of the widget bitmap contents like selection, zooming, area fill, etc. I will convert the turtle sample to use the widget sometime in the next month; eventually the turtle will just be part of the basic PythonCard framework. The BitmapDrawing widget is distinct from an object canvas where you can select individual rectangles, lines, text, etc. and I expect that to be a separate widget. Another library which people might want to look at is PIDDLE http://piddle.sourceforge.net/ There is nothing that would prevent doing drawing in PIDDLE and then placing the resulting bitmap into a BitmapDrawing widget. If we want a unified drawing model that gives us the best capabilities of PIDDLE and the underlying device contexts of wxPython/wxWindows so that printing, drawing in PostScript, etc. are roughly the same, that will need to be taken into account for the BitmapDrawing widget. One obvious problem I see with most of the current widgets is a lack of transparency, which limits what we can do with overlapping widgets and definitely limits the tricks that could be done with layering BitmapDrawings. This might be a fundamental limitation of wxPython/wxWindows. I would like to support the Python Imaging Library, but am not sure whether to wrap any of it or just leave its existing API exposed. Anyway, please share your thoughts and ideas on what you would like to see for bitmap graphics in PythonCard. You can start separate threads rather than replying to this email if you want. ka |