Unify AspectRatio, clip, and Viewport operations
Loosely quoting some relevant parts of the spec:
- All elements that establish a new viewport (
pattern) elements have attribute
viewBox. Its value is
x y width height, which define a new coordinate system inside a rectangle in the parent coordinate system.
- The rectangle in the parent coordinate system is specified by the
heightattributes, for example, in the
imageelement or in the
useelement that references a
- Positioning/scaling of the viewport is controlled by the
- Whether there's a clipping rectangle set on the x/y/width/height viewport or the viewBox is controlled by the
clipproperty, which we currently don't support (#272).
#92 is about a real bug where we don't clip
svg appropriately. I am not sure if this is just due to incorrect defaults on the
overflow property for the
symbol element, or if we are calling
draw_in_viewport() incorrectly for it.
We do the scaling/positioning of the
preserveAspectRatio value in
aspect_ratio.rs. However, we make it the caller's responsibility to:
- deal with viewbox.x and viewbox.y; that logic only deals with width and height.
- deal with a non-exixtent
- deal with clipping rectangles
It would be nice to unify all of this, including making
image.rs use the viewport logic.
viewport.rs already deals with a bunch of this stuff. It doesn't handle the special case of the
marker element; it would be nice to have it there, too. Note that
marker does not have
height attributes; instead it uses
refY for the anchor point plus a viewport size defined by
markerHeight after scaling for