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


C# IGraphics.DrawCurve方法代码示例

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


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

示例1: PaintMarkers

 private void PaintMarkers(IGraphics g, int off, int width, int height)
 {
     Pen fgPen = new Pen(ForeColor);
     for (int i = 0; i < Colors.Count; i++){
         Pen p = new Pen(Colors[i]);
         int a = ModelToView(Positions[i], width, height);
         int d = ((i == mouseOverIndex) && (Arrow == Arrows.First || Arrow == Arrows.Both)) ? triangleHeight : 0;
         if (Vertical){
             int e = ((i == mouseOverIndex)) && (Arrow == Arrows.Second || Arrow == Arrows.Both)
                 ? width - 1 - triangleHeight : width - 1;
             g.DrawLine(p, 0, a, width - 1, a);
             g.DrawLine(fgPen, d, a - 1, off - 1, a - 1);
             g.DrawLine(fgPen, d, a + 1, off - 1, a + 1);
             g.DrawLine(fgPen, off + StripWidth + 1, a - 1, e, a - 1);
             g.DrawLine(fgPen, off + StripWidth + 1, a + 1, e, a + 1);
         } else{
             int e = ((i == mouseOverIndex)) && (Arrow == Arrows.Second || Arrow == Arrows.Both)
                 ? height - 1 - triangleHeight : height - 1;
             g.DrawLine(p, a, 0, a, height - 1);
             g.DrawLine(fgPen, a - 1, d, a - 1, off - 1);
             g.DrawLine(fgPen, a + 1, d, a + 1, off - 1);
             g.DrawLine(fgPen, a - 1, off + StripWidth + 1, a - 1, e);
             g.DrawLine(fgPen, a + 1, off + StripWidth + 1, a + 1, e);
         }
         if (i == mouseOverIndex){
             Brush b = new SolidBrush(p.Color);
             if (Vertical){
                 if (Arrow == Arrows.Second || Arrow == Arrows.Both){
                     Point[] points = new[]{
                         new Point(width - 1 - triangleHeight, a - 1), new Point(width - 1 - triangleHeight, a - triangleBase2),
                         new Point(width - 1, a), new Point(width - 1 - triangleHeight, a + triangleBase2),
                         new Point(width - 1 - triangleHeight, a + 1)
                     };
                     g.FillClosedCurve(b, points);
                     g.DrawCurve(fgPen, points);
                 }
                 if (Arrow == Arrows.First || Arrow == Arrows.Both){
                     Point[] points = new[]{
                         new Point(triangleHeight, a - 1), new Point(triangleHeight, a - triangleBase2), new Point(0, a),
                         new Point(triangleHeight, a + triangleBase2), new Point(triangleHeight, a + 1)
                     };
                     g.FillClosedCurve(b, points);
                     g.DrawCurve(fgPen, points);
                 }
             } else{
                 Point[] points = new[]{
                     new Point(a - 1, height - 1 - triangleHeight), new Point(a - triangleBase2, height - 1 - triangleHeight),
                     new Point(a, height - 1), new Point(a + triangleBase2, height - 1 - triangleHeight),
                     new Point(a + 1, height - 1 - triangleHeight)
                 };
                 g.FillClosedCurve(b, points);
                 g.DrawCurve(fgPen, points);
                 points = new[]{
                     new Point(a - 1, triangleHeight), new Point(a - triangleBase2, triangleHeight), new Point(a, 0),
                     new Point(a + triangleBase2, triangleHeight), new Point(a + 1, triangleHeight)
                 };
                 g.FillClosedCurve(b, points);
                 g.DrawCurve(fgPen, points);
             }
         }
     }
 }
开发者ID:neuhauser,项目名称:compbio-base,代码行数:62,代码来源:ColorStripView.cs

示例2: Render


