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


C# ICanvas.BezierCurveTo方法代码示例

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


在下文中一共展示了ICanvas.BezierCurveTo方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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 != "")
//.........这里部分代码省略.........
开发者ID:vmoll,项目名称:alphaTab,代码行数:101,代码来源:BendGlyph.cs

示例2: Paint

        public void Paint(float cx, float cy, ICanvas canvas)
        {
            for (int i = 0, j = _allStaves.Count; i < j; i++)
            {
                _allStaves[i].Paint(cx + X, cy + Y, canvas);
            }

            var res = Layout.Renderer.RenderingResources;

            if (Staves.Count > 0)
            {
                //
                // Draw start grouping
                //

                if (_firstStaveInAccolade != null && _lastStaveInAccolade != null)
                {
                    //
                    // draw grouping line for all staves
                    //

                    var firstStart = cy + Y + _firstStaveInAccolade.Y + _firstStaveInAccolade.StaveTop + _firstStaveInAccolade.TopSpacing + _firstStaveInAccolade.TopOverflow;
                    var lastEnd = cy + Y + _lastStaveInAccolade.Y + _lastStaveInAccolade.TopSpacing + _lastStaveInAccolade.TopOverflow
                                         + _lastStaveInAccolade.StaveBottom;

                    var acooladeX = cx + X + _firstStaveInAccolade.X;

                    canvas.Color = res.BarSeperatorColor;

                    canvas.BeginPath();
                    canvas.MoveTo(acooladeX, firstStart);
                    canvas.LineTo(acooladeX, lastEnd);
                    canvas.Stroke();
                }

                //
                // Draw accolade for each track group
                //
                canvas.Font = res.EffectFont;
                for (int i = 0, j = Staves.Count; i < j; i++)
                {
                    var g = Staves[i];
                    var firstStart = cy + Y + g.FirstStaveInAccolade.Y + g.FirstStaveInAccolade.StaveTop + g.FirstStaveInAccolade.TopSpacing + g.FirstStaveInAccolade.TopOverflow;
                    var lastEnd = cy + Y + g.LastStaveInAccolade.Y + g.LastStaveInAccolade.TopSpacing + g.LastStaveInAccolade.TopOverflow
                                         + g.LastStaveInAccolade.StaveBottom;

                    var acooladeX = cx + X + g.FirstStaveInAccolade.X;

                    var barSize = (3 * Layout.Renderer.Settings.Scale);
                    var barOffset = barSize;

                    var accoladeStart = firstStart - (barSize * 4);
                    var accoladeEnd = lastEnd + (barSize * 4);

                    // text
                    if (Index == 0)
                    {
                        canvas.FillText(g.Track.ShortName, cx + X + (AccoladeLabelSpacing * Layout.Scale), firstStart);
                    }

                    // rect
                    canvas.FillRect(acooladeX - barOffset - barSize, accoladeStart, barSize, accoladeEnd - accoladeStart);

                    var spikeStartX = acooladeX - barOffset - barSize;
                    var spikeEndX = acooladeX + barSize * 2;

                    // top spike
                    canvas.BeginPath();
                    canvas.MoveTo(spikeStartX, accoladeStart);
                    canvas.BezierCurveTo(spikeStartX, accoladeStart, spikeStartX, accoladeStart, spikeEndX, accoladeStart - barSize);
                    canvas.BezierCurveTo(acooladeX, accoladeStart + barSize, spikeStartX, accoladeStart + barSize, spikeStartX, accoladeStart + barSize);
                    canvas.ClosePath();
                    canvas.Fill();

                    // bottom spike
                    canvas.BeginPath();
                    canvas.MoveTo(spikeStartX, accoladeEnd);
                    canvas.BezierCurveTo(spikeStartX, accoladeEnd, acooladeX, accoladeEnd, spikeEndX, accoladeEnd + barSize);
                    canvas.BezierCurveTo(acooladeX, accoladeEnd - barSize, spikeStartX, accoladeEnd - barSize, spikeStartX, accoladeEnd - barSize);
                    canvas.ClosePath();

                    canvas.Fill();
                }
            }
        }
开发者ID:stefan-j,项目名称:alphaTab,代码行数:85,代码来源:StaveGroup.cs

示例3: PaintBend

        private void PaintBend(BendPoint firstPt, BendPoint secondPt, float cx, float cy, float dX, ICanvas canvas)
        {
            var r = (TabBarRenderer)Renderer;
            var res = Renderer.Resources;

            var overflowOffset = r.LineOffset / 2;

            var x1 = cx + (dX * firstPt.Offset);
            var y1 = cy - (_bendValueHeight * firstPt.Value);
            if (firstPt.Value == 0)
            {
                y1 += r.GetNoteY(_note);
            }
            else
            {
                y1 += overflowOffset;
            }
            var x2 = cx + (dX * secondPt.Offset);
            var y2 = cy - (_bendValueHeight * secondPt.Value);
            if (secondPt.Value == 0)
            {
                y2 += r.GetNoteY(_note);
            }
            else
            {
                y2 += overflowOffset;
            }

            // what type of arrow? (up/down)
            var arrowOffset = 0f;
            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();
                arrowOffset = arrowSize;
            }
            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();
                arrowOffset = -arrowSize;
            }
            canvas.Stroke();

            if (firstPt.Value == secondPt.Value)
            {
                // draw horizontal line
                canvas.MoveTo(x1, y1);
                canvas.LineTo(x2, y2);
                canvas.Stroke();
            }
            else
            {
                if (x2 > x1)
                {
                    // draw bezier lien from first to second point
                    canvas.MoveTo(x1, y1);
                    canvas.BezierCurveTo(x2, y1, x2, y2 + arrowOffset, x2, y2 + arrowOffset);
                    canvas.Stroke();
                }
                else
                {
                    canvas.MoveTo(x1, y1);
                    canvas.LineTo(x2, y2);
                    canvas.Stroke();
                }
            }

            if (secondPt.Value != 0)
            {
                var dV = secondPt.Value;
                var up = secondPt.Value > firstPt.Value;
                dV = Math.Abs(dV);

                // calculate label
                var s = "";
                // Full Steps
                if (dV == 4 && up)
                {
                    s = "full";
                    dV -= 4;
                }
                else if (dV >= 4)
                {
                    int steps = dV / 4;
                    s += steps;
                    // Quaters
                    dV -= steps * 4;
                }

                if (dV > 0)
//.........这里部分代码省略.........
开发者ID:CoderLine,项目名称:alphaTab,代码行数:101,代码来源:BendGlyph.cs


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