本文整理汇总了C#中ICanvas.ClosePath方法的典型用法代码示例。如果您正苦于以下问题:C# ICanvas.ClosePath方法的具体用法?C# ICanvas.ClosePath怎么用?C# ICanvas.ClosePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICanvas
的用法示例。
在下文中一共展示了ICanvas.ClosePath方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Paint
public override void Paint(float cx, float cy, ICanvas canvas)
{
var tabBarRenderer = (TabBarRenderer)Renderer;
var res = Renderer.Resources;
var startY = cy + X + (tabBarRenderer.GetNoteY(_beat.MaxNote) - res.TablatureFont.Size / 2);
var endY = cy + Y + tabBarRenderer.GetNoteY(_beat.MinNote) + res.TablatureFont.Size / 2;
var arrowX = (int)(cx + X + Width / 2);
var arrowSize = 8 * Scale;
if (_beat.BrushType != BrushType.None)
{
if (_beat.BrushType == BrushType.BrushUp || _beat.BrushType == BrushType.BrushDown)
{
canvas.BeginPath();
canvas.MoveTo(arrowX, startY);
canvas.LineTo(arrowX, endY);
canvas.Stroke();
}
else
{
var size = 15 * Scale;
var steps = Math.Abs(endY - startY) / size;
for (var i = 0; i < steps; i++)
{
canvas.FillMusicFontSymbol(cx + X + (3 * Scale), 1, startY + (i * size), MusicFontSymbol.WaveVertical);
}
}
if (_beat.BrushType == BrushType.BrushUp || _beat.BrushType == BrushType.ArpeggioUp)
{
canvas.BeginPath();
canvas.MoveTo(arrowX, endY);
canvas.LineTo(arrowX + arrowSize / 2, endY - arrowSize);
canvas.LineTo(arrowX - arrowSize / 2, endY - arrowSize);
canvas.ClosePath();
canvas.Fill();
}
else
{
canvas.BeginPath();
canvas.MoveTo(arrowX, startY);
canvas.LineTo(arrowX + arrowSize / 2, startY + arrowSize);
canvas.LineTo(arrowX - arrowSize / 2, startY + arrowSize);
canvas.ClosePath();
canvas.Fill();
}
}
}
示例2: Paint
public override void Paint(float cx, float cy, ICanvas canvas)
{
var scoreBarRenderer = (ScoreBarRenderer)Renderer;
var lineSize = scoreBarRenderer.LineOffset;
var startY = cy + Y + (scoreBarRenderer.GetNoteY(_beat.MaxNote) - lineSize / 2);
var endY = cy + Y + scoreBarRenderer.GetNoteY(_beat.MinNote) + lineSize;
var arrowX = cx + X + Width / 2;
var arrowSize = 8 * Scale;
if (_beat.BrushType != BrushType.None)
{
if (_beat.BrushType == BrushType.ArpeggioUp || _beat.BrushType == BrushType.ArpeggioDown)
{
var size = 15 * Scale;
var steps = Math.Abs(endY - startY) / size;
for (var i = 0; i < steps; i++)
{
canvas.FillMusicFontSymbol(cx + X + (3 * Scale), 1, startY + (i * size), MusicFontSymbol.WaveVertical);
}
}
if (_beat.BrushType == BrushType.ArpeggioUp)
{
canvas.BeginPath();
canvas.MoveTo(arrowX, endY);
canvas.LineTo(arrowX + arrowSize / 2, endY - arrowSize);
canvas.LineTo(arrowX - arrowSize / 2, endY - arrowSize);
canvas.ClosePath();
canvas.Fill();
}
else if (_beat.BrushType == BrushType.ArpeggioDown)
{
canvas.BeginPath();
canvas.MoveTo(arrowX, startY);
canvas.LineTo(arrowX + arrowSize / 2, startY + arrowSize);
canvas.LineTo(arrowX - arrowSize / 2, startY + arrowSize);
canvas.ClosePath();
canvas.Fill();
}
}
}
示例3: Paint
public void Paint(float cx, float cy, ICanvas canvas)
{
for (int i = 0, j = _allStaves.Count; i < j; i++)
{
_allStaves[i].Paint(cx + X, cy + Y, canvas);
}
var res = Layout.Renderer.RenderingResources;
if (Staves.Count > 0)
{
//
// Draw start grouping
//
if (_firstStaveInAccolade != null && _lastStaveInAccolade != null)
{
//
// draw grouping line for all staves
//
var firstStart = cy + Y + _firstStaveInAccolade.Y + _firstStaveInAccolade.StaveTop + _firstStaveInAccolade.TopSpacing + _firstStaveInAccolade.TopOverflow;
var lastEnd = cy + Y + _lastStaveInAccolade.Y + _lastStaveInAccolade.TopSpacing + _lastStaveInAccolade.TopOverflow
+ _lastStaveInAccolade.StaveBottom;
var acooladeX = cx + X + _firstStaveInAccolade.X;
canvas.Color = res.BarSeperatorColor;
canvas.BeginPath();
canvas.MoveTo(acooladeX, firstStart);
canvas.LineTo(acooladeX, lastEnd);
canvas.Stroke();
}
//
// Draw accolade for each track group
//
canvas.Font = res.EffectFont;
for (int i = 0, j = Staves.Count; i < j; i++)
{
var g = Staves[i];
var firstStart = cy + Y + g.FirstStaveInAccolade.Y + g.FirstStaveInAccolade.StaveTop + g.FirstStaveInAccolade.TopSpacing + g.FirstStaveInAccolade.TopOverflow;
var lastEnd = cy + Y + g.LastStaveInAccolade.Y + g.LastStaveInAccolade.TopSpacing + g.LastStaveInAccolade.TopOverflow
+ g.LastStaveInAccolade.StaveBottom;
var acooladeX = cx + X + g.FirstStaveInAccolade.X;
var barSize = (3 * Layout.Renderer.Settings.Scale);
var barOffset = barSize;
var accoladeStart = firstStart - (barSize * 4);
var accoladeEnd = lastEnd + (barSize * 4);
// text
if (Index == 0)
{
canvas.FillText(g.Track.ShortName, cx + X + (AccoladeLabelSpacing * Layout.Scale), firstStart);
}
// rect
canvas.FillRect(acooladeX - barOffset - barSize, accoladeStart, barSize, accoladeEnd - accoladeStart);
var spikeStartX = acooladeX - barOffset - barSize;
var spikeEndX = acooladeX + barSize * 2;
// top spike
canvas.BeginPath();
canvas.MoveTo(spikeStartX, accoladeStart);
canvas.BezierCurveTo(spikeStartX, accoladeStart, spikeStartX, accoladeStart, spikeEndX, accoladeStart - barSize);
canvas.BezierCurveTo(acooladeX, accoladeStart + barSize, spikeStartX, accoladeStart + barSize, spikeStartX, accoladeStart + barSize);
canvas.ClosePath();
canvas.Fill();
// bottom spike
canvas.BeginPath();
canvas.MoveTo(spikeStartX, accoladeEnd);
canvas.BezierCurveTo(spikeStartX, accoladeEnd, acooladeX, accoladeEnd, spikeEndX, accoladeEnd + barSize);
canvas.BezierCurveTo(acooladeX, accoladeEnd - barSize, spikeStartX, accoladeEnd - barSize, spikeStartX, accoladeEnd - barSize);
canvas.ClosePath();
canvas.Fill();
}
}
}
示例4: PaintSingleBar
private static void PaintSingleBar(ICanvas canvas, float x1, float y1, float x2, float y2, float size)
{
canvas.BeginPath();
canvas.MoveTo(x1, y1);
canvas.LineTo(x2, y2);
canvas.LineTo(x2, y2 + size);
canvas.LineTo(x1, y1 + size);
canvas.ClosePath();
canvas.Fill();
}
示例5: 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();
}
示例6: Paint
public override void Paint(float cx, float cy, ICanvas canvas)
{
var r = (TabBarRenderer)Renderer;
var res = Renderer.Resources;
// calculate offsets per step
var dX = Width / BendPoint.MaxPosition;
var maxValue = 0;
for (int i = 0, j = _note.BendPoints.Count; i < j; i++)
{
if (_note.BendPoints[i].Value > maxValue)
{
maxValue = _note.BendPoints[i].Value;
}
}
var dY = maxValue == 0 ? 0 : _height / maxValue;
var xx = cx + X;
var yy = cy + Y + r.GetNoteY(_note);
canvas.BeginPath();
for (int i = 0, j = _note.BendPoints.Count - 1; i < j; i++)
{
var firstPt = _note.BendPoints[i];
var secondPt = _note.BendPoints[i + 1];
// don't draw a line if there's no offset and it's the last point
if (firstPt.Value == secondPt.Value && i == _note.BendPoints.Count - 2) continue;
var x1 = xx + (dX * firstPt.Offset);
var y1 = yy - (dY * firstPt.Value);
var x2 = xx + (dX * secondPt.Offset);
var y2 = yy - (dY * secondPt.Value);
if (firstPt.Value == secondPt.Value)
{
// draw horizontal line
canvas.MoveTo(x1, y1);
canvas.LineTo(x2, y2);
canvas.Stroke();
}
else
{
// draw bezier lien from first to second point
var hx = x1 + (x2 - x1);
var hy = yy - (dY * firstPt.Value);
canvas.MoveTo(x1, y1);
canvas.BezierCurveTo(hx, hy, x2, y2, x2, y2);
canvas.Stroke();
}
// what type of arrow? (up/down)
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();
}
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();
}
canvas.Stroke();
if (secondPt.Value != 0)
{
var dV = (secondPt.Value - firstPt.Value);
var up = dV > 0;
dV = Math.Abs(dV);
// calculate label
var s = "";
// Full Steps
if (dV == 4)
{
s = "full";
dV -= 4;
}
else if (dV > 4)
{
s += dV / 4 + " ";
// Quaters
dV -= dV / 4;
}
if (dV > 0)
{
s += dV + "/4";
}
if (s != "")
//.........这里部分代码省略.........
示例7: PaintBend
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)
//.........这里部分代码省略.........