Skip to content

Instantly share code, notes, and snippets.

@jesulink2514
Created February 28, 2019 04:08
Show Gist options
  • Save jesulink2514/1590b72862579b8fdb590f119e20feea to your computer and use it in GitHub Desktop.
Save jesulink2514/1590b72862579b8fdb590f119e20feea to your computer and use it in GitHub Desktop.
_background = new NControlView
{
DrawingFunction = (canvas, rect) =>
{
var brush = new LinearGradientBrush(
Point.Zero,
Point.OneX,
Color.FromHex("#6C6FEC").ToNColor(),
Color.FromHex("#5A41B9").ToNColor());
var curveSize = BorderRadius;
var width = rect.Width;
var height = rect.Height;
canvas.DrawPath(new PathOp[]{
new MoveTo(curveSize, 0),
// Top Right corner
new LineTo(width-curveSize, 0),
new CurveTo(
new Point(width-curveSize, 0),
new Point(width, 0),
new Point(width, curveSize)
),
new LineTo(width, height-curveSize),
// Bottom right corner
new CurveTo(
new Point(width, height-curveSize),
new Point(width, height),
new Point(width-curveSize, height)
),
new LineTo(curveSize, height),
// Bottom left corner
new CurveTo(
new Point(curveSize, height),
new Point(0, height),
new Point(0, height-curveSize)
),
new LineTo(0, curveSize),
new CurveTo(
new Point(0, curveSize),
new Point(0, 0),
new Point(curveSize, 0)
),
new ClosePath()
}, null, brush);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment