NGraphics is a cross platform library for rendering vector graphics on .NET. It provides a unified API for both immediate and retained mode graphics using high quality native renderers.
public interface ICanvas
{
void ClipRectangle(Rect frame, Size corner);
}
public class GraphicCanvas : ICanvas
{
public void ClipRectangle(Rect frame, Size corner)
{
Graphic.Children.Add(new Rectangle(frame, corner) { Transform = CurrentTransform, });
}
}
public class FilterCanvas : ICanvas
{
public void ClipRectangle(Rect frame, Size corner)
{
NextCanvas.ClipRectangle(frame, corner);
}
}
public class AndroidPlatform : IPlatform
{
public void ClipRectangle(Rect frame, Size corner)
{
var left = (float)(frame.X);
var top = (float)(frame.Y);
var right = (float)(frame.X + frame.Width);
var bottom = (float)(frame.Y + frame.Height);
var rx = (float)corner.Width;
var ry = (float)corner.Height;
if (rx > 0 || ry > 0)
{
var path = new APath();
path.AddRoundRect(new RectF(left, top, right, bottom), rx, ry, APath.Direction.Ccw);
graphics.ClipPath(path);
}
else
{
var path = new APath();
path.AddRect(new RectF(left, top, right, bottom), APath.Direction.Ccw);
graphics.ClipPath(path);
}
}
}
public class ApplePlatform : IPlatform
{
public void ClipRectangle(Rect frame, Size corner)
{
DrawElement(() => {
context.SaveState();
if (corner.Width > 0 || corner.Height > 0)
{
var path = AddRoundedRect(Conversions.GetCGRect(frame), Conversions.GetCGSize(corner));
context.AddPath(path);
context.Clip();
}
else
{
context.AddRect(Conversions.GetCGRect(frame));
context.Clip();
}
return frame;
});
}
}
please Add 【ICanvas.ClipRectangle】
public interface ICanvas { void ClipRectangle(Rect frame, Size corner); }
public class GraphicCanvas : ICanvas { public void ClipRectangle(Rect frame, Size corner) { Graphic.Children.Add(new Rectangle(frame, corner) { Transform = CurrentTransform, }); } }
public class FilterCanvas : ICanvas { public void ClipRectangle(Rect frame, Size corner) { NextCanvas.ClipRectangle(frame, corner); } }
public class AndroidPlatform : IPlatform { public void ClipRectangle(Rect frame, Size corner) { var left = (float)(frame.X); var top = (float)(frame.Y); var right = (float)(frame.X + frame.Width); var bottom = (float)(frame.Y + frame.Height); var rx = (float)corner.Width; var ry = (float)corner.Height; if (rx > 0 || ry > 0) { var path = new APath(); path.AddRoundRect(new RectF(left, top, right, bottom), rx, ry, APath.Direction.Ccw); graphics.ClipPath(path); } else { var path = new APath(); path.AddRect(new RectF(left, top, right, bottom), APath.Direction.Ccw); graphics.ClipPath(path); } } }
public class ApplePlatform : IPlatform { public void ClipRectangle(Rect frame, Size corner) { DrawElement(() => { context.SaveState(); if (corner.Width > 0 || corner.Height > 0) { var path = AddRoundedRect(Conversions.GetCGRect(frame), Conversions.GetCGSize(corner)); context.AddPath(path); context.Clip(); } else { context.AddRect(Conversions.GetCGRect(frame)); context.Clip(); } return frame; }); } }