Lisp HUG Maillist Archive

Bezier curves with CAPI

Hello.

Can I draw nicely antialiased bezier curves using CAPI in a
platform-agnostic way?
If not with CAPI, then with someting else maybe. If not beziers, than some
other kind of curve.
If not in a platform agnostic way, then on osx or on windows.
But I would definitely like them antialiased.

I tried to look around, and my current understanding is that I'll have to go
with one of the gaming engines. If this is indeed the case, which one
of them in your experience plays nicely with CAPI on OS X and Windows?

Thank you for any suggestions, Denis. 


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________


Re: Bezier curves with CAPI

Bezier curves are among the easiest of cubic curves to render. You'll 
have to do it by hand, of course, but just evaluating the Bezier at 
appropriate parametric increments, and painting an anti-aliased 1x1 
brush at each point should work.

I've been doing this as aliased paths using CAPI, but translating it to 
C++ and using anti-aliased brushes should be readibly doable in CAPI, 
if a bit slow.

  - Stoney

On Apr 7, 2005, at 11:00 PM, Denis Mashkevich wrote:

> Hello.
>
> Can I draw nicely antialiased bezier curves using CAPI in a
> platform-agnostic way?
> If not with CAPI, then with someting else maybe. If not beziers, than 
> some
> other kind of curve.
> If not in a platform agnostic way, then on osx or on windows.
> But I would definitely like them antialiased.
>
> I tried to look around, and my current understanding is that I'll have 
> to go
> with one of the gaming engines. If this is indeed the case, which one
> of them in your experience plays nicely with CAPI on OS X and Windows?
>
> Thank you for any suggestions, Denis.
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email 
> ______________________________________________________________________
>


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________


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 
______________________________________________________________________


Updated at: 2020-12-10 08:53 UTC