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); 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) { var lineStartY = startY - arrowSize; var lineEndY = endY - arrowSize; canvas.BeginRotate(cx + X + 2 * Scale, lineEndY, -90); var glyph = new NoteVibratoGlyph(0, 0, VibratoType.Slight); glyph.Renderer = Renderer; glyph.DoLayout(); glyph.Width = Math.Abs(lineEndY - lineStartY); glyph.Paint(0, 0, canvas); canvas.EndRotate(); 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) { var lineStartY = startY + arrowSize; var lineEndY = endY + arrowSize; canvas.BeginRotate(cx + X + 7 * Scale, lineStartY, 90); var glyph = new NoteVibratoGlyph(0, 0, VibratoType.Slight); glyph.Renderer = Renderer; glyph.DoLayout(); glyph.Width = Math.Abs(lineEndY - lineStartY); glyph.Paint(0, 0, canvas); canvas.EndRotate(); canvas.BeginPath(); canvas.MoveTo(arrowX, startY); canvas.LineTo(arrowX + arrowSize / 2, startY + arrowSize); canvas.LineTo(arrowX - arrowSize / 2, startY + arrowSize); canvas.ClosePath(); canvas.Fill(); } } }
public override void Paint(float cx, float cy, ICanvas canvas) { var startNoteRenderer = (ScoreBarRenderer)Renderer; var sizeX = 12 * Scale; var offsetX = 1 * Scale; float startX; float startY; float endX; float endY; bool waves = false; switch (_type) { case SlideType.Shift: case SlideType.Legato: startX = cx + startNoteRenderer.X + startNoteRenderer.GetBeatX(_startNote.Beat, BeatXPosition.PostNotes) + offsetX; var isUp = _startNote.SlideTarget.RealValue > _startNote.RealValue; startY = cy + startNoteRenderer.Y + startNoteRenderer.GetNoteY(_startNote); var lineOffset = 0.25f * NoteHeadGlyph.NoteHeadHeight * Scale; if (isUp) { startY += lineOffset; } else { startY -= lineOffset; } if (_startNote.SlideTarget != null) { var endNoteRenderer = Renderer.ScoreRenderer.Layout.GetRendererForBar <BarRendererBase>(Renderer.Staff.StaveId, _startNote.SlideTarget.Beat.Voice.Bar); if (endNoteRenderer == null || endNoteRenderer.Staff != startNoteRenderer.Staff) { endX = cx + startNoteRenderer.X + _parent.X; endY = startY; } else { endX = cx + endNoteRenderer.X + endNoteRenderer.GetBeatX(_startNote.SlideTarget.Beat, BeatXPosition.PreNotes) - offsetX; endY = cy + endNoteRenderer.Y + endNoteRenderer.GetNoteY(_startNote.SlideTarget); if (isUp) { endY -= lineOffset; } else { endY += lineOffset; } } } else { endX = cx + startNoteRenderer.X + _parent.X; endY = startY; } break; case SlideType.IntoFromBelow: endX = cx + startNoteRenderer.X + startNoteRenderer.GetNoteX(_startNote, false) - offsetX; endY = cy + startNoteRenderer.Y + startNoteRenderer.GetNoteY(_startNote) + NoteHeadGlyph.NoteHeadHeight / 2; startX = endX - sizeX; startY = cy + startNoteRenderer.Y + startNoteRenderer.GetNoteY(_startNote) + NoteHeadGlyph.NoteHeadHeight; break; case SlideType.IntoFromAbove: endX = cx + startNoteRenderer.X + startNoteRenderer.GetNoteX(_startNote, false) - offsetX; endY = cy + startNoteRenderer.Y + startNoteRenderer.GetNoteY(_startNote) + NoteHeadGlyph.NoteHeadHeight / 2; startX = endX - sizeX; startY = cy + startNoteRenderer.Y + startNoteRenderer.GetNoteY(_startNote); break; case SlideType.OutUp: startX = cx + startNoteRenderer.X + startNoteRenderer.GetNoteX(_startNote) + offsetX; startY = cy + startNoteRenderer.Y + startNoteRenderer.GetNoteY(_startNote) + NoteHeadGlyph.NoteHeadHeight / 2; endX = startX + sizeX; endY = cy + startNoteRenderer.Y + startNoteRenderer.GetNoteY(_startNote); break; case SlideType.OutDown: startX = cx + startNoteRenderer.X + startNoteRenderer.GetNoteX(_startNote) + offsetX; startY = cy + startNoteRenderer.Y + startNoteRenderer.GetNoteY(_startNote) + NoteHeadGlyph.NoteHeadHeight / 2; endX = startX + sizeX; endY = cy + startNoteRenderer.Y + startNoteRenderer.GetNoteY(_startNote) + NoteHeadGlyph.NoteHeadHeight; break; case SlideType.PickSlideUp: startX = cx + startNoteRenderer.X + startNoteRenderer.GetNoteX(_startNote); startY = cy + startNoteRenderer.Y + startNoteRenderer.GetNoteY(_startNote) + NoteHeadGlyph.NoteHeadHeight / 2; endX = cx + startNoteRenderer.X + startNoteRenderer.GetBeatX(_startNote.Beat, BeatXPosition.EndBeat); endY = cy + startNoteRenderer.Y + startNoteRenderer.GetNoteY(_startNote) - NoteHeadGlyph.NoteHeadHeight; waves = true; break; case SlideType.PickSlideDown: startX = cx + startNoteRenderer.X + startNoteRenderer.GetNoteX(_startNote); startY = cy + startNoteRenderer.Y + startNoteRenderer.GetNoteY(_startNote) - NoteHeadGlyph.NoteHeadHeight / 2; endX = cx + startNoteRenderer.X + startNoteRenderer.GetBeatX(_startNote.Beat, BeatXPosition.EndBeat); endY = cy + startNoteRenderer.Y + startNoteRenderer.GetNoteY(_startNote) + NoteHeadGlyph.NoteHeadHeight; waves = true; break; default: return; } if (waves) { var b = endX - startX; var a = endY - startY; var c = Math.Sqrt(Math.Pow(a, 2) + Math.Pow(b, 2)); var angle = (float)(Math.Asin(a / c) * (180 / Math.PI)); canvas.BeginRotate(startX, startY, angle); var glyph = new NoteVibratoGlyph(0, 0, VibratoType.Slight); glyph.Renderer = Renderer; glyph.DoLayout(); glyph.Width = b; glyph.Paint(0, 0, canvas); canvas.EndRotate(); } else { canvas.BeginPath(); canvas.MoveTo(startX, startY); canvas.LineTo(endX, endY); canvas.Stroke(); } }
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 if (_beat.BrushType == BrushType.ArpeggioUp) { var lineStartY = startY - arrowSize; var lineEndY = endY - arrowSize; canvas.BeginRotate(cx + X + 2 * Scale, lineEndY, -90); var glyph = new NoteVibratoGlyph(0, 0, VibratoType.Slight); glyph.Renderer = Renderer; glyph.DoLayout(); glyph.Width = Math.Abs(lineEndY - lineStartY); glyph.Paint(0, 0, canvas); canvas.EndRotate(); } else if (_beat.BrushType == BrushType.ArpeggioDown) { var lineStartY = startY + arrowSize; var lineEndY = endY + arrowSize; canvas.BeginRotate(cx + X + 7 * Scale, lineStartY, 90); var glyph = new NoteVibratoGlyph(0, 0, VibratoType.Slight); glyph.Renderer = Renderer; glyph.DoLayout(); glyph.Width = Math.Abs(lineEndY - lineStartY); glyph.Paint(0, 0, canvas); canvas.EndRotate(); } 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(); } } }