Ejemplo n.º 1
0
        protected override void CreateTies(Note n)
        {
            if (!n.IsVisible)
            {
                return;
            }

            var renderer = (TabBarRenderer)Renderer;

            if (n.IsTieOrigin && renderer.ShowTiedNotes && n.TieDestination.IsVisible)
            {
                var tie = new TabTieGlyph(n, n.TieDestination, false);
                Ties.Add(tie);
            }
            if (n.IsTieDestination && renderer.ShowTiedNotes)
            {
                var tie = new TabTieGlyph(n.TieOrigin, n, false, true);
                Ties.Add(tie);
            }

            if (n.SlurOrigin != null)
            {
                var tie = new TabSlurGlyph(n);
                Ties.Add(tie);
            }

            if (n.SlideType != SlideType.None)
            {
                var l = new TabSlideLineGlyph(n.SlideType, n, this);
                Ties.Add(l);
            }

            if (n.HasBend)
            {
                if (_bend == null)
                {
                    _bend          = new TabBendGlyph(n.Beat);
                    _bend.Renderer = Renderer;
                    Ties.Add(_bend);
                }
                _bend.AddBends(n);
            }
        }
Ejemplo n.º 2
0
        private void PaintWhammy(bool isFirst, BendPoint firstPt, BendPoint secondPt, BendPoint nextPt, float cx, float cy, float dx, ICanvas canvas, string slurText = null)
        {
            var x1 = cx + dx * firstPt.Offset;
            var x2 = cx + dx * secondPt.Offset;

            var y1 = cy - GetOffset(firstPt.Value);
            var y2 = cy - GetOffset(secondPt.Value);

            if (firstPt.Offset == secondPt.Offset)
            {
                var dashSize = DashSize * Scale;
                var dashes   = Math.Abs(y2 - y1) / (dashSize * 2);
                if (dashes < 1)
                {
                    canvas.MoveTo(x1, y1);
                    canvas.LineTo(x2, y2);
                }
                else
                {
                    var dashEndY   = Math.Max(y1, y2);
                    var dashStartY = Math.Min(y1, y2);

                    while (dashEndY > dashStartY)
                    {
                        canvas.MoveTo(x1, dashStartY);
                        canvas.LineTo(x1, dashStartY + dashSize);

                        dashStartY += dashSize * 2;
                    }
                }
                canvas.Stroke();
            }
            else if (firstPt.Value == secondPt.Value)
            {
                var dashSize = DashSize * Scale;
                var dashes   = Math.Abs(x2 - x1) / (dashSize * 2);
                if (dashes < 1)
                {
                    canvas.MoveTo(x1, y1);
                    canvas.LineTo(x2, y2);
                }
                else
                {
                    var dashEndX   = Math.Max(x1, x2);
                    var dashStartX = Math.Min(x1, x2);

                    while (dashEndX > dashStartX)
                    {
                        canvas.MoveTo(dashEndX, y1);
                        canvas.LineTo(dashEndX - dashSize, y1);

                        dashEndX -= dashSize * 2;
                    }
                }
                canvas.Stroke();
            }
            else
            {
                canvas.MoveTo(x1, y1);
                canvas.LineTo(x2, y2);
            }

            var res = canvas.Resources;

            if (isFirst && !_beat.IsContinuedWhammy && !_isSimpleDip)
            {
                float y = y1;
                y -= res.TablatureFont.Size + (2 * Scale);
                if (Renderer.Settings.ShowZeroOnDiveWhammy)
                {
                    canvas.FillText("0", x1, y);
                }

                if (slurText != null)
                {
                    y -= res.TablatureFont.Size + (2 * Scale);
                    canvas.FillText(slurText, x1, y);
                }
            }

            var dV = Math.Abs(secondPt.Value);

            if ((dV != 0 || (Renderer.Settings.ShowZeroOnDiveWhammy && !_isSimpleDip)) && firstPt.Value != secondPt.Value)
            {
                var s = "";
                if (secondPt.Value < 0)
                {
                    s += "-";
                }

                if (dV >= 4)
                {
                    int steps = dV / 4;
                    s += steps;
                    // Quaters
                    dV -= steps * 4;
                }
                else if (dV == 0)
                {
                    s += "0";
                }

                if (dV > 0)
                {
                    s += TabBendGlyph.GetFractionSign(dV);
                }

                float y;
                if (_isSimpleDip)
                {
                    y = Math.Min(y1, y2) - res.TablatureFont.Size - (2 * Scale);
                }
                else
                {
                    y  = firstPt.Offset == secondPt.Offset ? Math.Min(y1, y2) : y2;
                    y -= res.TablatureFont.Size + (2 * Scale);
                    if (nextPt != null && nextPt.Value > secondPt.Value)
                    {
                        y -= (2 * Scale);
                    }
                }

                var x = x2;

                canvas.FillText(s, x, y);
            }
        }