本文整理汇总了C#中ICanvas.QuadraticCurveTo方法的典型用法代码示例。如果您正苦于以下问题:C# ICanvas.QuadraticCurveTo方法的具体用法?C# ICanvas.QuadraticCurveTo怎么用?C# ICanvas.QuadraticCurveTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICanvas
的用法示例。
在下文中一共展示了ICanvas.QuadraticCurveTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Paint
public override void Paint(float cx, float cy, ICanvas canvas)
{
var size = 6 * Scale;
canvas.BeginPath();
canvas.MoveTo(cx + X, cy + Y);
canvas.QuadraticCurveTo(cx + X + (Width / 2), cy + Y, cx + X + Width, cy + Y - size);
canvas.MoveTo(cx + X, cy + Y);
canvas.QuadraticCurveTo(cx + X + (Width / 2), cy + Y, cx + X + Width, cy + Y + size);
canvas.Stroke();
}
示例2: Paint
public override void Paint(float cx, float cy, ICanvas canvas)
{
var size = 6 * Scale;
var width = Math.Max(Width, 14*Scale);
var offset = Renderer.Height/2;
canvas.BeginPath();
canvas.MoveTo(cx + X, cy + Y + offset);
canvas.QuadraticCurveTo(cx + X + (width / 2), cy + Y + offset, cx + X + width, cy + Y + offset - size);
canvas.MoveTo(cx + X, cy + Y + offset);
canvas.QuadraticCurveTo(cx + X + (width / 2), cy + Y + offset, cx + X + width, cy + Y + offset + size);
canvas.Stroke();
}
示例3: PaintTie
/// <summary>
/// paints a tie between the two given points
/// </summary>
/// <param name="canvas"></param>
/// <param name="scale"></param>
/// <param name="x1"></param>
/// <param name="y1"></param>
/// <param name="x2"></param>
/// <param name="y2"></param>
/// <param name="down"></param>
public static void PaintTie(ICanvas canvas, float scale, float x1, float y1, float x2, float y2,
bool down = false)
{
// ensure endX > startX
if (x2 > x1)
{
var t = x1;
x1 = x2;
x2 = t;
t = y1;
y1 = y2;
y2 = t;
}
//
// calculate control points
//
var offset = 15 * scale;
var size = 4 * scale;
// normal vector
var normalVectorX = (y2 - y1);
var normalVectorY = (x2 - x1);
var length = (float)Math.Sqrt((normalVectorX * normalVectorX) + (normalVectorY * normalVectorY));
if (down)
normalVectorX *= -1;
else
normalVectorY *= -1;
// make to unit vector
normalVectorX /= length;
normalVectorY /= length;
// center of connection
var centerX = (x2 + x1) / 2;
var centerY = (y2 + y1) / 2;
// control points
var cp1X = centerX + (offset * normalVectorX);
var cp1Y = centerY + (offset * normalVectorY);
var cp2X = centerX + ((offset - size) * normalVectorX);
var cp2Y = centerY + ((offset - size) * normalVectorY);
canvas.BeginPath();
canvas.MoveTo(x1, y1);
canvas.QuadraticCurveTo(cp1X, cp1Y, x2, y2);
canvas.QuadraticCurveTo(cp2X, cp2Y, x1, y1);
canvas.ClosePath();
}