Re: Bezier curves with CAPI
On April 7, 2005 11:00 pm, Denis Mashkevich wrote:
> Can I draw nicely antialiased bezier curves using CAPI in a
> platform-agnostic way?
I was faced with a problem similar to yours, but not exactly what you want (I
think). (You can have my code, if it helps).
I needed 2-D parabolic splines.
I found code for the solution inside the Tcl/Tk package. (It included
Beziers, that's what triggered this response).
Instead of trying to use FLI to link to the Tk code with unknown dependencies,
I tried an experiment.
I simply transcribed the Tk C code for splines and beziers into Lisp. Warts
and all.
It took less than 20 minutes to manually convert the code to Lisp. I have
deep knowledge of C and pretty-good knowledge of Lisp. The faster you can
type, the faster this process goes.
After an hour or two of "debugging" - finding missing dependencies and
converting the extra code to Lisp - finding typos - it worked.
Since then, I found one more bug (caused by my own misunderstanding and my
C-based penchant for premature optimization).
I keep meaning to go back and "optimize" the code (i.e. convert it to the Lisp
paradigm and play with the optimization options). But so far, all profiling
measurements do not point to the Spline / Bezier code as being any sort of
significant bottle-neck. I have better things to do. Maybe some other time.
Morals:
(1) Steal architecture. (aka high-level algorithms).
(2) Steal engineering. (aka data structures, low-level algorithms).
(3) Often, stealing actual code (libraries, FLI, classes) is a near-worthless
activity. If it's going to cost more than 2 days to begin using a library
(often the case), it is probably cheaper to learn how to touch-type and then
re-do the whole mess. In the process, you learn - intimately - how the
transliterated code is supposed to work, which cuts down your debugging time
massively and gives you control that you would not, otherwise, have.
pt
______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________