Hi Cameron,
The way I would implement background-fill
would be in the various renderers. The JSVGCanvas
already has a method to set the background color
(Through swing's setBackground() method). The
transcoders have 'KEY_BACKGROUND_COLOR' which
could use the background from the outermost
SVG element. So I would modify these to look for
the property or get the 'backgroundColor' value from
the RootGraphicsNode and use it when another default
has not been given.
Otherwise, you are correct that there is no real
way to have this work given the infinite canvas
(you can do some things like check the clip on
the Graphics2D and fill that region, but AFAIK
there is no requirement that there be a clip, so
what do you fill in that case? ;)
Cameron McCormack wrote:
Hi Thomas.
I want to implement the 'background-fill' and 'background-fill-opacity'
1.2 properties. I've got it working nicely for the case when the svg
element it applies to has overflow="hidden", but the overflow="visible"
case is causing me problems.
I've modified the CanvasGraphicsNode's getPrimitiveBounds and
primitivePaint methods to handle filling the created viewport with the
background colour. When overflow="visible", though, the area to fill is
effectively infinite (subject to clipping). I've tried two ways to
handle it:
1. Have getPrimitiveBounds return an infinite area, with
new Rectangle2D.Float
(Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY,
Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY))
but this seems to cause problems with some calculations in the
renderer. I guess this would also be problematic if the node was
being rendered into an offscreen buffer first?
2. Have primitivePaint get the dimensions of the Graphics2D it is
painting to, transform that to the current coordinate system and
then fill that rectangle. This would be good, but
getPrimitiveBounds doesn't have access to a Graphics2D (I suppose
since it is meant to have some intrinsic dimensions irrespective of
where it will be drawn to).
And another one I've though of but haven't tried yet:
3. Have the SVGSVGElementBridge look up the current dimensions of the
root svg element and its viewing transform to compute the box that
will cover the whole viewable canvas. However, then the CGN would
have to be updated/recreated whenever the canvas is panned.
Any other thoughts on how to achieve this?
Thanks,
Cameron
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]