本文整理汇总了C#中ICanvas.Stroke方法的典型用法代码示例。如果您正苦于以下问题:C# ICanvas.Stroke方法的具体用法?C# ICanvas.Stroke怎么用?C# ICanvas.Stroke使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ICanvas
的用法示例。
在下文中一共展示了ICanvas.Stroke方法的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 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);
}
示例3: 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();
}
示例4: Paint
public override void Paint(float cx, float cy, ICanvas canvas)
{
// TODO: Create webfont version
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();
}
}
}
示例5: 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();
}
示例6: 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();
}
}
}
示例7: 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();
}
示例8: 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();
}
示例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: 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;
}
示例11: 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);
}
}
示例12: 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);
}
}
}
}
示例13: 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;
}
示例14: Paint
public override void Paint(float cx, float cy, ICanvas canvas)
{
var r = (ScoreBarRenderer)Renderer;
var sizeX = 12 * Scale;
var offsetX = 1 * Scale;
float startX;
float startY;
float endX;
float endY;
switch (_type)
{
case SlideType.Shift:
case SlideType.Legato:
startX = cx + r.GetNoteX(_startNote) + offsetX;
startY = cy + r.GetNoteY(_startNote) + NoteHeadGlyph.NoteHeadHeight / 2;
if (_startNote.SlideTarget != null)
{
endX = cx + r.GetNoteX(_startNote.SlideTarget, false) - offsetX;
endY = cy + r.GetNoteY(_startNote.SlideTarget) + NoteHeadGlyph.NoteHeadHeight / 2;
}
else
{
endX = cx + _parent.X;
endY = startY;
}
break;
case SlideType.IntoFromBelow:
endX = cx + r.GetNoteX(_startNote, false) - offsetX;
endY = cy + r.GetNoteY(_startNote) + NoteHeadGlyph.NoteHeadHeight / 2;
startX = endX - sizeX;
startY = cy + r.GetNoteY(_startNote) + NoteHeadGlyph.NoteHeadHeight;
break;
case SlideType.IntoFromAbove:
endX = cx + r.GetNoteX(_startNote, false) - offsetX;
endY = cy + r.GetNoteY(_startNote) + NoteHeadGlyph.NoteHeadHeight / 2;
startX = endX - sizeX;
startY = cy + r.GetNoteY(_startNote);
break;
case SlideType.OutUp:
startX = cx + r.GetNoteX(_startNote) + offsetX;
startY = cy + r.GetNoteY(_startNote) + NoteHeadGlyph.NoteHeadHeight / 2;
endX = startX + sizeX;
endY = cy + r.GetNoteY(_startNote);
break;
case SlideType.OutDown:
startX = cx + r.GetNoteX(_startNote) + offsetX;
startY = cy + r.GetNoteY(_startNote) + NoteHeadGlyph.NoteHeadHeight / 2;
endX = startX + sizeX;
endY = cy + r.GetNoteY(_startNote) + NoteHeadGlyph.NoteHeadHeight;
break;
default:
return;
}
canvas.BeginPath();
canvas.MoveTo(startX, startY);
canvas.LineTo(endX, endY);
canvas.Stroke();
}
示例15: 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 != "")
//.........这里部分代码省略.........