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


C# Pen.GetBrush方法代码示例

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


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

示例1: Draw

        /// <summary>
        /// Draw on to the supplied graphics surface against the supplied axes.
        /// </summary>
        /// <param name="g">The graphics surface on which to draw.</param>
        /// <param name="xAxis">The X-Axis to draw against.</param>
        /// <param name="yAxis">The Y-Axis to draw against.</param>
        /// <remarks>TODO: block positions may be off by a pixel or so. maybe. Re-think calculations</remarks>
        public void Draw( Graphics g, PhysicalAxis xAxis, PhysicalAxis yAxis )
        {
            if ( data_==null || data_.GetLength(0) == 0 || data_.GetLength(1) == 0 )
            {
                return;
            }

            double worldWidth = xAxis.Axis.WorldMax - xAxis.Axis.WorldMin;
            double numBlocksHorizontal = worldWidth / this.xStep_;
            double worldHeight = yAxis.Axis.WorldMax - yAxis.Axis.WorldMin;
            double numBlocksVertical = worldHeight / this.yStep_;

            double physicalWidth = xAxis.PhysicalMax.X - xAxis.PhysicalMin.X;
            double blockWidth = physicalWidth / numBlocksHorizontal;
            bool wPositive = true;
            if (blockWidth < 0.0)
            {
                wPositive = false;
            }
            blockWidth = Math.Abs(blockWidth)+1;

            double physicalHeight = yAxis.PhysicalMax.Y - yAxis.PhysicalMin.Y;
            double blockHeight = physicalHeight / numBlocksVertical;
            bool hPositive = true;
            if (blockHeight < 0.0)
            {
                hPositive = false;
            }
            blockHeight = Math.Abs(blockHeight)+1;

            for (int i=0; i<data_.GetLength(0); ++i)
            {
                for (int j=0; j<data_.GetLength(1); ++j)
                {
                    double wX = (double)j*this.xStep_ + xStart_;
                    double wY = (double)i*this.yStep_ + yStart_;
                    if ( !hPositive )
                    {
                        wY += yStep_;
                    }
                    if (!wPositive )
                    {
                        wX += xStep_;
                    }

                    if (this.center_)
                    {
                        wX -= this.xStep_/2.0;
                        wY -= this.yStep_/2.0;
                    }
                    Pen p = new Pen( this.Gradient.GetColor( (data_[i,j]-this.dataMin_)/(this.dataMax_-this.dataMin_) ) );
                    int x = (int)xAxis.WorldToPhysical(wX,false).X;
                    int y = (int)yAxis.WorldToPhysical(wY,false).Y;
                    g.FillRectangle(p.GetBrush(),
                        x,
                        y,
                        (int)blockWidth,
                        (int)blockHeight);
                    //g.DrawRectangle(Pens.White,x,y,(int)blockWidth,(int)blockHeight);
                }
            }
        }
开发者ID:KonstantinChizhov,项目名称:NPlotCompact,代码行数:69,代码来源:ImagePlot.cs


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