当前位置: 首页>>代码示例>>C#>>正文


C# ICanvas.BeginPath方法代码示例

本文整理汇总了C#中ICanvas.BeginPath方法的典型用法代码示例。如果您正苦于以下问题:C# ICanvas.BeginPath方法的具体用法?C# ICanvas.BeginPath怎么用?C# ICanvas.BeginPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICanvas的用法示例。


在下文中一共展示了ICanvas.BeginPath方法的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();
            }
        }
开发者ID:CoderLine,项目名称:alphaTab,代码行数:27,代码来源:LineRangedGlyph.cs

示例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();
                }
            }
        }
开发者ID:eriser,项目名称:alphaTab,代码行数:48,代码来源:TabBrushGlyph.cs

示例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);
        }
开发者ID:eriser,项目名称:alphaTab,代码行数:26,代码来源:RepeatOpenGlyph.cs

示例4: Paint

        public override void Paint(float cx, float cy, ICanvas canvas)
        {
            // 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;
                }
            }

            cx += X;
            cy += Y;

            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];

                // draw pre-bend if previous
                if (i == 0 && firstPt.Value != 0 && !_note.IsTieDestination)
                {
                    PaintBend(new BendPoint(), firstPt, cx, cy, dX, canvas);
                }

                // 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;

                PaintBend(firstPt, secondPt,  cx, cy, dX, canvas);
            }
        }
开发者ID:CoderLine,项目名称:alphaTab,代码行数:34,代码来源:BendGlyph.cs

示例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();
 }
开发者ID:CoderLine,项目名称:alphaTab,代码行数:10,代码来源:RhythmBarRenderer.cs

示例6: 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();
        }
开发者ID:eriser,项目名称:alphaTab,代码行数:11,代码来源:FadeInGlyph.cs

示例7: Paint

        public override void Paint(float cx, float cy, ICanvas canvas)
        {
            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();
                }
            }
        }
开发者ID:eriser,项目名称:alphaTab,代码行数:41,代码来源:ScoreBrushGlyph.cs

示例8: 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();
        }
开发者ID:CoderLine,项目名称:alphaTab,代码行数:14,代码来源:FadeInGlyph.cs

示例9: 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();

                }
            }
        }
开发者ID:eriser,项目名称:alphaTab,代码行数:36,代码来源:LineRangedGlyph.cs

示例10: 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();
 }
开发者ID:eriser,项目名称:alphaTab,代码行数:18,代码来源:CrescendoGlyph.cs

示例11: 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();
 }
开发者ID:CoderLine,项目名称:alphaTab,代码行数:19,代码来源:CrescendoGlyph.cs

示例12: 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);
            }
        }
开发者ID:eriser,项目名称:alphaTab,代码行数:22,代码来源:BarSeperatorGlyph.cs

示例13: 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;
        }
开发者ID:CoderLine,项目名称:alphaTab,代码行数:94,代码来源:ScoreBarRenderer.cs

示例14: 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);
            }
        }
开发者ID:CoderLine,项目名称:alphaTab,代码行数:76,代码来源:ScoreBarRenderer.cs

示例15: 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);
                    }
                }
            }
        }
开发者ID:CoderLine,项目名称:alphaTab,代码行数:97,代码来源:ScoreBarRenderer.cs


注:本文中的ICanvas.BeginPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。