On Tuesday 03 December 2002 8:05 pm, Carl Worth wrote:
[...]
|
|  As always, feedback is welcome and encouraged.
|
|  -Carl
|
|  PS. Oh, and how about a convenience function for rectangles? I think
|  XrRectangle should add a rectangle to the path, (convenience function
|  for a MoveTo and four LineTo's). 

Going from LineTo to Rectangle is not that easy.
You should take care about junction of those lines.

Besides, you should take into consideration dashed lines (with specified dash 
pattern) and rectangles (beziers, arcs) with such dashed lines...

I attached couple of simplified examples illustrating this problem
(there are also few nice examples Dom committed to librsvg2 source tree)
Compare rendeirng of those files with different renderers (ImageMagick, KSVG, 
librsvg2, Adobe SVG viewer), and you will see that implementing *rectangle* 
is quite difficult task.

| I don't see the need now to implement
|  functions like PostScript's rectstroke/rectfill, (any such
|  optimization functions can be added later if necessary). I'm inclined
|  not to add rounded rectangle support.

I am not sure what do you mean under "rounded rectangle support".
Does rectangle with rounded/ (not *round*) corners, like in attached example, 
fall into this category?  All examples are valid SVG files, so support for 
drawing primitives like this is really necessary for SVG compliance.

|
|  [*] For any inclined to more reading, here's the results of my review
|  of arc support in graphics systems:
|
|  From surveying several 2D graphics systems it seems there are two
|  major means of specifying arcs:
|
|  Center Parameterization
|  -----------------------
|  Accepts center point, radius, and two angular extents.
|  This parameterization has a two-way ambiguity (depending on which
|  direction the arc is drawn).
|
|  Endpoint Parameterization
|  -------------------------
|  Accept initial and final arc endpoints.
|  This parameterization has a four-way ambiguity.
|
|  Here are what several graphics systems provide and how the ambiguities
|  are handled:
|
|  PDF
|  ---
|  No arc support.
|
|  Core X11 arcs
|  --------------
|  Center parameterization. Ambiguity resolved by the sign of the angles,
|  (I don't know what happens if the sign of the two angles differs).
|
|  Java 2D
|  -------
|  Center parameterization. I couldn't find a reference explaining how
|  the ambiguity is resolved, (perhaps arcs are always drawn in the
|  positive direction?).
|
|  SVG
|  ---
|  Endpoint parameterization. Ambiguity resolved with two flags,
|  (large arc flag and sweep flag).
|
|  PostScript
|  ----------
|  Center parameterization. Ambiguity resolved with two different
|  operators, arc and arcn (arc negative).
|
|  Note: If current point is defined, also draws line from current point
|  to initial arc endpoint.
|
|  PostScript also provides another more specialized arc function:
|
|       arct (point_1, point_2, radius)
|
|       arcto (point_1, point_2, radius)
|
|  arct specifies a circular arc that fits within and tangent to a
|  polygon formed by the current point, point_1, and point_2. This is
|  quite similar to the way that splines are specified. An important
|  difference is that the endpoints of the arc are not provided as
|  explicit arguments, but are implicit given the tangents and the
|  radius. For this reason, the arcto flavor is also provided. It
|  constructs the same arc as arct, but it also returns the two endpoints
|  of the arc.
|
|  arct cannot be used as a general arc function since it will not draw
|  arcs with extents greater than 180 degrees, (so it can't be used to
|  draw a complete circle). But, this is a very handy operator for doing
|  things such as rounded corners on rectangles.
|
|  Conclusions
|  -----------
|  Center parameterization is clearly more popular than endpoint
|  parameterization. I also prefer it since I dislike APIs that involve
|  lots of boolean flags.
|
|  Postscript uses my preferred mechanism for resolving an ambiguity,
|  which is to provide distinct operators with distinct behavior rather
|  than passing a flag. However, I do prefer more descriptive names.

-- 

Vadim Plessky
SVG Icons * BlueSphere Icons 0.3.0 released
http://svgicons.sourceforge.net
My KDE page
http://kde2.newmail.ru  (English)
KDE mini-Themes
http://kde2.newmail.ru/themes/

<<attachment: rectangles-lineJoin.svg>>

<<attachment: rectangle-dashes.svg>>

<<attachment: rectangle-dashes-3.svg>>

Reply via email to