private void PaintBend(BendPoint firstPt, BendPoint secondPt, float cx, float cy, float dX, ICanvas canvas)
{
var r = (TabBarRenderer)Renderer;
var res = Renderer.Resources;
var overflowOffset = r.LineOffset / 2;
var x1 = cx + (dX * firstPt.Offset);
var y1 = cy - (_bendValueHeight * firstPt.Value);
if (firstPt.Value == 0)
{
y1 += r.GetNoteY(_note);
}
else
{
y1 += overflowOffset;
}
var x2 = cx + (dX * secondPt.Offset);
var y2 = cy - (_bendValueHeight * secondPt.Value);
if (secondPt.Value == 0)
{
y2 += r.GetNoteY(_note);
}
else
{
y2 += overflowOffset;
}
// what type of arrow? (up/down)
var arrowOffset = 0f;
var arrowSize = 6 * Scale;
if (secondPt.Value > firstPt.Value)
{
canvas.BeginPath();
canvas.MoveTo(x2, y2);
canvas.LineTo(x2 - arrowSize * 0.5f, y2 + arrowSize);
canvas.LineTo(x2 + arrowSize * 0.5f, y2 + arrowSize);
canvas.ClosePath();
canvas.Fill();
arrowOffset = arrowSize;
}
else if (secondPt.Value != firstPt.Value)
{
canvas.BeginPath();
canvas.MoveTo(x2, y2);
canvas.LineTo(x2 - arrowSize * 0.5f, y2 - arrowSize);
canvas.LineTo(x2 + arrowSize * 0.5f, y2 - arrowSize);
canvas.ClosePath();
canvas.Fill();
arrowOffset = -arrowSize;
}
canvas.Stroke();
if (firstPt.Value == secondPt.Value)
{
// draw horizontal line
canvas.MoveTo(x1, y1);
canvas.LineTo(x2, y2);
canvas.Stroke();
}
else
{
if (x2 > x1)
{
// draw bezier lien from first to second point
canvas.MoveTo(x1, y1);
canvas.BezierCurveTo(x2, y1, x2, y2 + arrowOffset, x2, y2 + arrowOffset);
canvas.Stroke();
}
else
{
canvas.MoveTo(x1, y1);
canvas.LineTo(x2, y2);
canvas.Stroke();
}
}
if (secondPt.Value != 0)
{
var dV = secondPt.Value;
var up = secondPt.Value > firstPt.Value;
dV = Math.Abs(dV);
// calculate label
var s = "";
// Full Steps
if (dV == 4 && up)
{
s = "full";
dV -= 4;
}
else if (dV >= 4)
{
int steps = dV / 4;
s += steps;
// Quaters
dV -= steps * 4;
}
if (dV > 0)
{
s += GetFractionSign(dV);
}
if (s != "")
{
if (!up)
{
s = "-" + s;
}
// draw label
canvas.Font = res.TablatureFont;
var size = canvas.MeasureText(s);
var y = up ? y2 - res.TablatureFont.Size - (2 * Scale) : y2 + (2 * Scale);
var x = x2 - size / 2;
canvas.FillText(s, x, y);
}
}
}