本文整理汇总了C#中ICanvas.LineTo方法的典型用法代码示例。如果您正苦于以下问题:C# ICanvas.LineTo方法的具体用法?C# ICanvas.LineTo怎么用?C# ICanvas.LineTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICanvas
的用法示例。
在下文中一共展示了ICanvas.LineTo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PaintGrouped
protected override void PaintGrouped(float cx, float cy, float endX, ICanvas canvas)
{
PaintNonGrouped(cx, cy, canvas);
var lineSpacing = LineSpacing * Scale;
var textWidth = canvas.MeasureText(_label);
var startX = cx + X + textWidth + lineSpacing;
var lineY = cy + Y + (LineTopPadding * Scale);
var lineSize = LineSize * Scale;
if (endX > startX)
{
var lineX = startX;
while (lineX < endX)
{
canvas.BeginPath();
canvas.MoveTo(lineX, (int)lineY);
canvas.LineTo(Math.Min(lineX + lineSize, endX), (int)lineY);
lineX += lineSize + lineSpacing;
canvas.Stroke();
}
canvas.BeginPath();
canvas.MoveTo(endX, (int)(lineY - LineTopOffset * Scale));
canvas.LineTo(endX, (int)(lineY + LineTopOffset * Scale));
canvas.Stroke();
}
}
示例2: 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();
}
}
}
示例3: Paint
public override void Paint(float cx, float cy, ICanvas canvas)
{
var blockWidth = 4 * Scale;
var top = cy + Y + Renderer.TopPadding;
var bottom = cy + Y + Renderer.Height - Renderer.BottomPadding;
var left = cx + X + 0.5f;
// big bar
var h = bottom - top;
canvas.FillRect(left, top, blockWidth, h);
// line
left += (blockWidth * 2) - 0.5f;
canvas.BeginPath();
canvas.MoveTo(left, top);
canvas.LineTo(left, bottom);
canvas.Stroke();
//circles
left += 3 * Scale;
var circleSize = _circleSize * Scale;
var middle = (top + bottom) / 2;
canvas.FillCircle(left, middle - (circleSize * _dotOffset), circleSize);
canvas.FillCircle(left, middle + (circleSize * _dotOffset), circleSize);
}
示例4: Paint
public override void Paint(float cx, float cy, ICanvas canvas)
{
var height = Height * Scale;
canvas.BeginPath();
if (_crescendo == CrescendoType.Crescendo)
{
canvas.MoveTo(cx + X + Width, cy + Y);
canvas.LineTo(cx + X, cy + Y + (height / 2));
canvas.LineTo(cx + X + Width, cy + Y + height);
}
else
{
canvas.MoveTo(cx + X, cy + Y);
canvas.LineTo(cx + X + Width, cy + Y + (height / 2));
canvas.LineTo(cx + X, cy + Y + height);
}
canvas.Stroke();
}
示例5: 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();
}
示例6: PaintGrouped
protected override void PaintGrouped(float cx, float cy, float endX, ICanvas canvas)
{
var startX = cx + X;
var height = Height * Scale;
canvas.BeginPath();
if (_crescendo == CrescendoType.Crescendo)
{
canvas.MoveTo(endX, cy + Y);
canvas.LineTo(startX, cy + Y + height / 2);
canvas.LineTo(endX, cy + Y + height);
}
else
{
canvas.MoveTo(cx + X, cy + Y);
canvas.LineTo(endX, cy + Y + (height / 2));
canvas.LineTo(cx + X, cy + Y + height);
}
canvas.Stroke();
}
示例7: Paint
public override void Paint(float cx, float cy, ICanvas canvas)
{
//TODO: Create webfont version
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();
}
}
}
示例8: Paint
public override void Paint(float cx, float cy, ICanvas canvas)
{
var res = Renderer.Resources;
canvas.Font = res.EffectFont;
canvas.TextAlign = TextAlign.Left;
var textWidth = canvas.MeasureText(_label);
canvas.FillText(_label, cx + X, cy + Y);
// check if we need lines
if (_isExpanded)
{
var lineSpacing = LineSpacing * Scale;
var startX = cx + X + textWidth + lineSpacing;
var endX = cx + X + Width - lineSpacing - lineSpacing;
var lineY = cy + Y + (LineTopPadding * Scale);
var lineSize = LineSize * Scale;
if (endX > startX)
{
var lineX = startX;
while (lineX < endX)
{
canvas.BeginPath();
canvas.MoveTo(lineX, (int)lineY);
canvas.LineTo(Math.Min(lineX + lineSize, endX), (int)lineY);
lineX += lineSize + lineSpacing;
canvas.Stroke();
}
canvas.BeginPath();
canvas.MoveTo(endX, (int)(lineY - LineTopOffset * Scale));
canvas.LineTo(endX, (int)(lineY + LineTopOffset * Scale));
canvas.Stroke();
}
}
}
示例9: Paint
public override void Paint(float cx, float cy, ICanvas canvas)
{
var blockWidth = 4 * Scale;
var top = cy + Y + Renderer.TopPadding;
var bottom = cy + Y + Renderer.Height - Renderer.BottomPadding;
var left = (int)(cx + X);
var h = bottom - top;
// line
canvas.BeginPath();
canvas.MoveTo(left, top);
canvas.LineTo(left, bottom);
canvas.Stroke();
if (_isLast)
{
// big bar
left += (int)((3 * Scale) + 0.5f);
canvas.FillRect(left, top, blockWidth, h);
}
}
示例10: Paint
public override void Paint(float cx, float cy, ICanvas canvas)
{
var r = (TabBarRenderer)Renderer;
var sizeX = 12 * Scale;
var sizeY = 3 * Scale;
float startX;
float startY;
float endX;
float endY;
switch (_type)
{
case SlideType.Shift:
case SlideType.Legato:
float startOffsetY;
float endOffsetY;
if (_startNote.SlideTarget == null)
{
startOffsetY = 0;
endOffsetY = 0;
}
else if (_startNote.SlideTarget.Fret > _startNote.Fret)
{
startOffsetY = sizeY;
endOffsetY = sizeY * -1;
}
else
{
startOffsetY = sizeY * -1;
endOffsetY = sizeY;
}
startX = cx + r.GetNoteX(_startNote);
startY = cy + r.GetNoteY(_startNote) + startOffsetY;
if (_startNote.SlideTarget != null)
{
endX = cx + r.GetNoteX(_startNote.SlideTarget, false);
endY = cy + r.GetNoteY(_startNote.SlideTarget) + endOffsetY;
}
else
{
endX = cx + _parent.X + _parent.PostNotes.X + _parent.PostNotes.Width;
endY = startY;
}
break;
case SlideType.IntoFromBelow:
endX = cx + r.GetNoteX(_startNote, false);
endY = cy + r.GetNoteY(_startNote);
startX = endX - sizeX;
startY = cy + r.GetNoteY(_startNote) + sizeY;
break;
case SlideType.IntoFromAbove:
endX = cx + r.GetNoteX(_startNote, false);
endY = cy + r.GetNoteY(_startNote);
startX = endX - sizeX;
startY = cy + r.GetNoteY(_startNote) - sizeY;
break;
case SlideType.OutUp:
startX = cx + r.GetNoteX(_startNote);
startY = cy + r.GetNoteY(_startNote);
endX = startX + sizeX;
endY = cy + r.GetNoteY(_startNote) - sizeY;
break;
case SlideType.OutDown:
startX = cx + r.GetNoteX(_startNote);
startY = cy + r.GetNoteY(_startNote);
endX = startX + sizeX;
endY = cy + r.GetNoteY(_startNote) + sizeY;
break;
default:
return;
}
canvas.BeginPath();
canvas.MoveTo(startX, startY);
canvas.LineTo(endX, endY);
canvas.Stroke();
}
示例11: 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();
}
}
}
示例12: PaintTupletHelper
private void PaintTupletHelper(float cx, float cy, ICanvas canvas, TupletHelper h)
{
var res = Resources;
var oldAlign = canvas.TextAlign;
canvas.TextAlign = TextAlign.Center;
// check if we need to paint simple footer
if (h.Beats.Count == 1 || !h.IsFull)
{
for (int i = 0, j = h.Beats.Count; i < j; i++)
{
var beat = h.Beats[i];
var beamingHelper = Helpers.BeamHelperLookup[h.VoiceIndex][beat.Index];
if (beamingHelper == null) continue;
var direction = beamingHelper.Direction;
var tupletX = beamingHelper.GetBeatLineX(beat) + Scale;
var tupletY = cy + Y + CalculateBeamY(beamingHelper, tupletX);
var offset = direction == BeamDirection.Up
? res.EffectFont.Size * 1.8f
: -3 * Scale;
canvas.Font = res.EffectFont;
canvas.FillText(h.Tuplet.ToString(), cx + X + tupletX, tupletY - offset);
}
}
else
{
var firstBeat = h.Beats[0];
var lastBeat = h.Beats[h.Beats.Count - 1];
var firstBeamingHelper = Helpers.BeamHelperLookup[h.VoiceIndex][firstBeat.Index];
var lastBeamingHelper = Helpers.BeamHelperLookup[h.VoiceIndex][lastBeat.Index];
if (firstBeamingHelper != null && lastBeamingHelper != null)
{
var direction = firstBeamingHelper.Direction;
//
// Calculate the overall area of the tuplet bracket
var startX = firstBeamingHelper.GetBeatLineX(firstBeat) + Scale;
var endX = lastBeamingHelper.GetBeatLineX(lastBeat) + Scale;
//
// Calculate how many space the text will need
canvas.Font = res.EffectFont;
var s = h.Tuplet.ToString();
var sw = canvas.MeasureText(s);
var sp = 3 * Scale;
//
// Calculate the offsets where to break the bracket
var middleX = (startX + endX) / 2;
var offset1X = middleX - sw / 2 - sp;
var offset2X = middleX + sw / 2 + sp;
//
// calculate the y positions for our bracket
var startY = CalculateBeamY(firstBeamingHelper, startX);
var offset1Y = CalculateBeamY(firstBeamingHelper, offset1X);
var middleY = CalculateBeamY(firstBeamingHelper, middleX);
var offset2Y = CalculateBeamY(lastBeamingHelper, offset2X);
var endY = CalculateBeamY(lastBeamingHelper, endX);
var offset = 10 * Scale;
var size = 5 * Scale;
if (direction == BeamDirection.Down)
{
offset *= -1;
size *= -1;
}
//
// draw the bracket
canvas.BeginPath();
canvas.MoveTo(cx + X + startX, (int)(cy + Y + startY - offset));
canvas.LineTo(cx + X + startX, (int)(cy + Y + startY - offset - size));
canvas.LineTo(cx + X + offset1X, (int)(cy + Y + offset1Y - offset - size));
canvas.Stroke();
canvas.BeginPath();
canvas.MoveTo(cx + X + offset2X, (int)(cy + Y + offset2Y - offset - size));
canvas.LineTo(cx + X + endX, (int)(cy + Y + endY - offset - size));
canvas.LineTo(cx + X + endX, (int)(cy + Y + endY - offset));
canvas.Stroke();
//
// Draw the string
canvas.FillText(s, cx + X + middleX, cy + Y + middleY - offset - size - res.EffectFont.Size);
}
}
canvas.TextAlign = oldAlign;
}
示例13: PaintFooter
private void PaintFooter(float cx, float cy, ICanvas canvas, BeamingHelper h)
{
var beat = h.Beats[0];
var isGrace = beat.GraceType != GraceType.None;
var scaleMod = isGrace ? NoteHeadGlyph.GraceScale : 1;
//
// draw line
//
var stemSize = GetFooterStemSize(h.ShortestDuration);
var beatLineX = h.GetBeatLineX(beat) + Scale;
var direction = h.Direction;
var topY = GetScoreY(GetNoteLine(beat.MaxNote));
var bottomY = GetScoreY(GetNoteLine(beat.MinNote));
float beamY;
float fingeringY;
if (direction == BeamDirection.Down)
{
bottomY += stemSize * scaleMod;
beamY = bottomY;
fingeringY = cy + Y + bottomY;
}
else
{
topY -= stemSize * scaleMod;
beamY = topY;
fingeringY = cy + Y + topY;
}
PaintFingering(canvas, beat, cx + X + beatLineX, direction, fingeringY);
if (beat.Duration == Duration.Whole || beat.Duration == Duration.DoubleWhole)
{
return;
}
canvas.BeginPath();
canvas.MoveTo(cx + X + beatLineX, cy + Y + topY);
canvas.LineTo(cx + X + beatLineX, cy + Y + bottomY);
canvas.Stroke();
if (isGrace)
{
var graceSizeY = 15 * Scale;
var graceSizeX = 12 * Scale;
canvas.BeginPath();
if (direction == BeamDirection.Down)
{
canvas.MoveTo(cx + X + beatLineX - (graceSizeX / 2), cy + Y + bottomY - graceSizeY);
canvas.LineTo(cx + X + beatLineX + (graceSizeX / 2), cy + Y + bottomY);
}
else
{
canvas.MoveTo(cx + X + beatLineX - (graceSizeX / 2), cy + Y + topY + graceSizeY);
canvas.LineTo(cx + X + beatLineX + (graceSizeX / 2), cy + Y + topY);
}
canvas.Stroke();
}
//
// Draw beam
//
if (beat.Duration > Duration.Quarter)
{
var glyph = new BeamGlyph(beatLineX - Scale / 2f, beamY, beat.Duration, direction, isGrace);
glyph.Renderer = this;
glyph.DoLayout();
glyph.Paint(cx + X, cy + Y, canvas);
}
}
示例14: PaintBar
private void PaintBar(float cx, float cy, ICanvas canvas, BeamingHelper h)
{
for (int i = 0, j = h.Beats.Count; i < j; i++)
{
var beat = h.Beats[i];
//
// draw line
//
var beatLineX = h.GetBeatLineX(beat) + Scale;
var direction = h.Direction;
var y1 = cy + Y + (direction == BeamDirection.Up
? GetScoreY(GetNoteLine(beat.MinNote))
: GetScoreY(GetNoteLine(beat.MaxNote)));
var y2 = cy + Y + CalculateBeamY(h, beatLineX);
canvas.BeginPath();
canvas.MoveTo(cx + X + beatLineX, y1);
canvas.LineTo(cx + X + beatLineX, y2);
canvas.Stroke();
float fingeringY = y2;
if (direction == BeamDirection.Down)
{
fingeringY += canvas.Font.Size * 2f;
}
else if (i != 0)
{
fingeringY -= canvas.Font.Size * 1.5f;
}
PaintFingering(canvas, beat, cx + X + beatLineX, direction, fingeringY);
var brokenBarOffset = 6 * Scale;
var barSpacing = 6 * Scale;
var barSize = 3 * Scale;
var barCount = beat.Duration.GetIndex() - 2;
var barStart = cy + Y;
if (direction == BeamDirection.Down)
{
barSpacing = -barSpacing;
barSize = -barSize;
}
for (var barIndex = 0; barIndex < barCount; barIndex++)
{
float barStartX;
float barEndX;
float barStartY;
float barEndY;
var barY = barStart + (barIndex * barSpacing);
//
// Bar to Next?
//
if (i < h.Beats.Count - 1)
{
// full bar?
if (IsFullBarJoin(beat, h.Beats[i + 1], barIndex))
{
barStartX = beatLineX;
barEndX = h.GetBeatLineX(h.Beats[i + 1]) + Scale;
}
// broken bar?
else if (i == 0 || !IsFullBarJoin(h.Beats[i - 1], beat, barIndex))
{
barStartX = beatLineX;
barEndX = barStartX + brokenBarOffset;
}
else
{
continue;
}
barStartY = barY + CalculateBeamY(h, barStartX);
barEndY = barY + CalculateBeamY(h, barEndX);
PaintSingleBar(canvas, cx + X + barStartX, barStartY, cx + X + barEndX, barEndY, barSize);
}
//
// Broken Bar to Previous?
//
else if (i > 0 && !IsFullBarJoin(beat, h.Beats[i - 1], barIndex))
{
barStartX = beatLineX - brokenBarOffset;
barEndX = beatLineX;
barStartY = barY + CalculateBeamY(h, barStartX);
barEndY = barY + CalculateBeamY(h, barEndX);
PaintSingleBar(canvas, cx + X + barStartX, barStartY, cx + X + barEndX, barEndY, barSize);
}
}
}
}
示例15: PaintBackground
//private static readonly Random Random = new Random();
protected override void PaintBackground(float cx, float cy, ICanvas canvas)
{
base.PaintBackground(cx, cy, canvas);
var res = Resources;
//var c = new Color((byte)Std.Random(255),
// (byte)Std.Random(255),
// (byte)Std.Random(255),
// 100);
//canvas.Color = c;
//canvas.FillRect(cx + X, cy + Y, Width, Height);
//
// draw string lines
//
canvas.Color = res.StaveLineColor;
var lineY = cy + Y + TopPadding;
for (var i = 0; i < 5; i++)
{
if (i > 0) lineY += LineOffset;
canvas.BeginPath();
canvas.MoveTo(cx + X, (int)lineY);
canvas.LineTo(cx + X + Width, (int)lineY);
canvas.Stroke();
}
canvas.Color = res.MainGlyphColor;
}