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


C# Point2D.Scale方法代码示例

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


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

示例1: OnPaint

        protected override void OnPaint(PaintEventArgs e)
        {
            ITriangulatable t = DisplayObjects[mDisplayIndex];

            Text = "poly2tri test: " + t.FileName;

            float xmin = (float)t.MinX;
            float xmax = (float)t.MaxX;
            float ymin = (float)t.MinY;
            float ymax = (float)t.MaxY;

            var fx = e.Graphics;

            {
                Font textFont = new Font("Times New Roman", 12);
                System.Drawing.Brush textBrush = System.Drawing.Brushes.Black;
                fx.DrawString("space = Pause/Unpause", textFont, textBrush, new PointF(10.0f, 10.0f));
                fx.DrawString("left/right arrow (while paused) = prev/next example", textFont, textBrush, new PointF(10.0f, 30.0f));
                fx.DrawString("mouse wheel = zoom in/out", textFont, textBrush, new PointF(10.0f, 50.0f));
                fx.DrawString("drag = pan", textFont, textBrush, new PointF(10.0f, 70.0f));
                fx.DrawString("double-click = reset zoom/pan", textFont, textBrush, new PointF(10.0f, 90.0f));
            }

            if (mbPaused)
            {
                Font textFont = new Font("Times New Roman", 24);
                System.Drawing.Brush textBrush = System.Drawing.Brushes.Black;
                fx.DrawString("Paused", textFont, textBrush, new PointF((ClientSize.Width / 2.0f) - 20.0f, 10.0f));
            }

            if (xmin < xmax && ymin < ymax)
            {
                float w = xmax - xmin;
                float h = ymax - ymin;
                Point2D ctr = new Point2D((double)ClientSize.Width / 2.0, (double)ClientSize.Height / 2.0);
                Point2D screenScaler = new Point2D((double)ClientSize.Width / (double)w, (double)ClientSize.Height / (double)h);
                Point2D zoomPoint = new Point2D(-mZoomPoint.X, mZoomPoint.Y);
                zoomPoint.RotateDegrees(t.DisplayRotate);
                zoomPoint.Scale(1.0 / screenScaler.X, 1.0 / screenScaler.Y);
                float zoom = mZoomLevel * (float)Math.Min(screenScaler.X, screenScaler.Y);

                fx.TranslateTransform(ctr.Xf, ctr.Yf);
                fx.RotateTransform(t.DisplayRotate);
                fx.ScaleTransform(zoom, -zoom);
                fx.TranslateTransform((-(xmax + xmin) / 2.0f) - zoomPoint.Xf, (-(ymax + ymin) / 2.0f) - zoomPoint.Yf);

                var penConstrained = new Pen(Color.Red, 1.0f / zoom);
                //var penDelaunay = new Pen(Color.Blue, 1.0f / zoom);
                var penNormal = new Pen(Color.Silver, 1.0f / zoom);
                var penErrorCase1 = new Pen(Color.Purple, 1.0f / zoom);
                var penErrorCase2 = new Pen(Color.Cyan, 1.0f / zoom);
                foreach (var tri in t.Triangles)
                {
                    PointF[] pts = new PointF[]
                    {
                        new PointF(tri.Points[0].Xf, tri.Points[0].Yf),
                        new PointF(tri.Points[1].Xf, tri.Points[1].Yf),
                        new PointF(tri.Points[2].Xf, tri.Points[2].Yf),
                    };
                    for (int i = 0; i < 3; ++i)
                    {
                        if (t.DisplayFlipX)
                        {
                            pts[i].X = xmax - (pts[i].X - xmin);
                        }
                        if (t.DisplayFlipY)
                        {
                            pts[i].Y = ymax - (pts[i].Y - ymin);
                        }
                    }
                    for (int i = 0; i < 3; ++i)
                    {
                        var curPen = penNormal;
                        DTSweepConstraint edge = null;
                        bool isConstrained = tri.GetConstrainedEdgeCCW(tri.Points[i]);
                        bool hasConstrainedEdge = tri.GetEdgeCCW(tri.Points[i], out edge);
                        if (isConstrained || hasConstrainedEdge)
                        {
                            if (isConstrained && hasConstrainedEdge)
                            {
                                curPen = penConstrained;
                            }
                            else if (isConstrained && !hasConstrainedEdge)
                            {
                                // this will happen when edges are split and is expected
                                //curPen = penErrorCase1;
                                curPen = penConstrained;
                            }
                            else
                            {
                                curPen = penErrorCase2;
                            }
                        }
                        //else if (tri.GetDelaunayEdgeCCW(tri.Points[i]))
                        //{
                        //    curPen = penDelaunay;
                        //}
                        fx.DrawLine(curPen, pts[i], pts[(i + 1) % 3]);
                    }
                }
//.........这里部分代码省略.........
开发者ID:nightkidfifa,项目名称:poly2tri.cs,代码行数:101,代码来源:TestForm.cs


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