Add DrawingImage.Viewbox#18913
Conversation
|
You can test this PR using the following package version. |
…e independent pixels, to display when rendering the image
1a8db7c to
e69182d
Compare
|
You can test this PR using the following package version. |
|
Notes from the API review: rename |
|
I wasn't able to extend the feature to brushes. I can clip and translate the output, but this doesn't alter tiling. It looks like doing so would require low-level changes to the rendering system. |
|
You can test this PR using the following package version. |
This is a new property which gets or sets a rectangular region of
Drawing, in device independent pixels, to display when rendering the image.The value can be used to display only part of
Drawing, or to surround it with empty space. If null,Drawingwill provide its own frame, the same as before.What is the current behavior?
The drawing is framed with a tight bounding box defined by a union of the bounds of each component of the drawing. Expanding the frame requires adding invisible drawing elements. It's not possible to reduce the size of the frame, only to crop the rasterised output later.
What is the updated/expected behavior with this PR?
The following XAML (which is the test case of #18871, plus
Viewboxand a border) now produces the pictured output. The arc in the drawing is framed with enough space for the entire circle, because a frame starting at 0,0 has been defined.How was the solution implemented (if it's not obvious)?
At first I added the property to
GeometryGroupper the bug reports, but then I realised that if I usedDrawingGroupto add an image to the drawing, the geometry began to draw at the intended position. The problem was higher up the tree, withDrawingImageitself, which automatically crops the image to the bounds of the drawing. It still does, but now you can override those bounds and have them start and end wherever you like.I wanted to use the equivalent SVG attribute name for the property, but unfortunatelyViewBoxis already the name of an Avalonia control. I also decided against "bounds", because the frame is explicitly NOT the bounds of the drawing. That name is also already in use withVisual.Bounds, a read-only property, which could become a source of confusion.Viewboxis now used at the request of the Avalonia team.Breaking changes
None.
Obsoletions / Deprecations
None.
Fixed issues
Fixes #18871
Fixes #18512