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


C# WriteableBitmap.DrawEllipse方法代码示例

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


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

示例1: DrawLoop_Terminator

        private void DrawLoop_Terminator(WriteableBitmap bitmap, System.Drawing.Rectangle r, String name)
        {
            bitmap.DrawEllipse(r.Left, r.Top, r.Width + r.Left, r.Height + r.Top, color);
              bitmap.DrawEllipse(r.Left + 1, r.Top + 1, r.Width - 1 + r.Left, r.Height - 1 + r.Top, color);
              bitmap.DrawEllipse(r.Left + 2, r.Top + 2, r.Width - 2 + r.Left, r.Height - 2 + r.Top, color);

              var x1 = r.Left + r.Width / 2;
              var y1 = r.Top;

              bitmap.DrawLine(x1, y1, x1 + 50, y1 - 50, color);
              bitmap.DrawLine(x1, y1 - 1, x1 + 50, y1 - 1 - 50, color);
              bitmap.DrawLine(x1, y1 - 2, x1 + 50, y1 - 2 - 50, color);

              bitmap.DrawLine(x1 + 50, y1 - 50, x1 + 100, y1 - 50, color);
              bitmap.DrawLine(x1 + 50, y1 - 50 - 1, x1 + 100, y1 - 50 - 1, color);
              bitmap.DrawLine(x1 + 50, y1 - 50 - 2, x1 + 100, y1 - 50 - 2, color);

              DrawText(bitmap, name, 16, x1 + 100 + 5, y1 - 50 - 20);
        }
开发者ID:philippetavernier,项目名称:WSRMacro,代码行数:19,代码来源:WSRCamera.xaml.cs

示例2: Button_Click

        /// <summary>
        /// Randomise the layout of points.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            // Create a new bitmap and set it as our canvas background.
            pBitmap = BitmapFactory.New((int)cnvPoints.ActualWidth, (int)cnvPoints.ActualHeight);
            var pBrush = new ImageBrush();
            pBrush.ImageSource = pBitmap;
            cnvPoints.Background = pBrush;

            // Clear the bitmap to light blue.
            using (pBitmap.GetBitmapContext())
                pBitmap.Clear(Colors.LightBlue);


            // Get the number we want to generate and update the UI.
            var iResult = 0;
            if (!int.TryParse(txtPoints.Text, out iResult))
            {
                txtPoints.Foreground = Brushes.Red;
                return;
            }
            if (iResult < 0)
            {
                txtPoints.Foreground = Brushes.Red;
                return;
            }
            txtPoints.Foreground = Brushes.Black;

            // Clear the tree and canvas.
            cnvPoints.Children.Clear();
            pTree = new KDTree.KDTree<EllipseWrapper>(2);

            // Create a list of points and draw a ghost ellipse for each one.
            using (pBitmap.GetBitmapContext())
            {
                // Generate X new random items.
                var pRandom = new Random();
                for (int i = 0; i < iResult; ++i)
                {
                    // Position it and add it to the canvas.
                    var x = pRandom.NextDouble() * cnvPoints.ActualWidth;
                    var y = pRandom.NextDouble() * cnvPoints.ActualHeight;

                    // Add it to the tree.
                    pTree.AddPoint(new double[] { x, y }, new EllipseWrapper(x, y));

                    // Draw a ghost visual for it.
                    //pBitmap.DrawEllipse((int)x - 2, (int)y - 2, (int)x + 2, (int)y + 2, Colors.Green);
                    pBitmap.DrawEllipse((int)x - 2, (int)y - 2, (int)x + 2, (int)y + 2, Colors.Orange);

                }
            }
        }
开发者ID:b3r3ch1t,项目名称:kd-sharp,代码行数:57,代码来源:MainWindow.xaml.cs


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