Reputation: 97
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));
}
Upvotes: 0
Views: 415
Reputation: 3032
Referring to the Remarks of the document, you need to set the ClearColor
property as White
and set the Opacity
property as “0.5” or “1” in your CanvasControl
(if your offscreen
is from a CanvasControl
) to view the effect of CanvasBlend.Min
. The default color is Transparent
in CanvasControl
.
Note that Windows.UI.Color.FromArgb(150, 255, 255, 255)
and Windows.UI.Color.FromArgb(50, 255, 255, 255)
are all white colors, you need to change them to other colors such as Windows.UI.Color.FromArgb(255, 255, 0, 0)
and Windows.UI.Color.FromArgb(255, 0, 0, 255)
. The first parameter of Windows.UI.Color.FromArgb()
represent opacity.
Upvotes: 1