//.........这里部分代码省略.........
                PointF[] bezzie = new PointF[]
            {
                new PointF(20, 150),

                new PointF(110, 190),
                new PointF(120, 200),
                new PointF(50, 220),

                new PointF(60, 200),
                new PointF(140, 180),
                new PointF(100, 160),

                new PointF(180, 260),
                new PointF(200, 210),
                new PointF(190, 210)
            };

                Pen bpn = new Pen(Color.MediumSeaGreen, 2);
                bpn.DashStyle = DashStyle.Custom;
                bpn.DashPattern = new float[]{6,1,5,2,4,3,3,4,2,5,6,1};
                ig.DrawBeziers(bpn, bezzie);

                PointF[] curvy = new PointF[]
            {
                new PointF(130, 40),
                new PointF(70, 70),
                new PointF(50, 20),
                new PointF(120, 120),
                new PointF(150, 80),
                new PointF(80, 150),
                new PointF(80, 110)
            };

                ig.DrawCurve(new Pen(Color.Blue, 5), curvy);
                ig.DrawCurve(new Pen(Color.Red, 2), curvy, 2, 3);
                ig.DrawCurve(new Pen(Color.Yellow, 1), curvy, 1f);

                Point[] ccurvy = new Point[]
            {
                new Point(280, 30),
                new Point(260, 60),
                new Point(200, 20),
                new Point(290, 120),
                new Point(290, 80),
                new Point(230, 150),
                new Point(150, 50)
            };
                ig.DrawClosedCurve(new Pen(Color.Green, 3), ccurvy, 1f, FillMode.Alternate);
                ig.DrawClosedCurve(new Pen(Color.Purple, 1), ccurvy, 0f, FillMode.Alternate);

                Point[] fcc = new Point[]
            {
                new Point(160, 350),
                new Point(190, 370),
                new Point(130, 390),
                new Point(190, 400),
                new Point(195, 410),
                new Point(100, 430),
                new Point(160, 450)
            };
                ig.FillClosedCurve(new SolidBrush(Color.Red), fcc, FillMode.Winding, 1f);
                ig.FillClosedCurve(new SolidBrush(Color.Aquamarine), fcc, FillMode.Alternate, .2f);

            }
            else if (s == "Transparency")
            {
开发者ID:luizcorreia,项目名称:SvgNet,代码行数:67,代码来源:Form1.cs

示例3: DrawSmoothFilledCurve

        /// <summary>
        /// Draw the this <see cref="CurveItem"/> to the specified <see cref="Graphics"/>
        /// device using the specified smoothing property (<see cref="ZedGraph.Line.SmoothTension"/>).
        /// The routine draws the line segments and the area fill (if any, see <see cref="FillType"/>;
        /// the symbols are drawn by the <see cref="Symbol.Draw"/> method.  This method
        /// is normally only called by the Draw method of the
        /// <see cref="CurveItem"/> object.  Note that the <see cref="StepType"/> property
        /// is ignored for smooth lines (e.g., when <see cref="ZedGraph.Line.IsSmooth"/> is true).
        /// </summary>
        /// <param name="g">
        /// A graphic device object to be drawn into.  This is normally e.Graphics from the
        /// PaintEventArgs argument to the Paint() method.
        /// </param>
        /// <param name="scaleFactor">
        /// The scaling factor to be used for rendering objects.  This is calculated and
        /// passed down by the parent <see cref="GraphPane"/> object using the
        /// <see cref="PaneBase.CalcScaleFactor"/> method, and is used to proportionally adjust
        /// font sizes, etc. according to the actual size of the graph.
        /// </param>
        /// <param name="pane">
        /// A reference to the <see cref="GraphPane"/> object that is the parent or
        /// owner of this object.
        /// </param>
        /// <param name="curve">A <see cref="LineItem"/> representing this
        /// curve.</param>
        public virtual void DrawSmoothFilledCurve( IGraphics g, GraphPane pane,
                                CurveItem curve, float scaleFactor )
        {
            Line source = this;
            if ( curve.IsSelected )
                source = Selection.Line;

            PointF[] arrPoints;
            int count;
            IPointList points = curve.Points;

            if ( this.IsVisible && !this.Color.IsEmpty && points != null &&
                BuildPointsArray( pane, curve, out arrPoints, out count ) &&
                count > 2 )
            {
                float tension = _isSmooth ? _smoothTension : 0f;

                // Fill the curve if needed
                if ( this.Fill.IsVisible )
                {
                    Axis yAxis = curve.GetYAxis( pane );

                    using ( GraphicsPath path = new GraphicsPath( FillMode.Winding ) )
                    {
                        path.AddCurve( arrPoints, 0, count - 2, tension );

                        double yMin = yAxis._scale._min < 0 ? 0.0 : yAxis._scale._min;
                        CloseCurve( pane, curve, arrPoints, count, yMin, path );

                        RectangleF rect = path.GetBounds();
                        using ( Brush brush = source._fill.MakeBrush( rect ) )
                        {
                            if ( pane.LineType == LineType.Stack && yAxis.Scale._min < 0 &&
                                    this.IsFirstLine( pane, curve ) )
                            {
                                float zeroPix = yAxis.Scale.Transform( 0 );
                                RectangleF tRect = pane.Chart._rect;
                                tRect.Height = zeroPix - tRect.Top;
                                if ( tRect.Height > 0 )
                                {
                                    Region reg = g.Clip;
                                    g.SetClip( tRect );
                                    g.FillPath( brush, path );
                                    g.SetClip( pane.Chart._rect );
                                }
                            }
                            else
                                g.FillPath( brush, path );
                            //brush.Dispose();
                        }

                        // restore the zero line if needed (since the fill tends to cover it up)
                        yAxis.FixZeroLine( g, pane, scaleFactor, rect.Left, rect.Right );
                    }
                }

                // If it's a smooth curve, go ahead and render the path.  Otherwise, use the
                // standard drawcurve method just in case there are missing values.
                if (_isSmooth)
                {
                    using (Pen pen = GetPen(pane, scaleFactor))
                    {
                        // Stroke the curve
                        g.DrawCurve(pen, arrPoints, 0, count - 2, tension);

                        //pen.Dispose();
                    }
                }
                else
                {
                    DrawCurve(g, pane, curve, scaleFactor, GetPoints(curve, pane));
                }
            }
        }
开发者ID:konrad-zielinski,项目名称:ZedGraph,代码行数:99,代码来源:Line.cs


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