In my project i would like to do a special kind of plot in Win2D. For this i need a procedure to overwrite geometries in the bitmap with new geometries, without losing the complete information of the previous geometries. The CanvasBlend.Min function seems to be the way to go.
I tried the following code, but the min function does not work as expected. It does not compare the geometry of the bitmap with the new geometry.
using (CanvasDrawingSession ds = offscreen.CreateDrawingSession())
{
Rect myRect2 = new Rect();
myRect2.X = 0;
myRect2.Y = 0;
myRect2.Width = 400;
myRect2.Height = 500;
ds.FillRectangle(myRect2, Windows.UI.Color.FromArgb(150, 255, 255, 255));
ds.Blend = CanvasBlend.Min;
Rect myRect1 = new Rect();
myRect1.X = 0;
myRect1.Y = 0;
myRect1.Width = 500;
myRect1.Height = 200;
//this color should overwrite the color before, because it is the minimum
ds.FillRectangle(myRect1, Windows.UI.Color.FromArgb(50, 255, 255, 255));
}
Referring to the Remarks of the document, you need to set the
ClearColor
property asWhite
and set theOpacity
property as “0.5” or “1” in yourCanvasControl
(if youroffscreen
is from aCanvasControl
) to view the effect ofCanvasBlend.Min
. The default color isTransparent
inCanvasControl
.Note that
Windows.UI.Color.FromArgb(150, 255, 255, 255)
andWindows.UI.Color.FromArgb(50, 255, 255, 255)
are all white colors, you need to change them to other colors such asWindows.UI.Color.FromArgb(255, 255, 0, 0)
andWindows.UI.Color.FromArgb(255, 0, 0, 255)
. The first parameter ofWindows.UI.Color.FromArgb()
represent opacity.