Open BergChristian opened 3 years ago
Thanks! Hope this lib helps you. Do you mean draw a masked bitmap? I think it is easy by making some improvements, I will take a look.
Hi, Yes
In GDI+ I can create a brush and then fill a circle with that brush to paint an image inside the circle (or really any path). Looking for something similar here.
Right now it is only a circle which I need :).
Now some APIs to support this have been added.
Direct2D uses layers to make clipping mask, for an ellipse mask, you can use the following code:
protected override void OnRender(D2DGraphics g)
{
// create an ellipse geometry, which is the clipping target region
using (var path = this.Device.CreateEllipseGeometry(ellipseOrigin, ellipseSize))
{
// push a layer to apply the clip mask
using (var layer = g.PushLayer(path))
{
// draw masked content, ---- start from here -----
g.FillRectangle(ClientRectangle, new D2DColor(.7f, .7f, .7f));
g.DrawText("Text drawed via Direct2D API (d2dlib)", D2DColor.Blue, "Arial", 24, 140, 180);
// masked content, ---- end at here ----
// finally pop the layer to exit the mask rendering
g.PopLayer();
}
}
}
There is the result:
Thanks! That is really awesome! I guess it can be used for other geometrical As well such as a rounded rectangle?
anyway. Love this lib and when and if I can contribute I will do my best!
Glad to hear that!
Yes, any path geometries are supported. You can also combine multiple paths by pushing nested layers.
Any contributions are welcome, feel free to share it!
Hi!
Great lib. Just starting to convert my controls to use this. Love it!
I am trying to draw a bitmap inside a circle. Would that be possible?
Thanks Christian