|
From: Ethan A M. <sf...@us...> - 2013-04-18 20:46:34
|
On Thursday, April 18, 2013 12:06:59 pm Christoph Bersch wrote:
> Hi,
>
> I am working on an _arc() terminal entry and during this some questions
> about possible design/features came up:
>
> 1. The main issue is about the clipping. In the current implementation,
> the circles are always clipped at the graph boundaries.
Not quite correct.
The graphics code sets a current clip area and then calls
do_arc(), which clips to whatever area was set.
For circles the clip area is set to the graph boundaries if the center
is specified in plot ("first" or "second") coordinates or in graph
coordinates, but not if it is specified in screen coordinates.
> * The clipping of the circles must be done inside each individual
> terminal implementation (works e.g. with Postscript, cairo-related
> terminals, SVG and others).
> * I would suggest, that the information, whether clipping is necessary,
> and to which rectangle it should be clipped is provided by a
> terminal-independent function.
The current clipping area is maintained in the global structure
gadgets.h:extern BoundingBox *clip_area; /* Current clipping box */
If the clipping area is set to the entire canvas, then no clipping is
visible. Note that this is different from not doing clipping at all.
Some of the older terminals would segfault if lines were drawn off the
edge of the canvas, so clipping to the canvas boundary was important.
> * Should the circle object support a [no]clip parameter, which can
> control the clipping at the graph border?
So far I haven't seen a need for that, but maybe you have a new use
case that would want it.
> In the current implementation
> the circle object is useless for marking something around the graph
> boundary (could just be a single dot on the border).
Not really. You just have to specify the position in screen, rather
than plot, coordinates. You wouldn't normally specify the graph
boundary in plot coordinates anyhow so I don't see this as much of a
restriction. It is true that the most obvious way to position
something on the graph boundary is to use graph coordinates
set obj 1 at graph 0, graph 1
and currently the code in graphics.c would set the corresponding
clip area to the graph boundary. Perhaps it shouldn't? Or perhaps
that would be where your proposed clipping flag would come in?
> This might also be
> implemented as a new value for 'set clip' and could also affect all
> other objects.
The same clipping area and clipping primitives are used for all
objects. The clipping of filled curves is a partial exception,
since it gets very complicated to determine the correct clipping
for a filled curves whose vertices are off the edge of the canvas.
> As another thing I would suggest two distinct terminal entries _arc()
> and filledarc().
>
> I'm looking forward to your comments and suggestions,
I suggest that before investing a lot of time in this you first
dummy up a bit of terminal-specific output and compare it to the
result of the generic code in do_arc(). You might be surprised
at how much alike they look. I originally coded up a postscript
specific term->arc routine that used the PS Level 2 arc function.
But the result was not notably better than the generic function
so I abandoned the idea. That was before the cairo terminals
were added, however, so I didn't do the comparison for those.
Ethan
|