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


C# CanvasDrawingSession.DrawRoundedRectangle方法代码示例

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


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

示例1: DrawRoundedRectangle

        private void DrawRoundedRectangle(CanvasControl sender, CanvasDrawingSession ds)
        {
            var width = (float)sender.ActualWidth;
            var height = (float)sender.ActualHeight;

            int steps = Math.Min((int)(width / 30), 10);

            for (int i = 0; i < steps; ++i)
            {
                var mu = (float)i / steps;

                var color = GradientColor(mu);

                mu *= 0.5f;
                var x = mu * width;
                var y = mu * height;

                var xx = (1 - mu) * width;
                var yy = (1 - mu) * height;

                var radius = mu * 50.0f;

                ds.DrawRoundedRectangle(
                    x, y,
                    xx-x, yy-y,
                    radius, radius,
                    color,
                    2.0f);
            }
        }
开发者ID:jiatingxiu,项目名称:Win2D,代码行数:30,代码来源:ShapesExample.xaml.cs

示例2: DrawStuff

        void DrawStuff(CanvasDrawingSession ds)
        {
            int horizontalLimit = (int)m_canvasControl.ActualWidth;
            int verticalLimit = (int)m_canvasControl.ActualHeight;
            const float thickStrokeWidth = 80.0f;

            DrawnContentType drawnContentType = (DrawnContentType)m_drawnContentTypeCombo.SelectedValue;

            ds.Clear(NextRandomColor());
                
            Rect rect;
            Vector2 point;
            float radiusX;
            float radiusY;

            switch (drawnContentType)
            {
                case DrawnContentType.Clear_Only:
                    break;

                case DrawnContentType.Bitmap:
                    if (m_bitmap_tiger != null)
                    {
                        ds.DrawImage(m_bitmap_tiger, NextRandomPoint(horizontalLimit, verticalLimit).ToVector2());
                    }
                    else
                    {
                        DrawNoBitmapErrorMessage(ds, horizontalLimit / 2, verticalLimit / 2);
                    }
                    break;

                case DrawnContentType.Effect_Blur:
                    if (m_bitmap_tiger != null)
                    {
                        GaussianBlurEffect blurEffect = new GaussianBlurEffect();
                        blurEffect.StandardDeviation = 2.0f;
                        blurEffect.Source = m_bitmap_tiger;
                        ds.DrawImage(blurEffect, NextRandomPoint(horizontalLimit, verticalLimit).ToVector2());
                    }
                    else
                    {
                        DrawNoBitmapErrorMessage(ds, horizontalLimit / 2, verticalLimit / 2);
                    }
                    break;

                case DrawnContentType.Line_Thin:
                    ds.DrawLine(
                        NextRandomPoint(horizontalLimit, verticalLimit).ToVector2(),
                        NextRandomPoint(horizontalLimit, verticalLimit).ToVector2(),
                        NextRandomColor());
                    break;

                case DrawnContentType.Line_Thick:
                    ds.DrawLine(
                        NextRandomPoint(horizontalLimit, verticalLimit).ToVector2(),
                        NextRandomPoint(horizontalLimit, verticalLimit).ToVector2(),
                        NextRandomColor(),
                        thickStrokeWidth);
                    break;

                case DrawnContentType.Rectangle_Thin:
                    ds.DrawRectangle(
                        NextRandomRect(horizontalLimit, verticalLimit),
                        NextRandomColor());
                    break;

                case DrawnContentType.Rectangle_Thick:
                    ds.DrawRectangle(
                        NextRandomRect(horizontalLimit, verticalLimit),
                        NextRandomColor(),
                        thickStrokeWidth);
                    break;

                case DrawnContentType.Rectangle_Filled:
                    ds.FillRectangle(
                        NextRandomRect(horizontalLimit, verticalLimit),
                        NextRandomColor());
                    break;

                case DrawnContentType.RoundedRectangle_Thin:
                    NextRandomRoundedRect(horizontalLimit, verticalLimit, out rect, out radiusX, out radiusY);
                    ds.DrawRoundedRectangle(
                        rect, radiusX, radiusY,
                        NextRandomColor());
                    break;

                case DrawnContentType.RoundedRectangle_Thick:
                    NextRandomRoundedRect(horizontalLimit, verticalLimit, out rect, out radiusX, out radiusY);
                    ds.DrawRoundedRectangle(
                        rect, radiusX, radiusY,
                        NextRandomColor(),
                        thickStrokeWidth);
                    break;

                case DrawnContentType.Ellipse_Thin:
                    NextRandomEllipse(horizontalLimit, verticalLimit, out point, out radiusX, out radiusY);
                    ds.DrawEllipse(
                        point, radiusX, radiusY,
                        NextRandomColor());
                    break;
//.........这里部分代码省略.........
开发者ID:gfcprogramer,项目名称:Win2D,代码行数:101,代码来源:MainPage.xaml.cs


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