public GetBeatLineX ( |
||
beat | ||
return | float |
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); } }
private void PaintFooter(float cx, float cy, ICanvas canvas, BeamingHelper h) { var beat = h.Beats[0]; if (beat.Duration == Duration.Whole || beat.Duration == Duration.DoubleWhole) { return; } // // draw line // var beatLineX = h.GetBeatLineX(beat) + Scale; const float topY = 0; var bottomY = Height; float beamY = _direction == BeamDirection.Down ? bottomY : topY; canvas.BeginPath(); canvas.MoveTo(cx + X + beatLineX, cy + Y + topY); canvas.LineTo(cx + X + beatLineX, cy + Y + bottomY); canvas.Stroke(); // // Draw beam // var glyph = new BeamGlyph(beatLineX, beamY, beat.Duration, _direction, false); glyph.Renderer = this; glyph.DoLayout(); glyph.Paint(cx + X, cy + Y, canvas); }
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); } } } }
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]; if (h.HasBeatLineX(beat)) { // // draw line // var beatLineX = h.GetBeatLineX(beat) + Scale; var y1 = cy + Y; var y2 = cy + Y + Height; canvas.BeginPath(); canvas.MoveTo(cx + X + beatLineX, y1); canvas.LineTo(cx + X + beatLineX, y2); canvas.Stroke(); 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; barStart += Height; } for (int barIndex = 0; barIndex < barCount; barIndex++) { float barStartX; float barEndX; float barStartY; float barEndY; var barY = barStart + (barIndex * barSpacing); // // Broken Bar to Next // if (h.Beats.Count == 1) { barStartX = beatLineX; barEndX = beatLineX + brokenBarOffset; barStartY = barY; barEndY = barY; PaintSingleBar(canvas, cx + X + barStartX, barStartY, cx + X + barEndX, barEndY, barSize); } // // Bar to Next? // else 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; barEndY = barY; 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; barEndY = barY; PaintSingleBar(canvas, cx + X + barStartX, barStartY, cx + X + barEndX, barEndY, barSize); } } } } }