Re: Drawing complex vector shapes
Re: Drawing complex vector shapes
- Subject: Re: Drawing complex vector shapes
- From: Public Look <email@hidden>
- Date: Mon, 1 Dec 2003 17:16:12 -0500
On Dec 1, 2003, at 3:05 PM, Matt Budd wrote:
>
Hi..
>
>
We're creating a vector drawing program, but we want to able to do
>
some pretty cool stuff with the vector paths (like gradients,
>
transparent fills, outlines, shadows). We got a prototype with the
>
complex drawing of all these shapes (using NSBezierPaths), but I was
>
wondering if anyone had information on the best way to do the specific
>
effects we're confronting right now:
>
>
Gradients: Seems like CGShading has what I need, but can I use this
>
to fill a NSBezierPath, or just a rect? The web doesn't have much in
>
the way of sample code, so if anyone can point me in the right
>
direction (or some sample code), that'd be great...
You can clip all drawing to any path. Once your path is constructed,
save the current context, add the path to the current clipping path,
draw your gradient, and restore the graphics context. See the path
documentation about clipping.
>
Shadowing: Seems like an iterative repeating of the outline with a
>
shift of each iteration down and to the right and reduce it's opacity.
>
However, this would mean that for each shape, I'd fill it once, but
>
stroke it 6 times...inherent performance hit?
Repeating the outline is not the way to go. It wont print very well at
600 dpi. One way to draw a shadow is to translate the coordinate
system, fill you path with a transparent color, and then un-translate
and draw your path as normal.
>
Also, we're looking at possibly using cross-platform Qt
>
(http://www.trolltech.com) with OpenGL for the graphics (Qt's internal
>
graphic stuff is quite lacking). I was wondering if anyone had gone
>
down the route of using OpenGL for its 2D drawing effects, and if they
>
thought that was comparable to Cocoa/Quartz graphics (which I think
>
look amazing for the amount of code you have to write).
>
OpenGL is a cross platform standard API for accessing "high"
performance graphics hardware. It is not device independent, and
almost all implementations are optimized for (and limited to) low
resolution output devices tike the frame buffer in a graphics card. In
contrast, Quartz contains a proprietary single-platform 2D API for
"high" quality device independent output using the cross platform
PDF/Postscript imaging model suitable for output to low resolution
devices such as graphics card frame buffers as well as high resolution
devices such as printing presses or direct to film applications.
OpenGL Quartz2D
open yes no
cross-platform yes no
interactive performance high low
device independent no yes
quality of output low high
supports 3D yes no
Supports full set of
2D vector operations no yes
Supports advanced font
technology no yes
Supports printing color
models (CMYK) no yes
Supports full set of 3D
operations (lighting, etc.) yes no
antialiasing some yes
The API you select should be based on the intended uses for your
application. Are you more interested in interactive performance or
high quality printing ? Are you more interested in high quality output
with advanced font technology or are you more interested in
cross-platform support ? Do you plan to use affine transforms, complex
clipping paths, outline fonts, and standard units such as inches,
centimeters, or kilometers ? Do you plan to use lighting, bump
mapping, stencil buffers, 3D, arbitrary units such as pixels, or
interactive animation ?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.