• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Canvas.CanvasDrawingSession类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



CanvasDrawingSession类属于Microsoft.Graphics.Canvas命名空间,在下文中一共展示了CanvasDrawingSession类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Draw

        public void Draw( CanvasDrawingSession ds, CanvasSpriteBatch SBatch, TextureLoader Textures )
        {
            lock ( PFSim )
            {
                var Snapshot = PFSim.Snapshot();
                while ( Snapshot.MoveNext() )
                {
                    Particle P = Snapshot.Current;

                    float A = Vector2.Transform( new Vector2( 0, 1 ), Matrix3x2.CreateRotation( P.ttl * 0.01f ) ).X;

                    Vector4 Tint = new Vector4(
                        P.Tint.M11 + P.Tint.M21 + P.Tint.M31 + P.Tint.M41 + P.Tint.M51,
                        P.Tint.M12 + P.Tint.M22 + P.Tint.M32 + P.Tint.M42 + P.Tint.M52,
                        P.Tint.M13 + P.Tint.M23 + P.Tint.M33 + P.Tint.M43 + P.Tint.M53,
                        P.Tint.M14 + P.Tint.M24 + P.Tint.M34 + P.Tint.M44 + P.Tint.M54
                    );

                    Tint.W *= A;
                    ScrollWind.Strength *= 0.5f;

                    SBatch.Draw(
                        Textures[ P.TextureId ]
                        , P.Pos, Tint
                        , Textures.Center[ P.TextureId ], 0, P.Scale
                        , CanvasSpriteFlip.None );
                }

                DrawWireFrames( ds );
            }
        }
开发者ID:tgckpg,项目名称:wenku10,代码行数:31,代码来源:Glitter.cs


示例2: DrawLine

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

            var middle = height / 2;

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

            for (int i = 0; i < steps; ++i)
            {
                var mu = (float)i / steps;
                var a = (float)(mu * Math.PI * 2);

                var color = GradientColor(mu);

                var x = width * mu;
                var y = (float)(middle + Math.Sin(a) * (middle * 0.3));

                var strokeWidth = (float)(Math.Cos(a) + 1) * 5;

                ds.DrawLine(x, 0, x, y, color, strokeWidth);
                ds.DrawLine(x, height, x, y, color, 10 - strokeWidth);
            }
        }
开发者ID:gfcprogramer,项目名称:Win2D,代码行数:25,代码来源:ShapesExample.xaml.cs


示例3: Draw

        public void Draw( CanvasDrawingSession ds, CanvasSpriteBatch SBatch, TextureLoader Textures )
        {
            lock ( PFSim )
            {
                var Snapshot = PFSim.Snapshot();
                while ( Snapshot.MoveNext() )
                {
                    Particle P = Snapshot.Current;

                    float A = ( P.Trait & PFTrait.IMMORTAL ) == 0 ? P.ttl * 0.033f : 1;

                    P.Tint.M12 = 4 * ( 1 - A );
                    P.Tint.M21 = 3 * A;

                    Vector4 Tint = new Vector4(
                        P.Tint.M11 + P.Tint.M21 + P.Tint.M31 + P.Tint.M41 + P.Tint.M51,
                        P.Tint.M12 + P.Tint.M22 + P.Tint.M32 + P.Tint.M42 + P.Tint.M52,
                        P.Tint.M13 + P.Tint.M23 + P.Tint.M33 + P.Tint.M43 + P.Tint.M53,
                        P.Tint.M14 + P.Tint.M24 + P.Tint.M34 + P.Tint.M44 + P.Tint.M54
                    ) * 2;

                    Tint.W *= A * 0.125f;

                    SBatch.Draw( Textures[ P.TextureId ], P.Pos, Tint, Textures.Center[ P.TextureId ], 0, P.Scale * A, CanvasSpriteFlip.None );
                }

                DrawWireFrames( ds );
            }
        }
开发者ID:tgckpg,项目名称:wenku10,代码行数:29,代码来源:Fireworks.cs


示例4: Draw

        public override void Draw(CanvasDrawingSession drawingSession, bool useSpriteBatch)
        {
            if (!surfaceLoaded)
                return;
            // 保护原先画布的混合模式
            var previousBlend = drawingSession.Blend;

            drawingSession.Blend = blendState;

#if WINDOWS_UWP
            if (useSpriteBatch)
            {
                // 使用 SpriteBatch 可以提高性能
                using (var spriteBatch = drawingSession.CreateSpriteBatch())
                {
                    Draw(drawingSession, spriteBatch);
                }
            }
            else
            {
                Draw(drawingSession, null);
            }
#else
            Draw(drawingSession);
#endif

            drawingSession.Blend = previousBlend;
        }
开发者ID:aurora-lzzp,项目名称:Aurora-Weather,代码行数:28,代码来源:StarParticleSystem.cs


示例5: Draw

        public void Draw(CanvasDrawingSession drawingSession, bool useSpriteBatch)
        {
            if (surfaceLoaded)
            {
                // 保护原先画布的混合模式
                var previousBlend = drawingSession.Blend;

                drawingSession.Blend = CanvasBlend.SourceOver;

#if WINDOWS_UWP
                if (useSpriteBatch)
                {
                    // 使用 SpriteBatch 可以提高性能
                    using (var spriteBatch = drawingSession.CreateSpriteBatch())
                    {
                        Draw(drawingSession, spriteBatch);
                    }
                }
                else
                {
                    Draw(drawingSession, null);
                }
#else
            Draw(drawingSession);
#endif

                drawingSession.Blend = previousBlend;
            }
        }
开发者ID:aurora-lzzp,项目名称:Aurora-Weather,代码行数:29,代码来源:SolarSystem.cs


示例6: TransformSession

		private TransformSession(CanvasDrawingSession session, Matrix3x2 oldTransform, SvgMatrix multiply)
		{
			this.Session = session;
			this.OldTransform = oldTransform;

			var transform = new Matrix3x2((float)multiply.A, (float)multiply.B, (float)multiply.C, (float)multiply.D, (float)multiply.E, (float)multiply.F);
			session.Transform = transform * session.Transform;
		}
开发者ID:lallous,项目名称:SvgForXaml,代码行数:8,代码来源:TransformSession.cs


示例7: Draw

        //int count;
        public void Draw(CanvasDrawingSession ds, Size sizeRender, float totalTimeSeconds)
        {
            //count++;
            //ds.DrawText(count.ToString(), new Vector2(10.0f, 10.0f), Colors.Red);
            SetupText(ds);
            ConfigureEffect(totalTimeSeconds);

            ds.DrawImage(composite, sizeRender.ToVector2() / 2);
        }
开发者ID:clarkezone,项目名称:BUILD2015-Talk-2-672,代码行数:10,代码来源:BurningTextExample.xaml.cs


示例8: Direct2DCommandExecutor

 /// <summary>
 /// Конструктор.
 /// </summary>
 /// <param name="session">Сессия отрисовки.</param>
 /// <param name="factory">Фабрика.</param>
 /// <param name="splitter">Средство разбики слов.</param>
 /// <param name="renderWidth">Ширина отрисовки.</param>
 public Direct2DCommandExecutor(CanvasDrawingSession session, IDirect2DElementFactory factory, IWordSplitter splitter, double renderWidth)
 {
     if (factory == null) throw new ArgumentNullException(nameof(factory));
     if (session == null) throw new ArgumentNullException(nameof(session));
     if (splitter == null) throw new ArgumentNullException(nameof(splitter));
     Factory = factory;
     Session = session;
     Splitter = splitter;
     RenderWidth = renderWidth;
 }
开发者ID:Opiumtm,项目名称:DvachBrowser3,代码行数:17,代码来源:Direct2DCommandExecutor.cs


示例9: DrawIcon

        // Alternative entrypoint for use by AppIconGenerator.
        internal void DrawIcon(CanvasDrawingSession drawingSession, string text)
        {
            this.text = text;
            this.fontSize = 64;

            CreateFlameEffect();
            SetupText(drawingSession);
            ConfigureEffect(new CanvasTimingInformation());

            drawingSession.DrawImage(flamePosition);
            drawingSession.DrawImage(textCommandList);
        }
开发者ID:jiatingxiu,项目名称:Win2D,代码行数:13,代码来源:BurningTextExample.xaml.cs


示例10: DrawWireFrames

        protected void DrawWireFrames( CanvasDrawingSession ds )
        {
#if DEBUG
            lock ( PFSim )
            {
                if ( ShowWireFrame )
                {
                    foreach ( IForceField IFF in PFSim.Fields )
                    {
                        IFF.WireFrame( ds );
                    }
                }

            }
#endif
        }
开发者ID:tgckpg,项目名称:wenku10,代码行数:16,代码来源:PFScene.cs


示例11: DrawCircles

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

            float endpointMargin = Math.Min(width, height) / 8;
            float controlMarginX = endpointMargin * 4;
            float controlMarginY = endpointMargin * 2;

            for (int i = 0; i < 25; i++)
            {
                Vector2[] bez = new Vector2[4];
                int n = (i * 24) + 9 - (i / 2);

                for (int k = 0; k < 3; k++)
                {
                    int j = 4 - (2 * k);
                    bez[k].X = (0 + (((n >> (j + 1)) & 1) * (width - controlMarginX)));
                    bez[k].Y = (0 + (((n >> j) & 1) * (height - controlMarginY)));
                }
                bez[3].X = width - endpointMargin; // Collect the ends in the lower right
                bez[3].Y = height - endpointMargin;

                const int nSteps = 80;
                const float tStep = 1.0f / nSteps;
                float t = 0;
                for (int step = 0; step < nSteps; step++)
                {
                    float s = 1 - t;
                    float ss = s * s;
                    float sss = ss * s;
                    float tt = t * t;
                    float ttt = tt * t;
                    float x = (sss * bez[0].X) + (3 * ss * t * bez[1].X) + (3 * s * tt * bez[2].X) + (ttt * bez[3].X);
                    float y = (sss * bez[0].Y) + (3 * ss * t * bez[1].Y) + (3 * s * tt * bez[2].Y) + (ttt * bez[3].Y);
                    float radius = ttt * endpointMargin;
                    float strokeWidth = (0.5f - Math.Abs(ss - 0.5f)) * 10;

                    ds.DrawCircle(x, y, radius, GradientColor(t), strokeWidth);
                    t += tStep;
                }
            }
        }
开发者ID:jiatingxiu,项目名称:Win2D,代码行数:43,代码来源:ShapesExample.xaml.cs


示例12: DrawCanvasState

        private void DrawCanvasState(CanvasControl canvas, CanvasDrawingSession ds, int drawCount)
        {
            ds.Clear(Color.FromArgb(0, 0, 0, 0));

            ds.DrawLine(0, 0, (float)canvas.ActualWidth, (float)canvas.ActualHeight, Colors.Aqua);
            ds.DrawLine(0, (float)canvas.ActualHeight, (float)canvas.ActualWidth, 0, Colors.Aqua);

            var text = String.Format("{0}x{1}\n{2} redraws", (int)canvas.ActualWidth, (int)canvas.ActualHeight, drawCount);

            ds.DrawText(
                text,
                0, 0,
                Colors.FloralWhite,
                new CanvasTextFormat()
                {
                    VerticalAlignment = CanvasVerticalAlignment.Top,
                    ParagraphAlignment = ParagraphAlignment.Left,
                    FontSize = 10
                });
        }
开发者ID:gfcprogramer,项目名称:Win2D,代码行数:20,代码来源:CanvasControlExample.xaml.cs


示例13: ApplyBloomFilter

        void ApplyBloomFilter(CanvasDrawingSession drawingSession)
        {
            // Configure effects to use the latest threshold, blur, and intensity settings.
            extractBrightAreas.RedSlope =
            extractBrightAreas.GreenSlope =
            extractBrightAreas.BlueSlope = 1 / (1 - BloomThreshold / 100);

            extractBrightAreas.RedOffset =
            extractBrightAreas.GreenOffset =
            extractBrightAreas.BlueOffset = -BloomThreshold / 100 / (1 - BloomThreshold / 100);

            blurBrightAreas.BlurAmount = BloomBlur;

            adjustBloomIntensity.RedSlope =
            adjustBloomIntensity.GreenSlope =
            adjustBloomIntensity.BlueSlope = BloomIntensity / 100;

            // Apply the bloom effect.
            drawingSession.DrawImage(bloomResult);
        }
开发者ID:jiatingxiu,项目名称:Win2D,代码行数:20,代码来源:Direct3DInteropExample.xaml.cs


示例14: Draw

        public void Draw(ICanvasAnimatedControl sender, CanvasDrawingSession drawingSession)
        {
            if (currentThunder == null)
            {
                return;
            }
            // 保护原先画布的混合模式
            var previousBlend = drawingSession.Blend;
            drawingSession.Blend = blendState;
            var builder = new CanvasPathBuilder(sender);
            builder.BeginFigure(0, 0);
            for (int i = 0; i < currentThunder.LifeLong; i++)
            {
                builder.AddLine(currentThunder.Path[i].X, currentThunder.Path[i].Y);
            }
            builder.EndFigure(CanvasFigureLoop.Open);
            builder.SetSegmentOptions(CanvasFigureSegmentOptions.ForceRoundLineJoin);

            // Draw the particle.
            var path = CanvasGeometry.CreatePath(builder);
            var NormalizeLifeTime = currentThunder.TimeSinceStart / currentThunder.Duration;
            byte opacity = (byte)((NormalizeLifeTime - 1) * (NormalizeLifeTime - 1) * 255);
            CanvasCommandList cl = new CanvasCommandList(sender);
            using (CanvasDrawingSession clds = cl.CreateDrawingSession())
            {
                clds.DrawGeometry(path, currentThunder.Position, Color.FromArgb((byte)(0.75f * opacity), 255, 255, 255), 6 * currentThunder.Luminace);
            }
            var lightAmount = 20.6f * currentThunder.Luminace * (NormalizeLifeTime - 1) * (NormalizeLifeTime - 1);
            blur.Source = cl;
            blur.BlurAmount = lightAmount;
            drawingSession.DrawImage(blur);
            drawingSession.DrawGeometry(path, currentThunder.Position, Color.FromArgb(opacity, 255, 240, 180), 2 * currentThunder.Luminace);
            drawingSession.Blend = previousBlend;
            if (NormalizeLifeTime > 1)
            {
                currentThunder = null;
            }
        }
开发者ID:aurora-lzzp,项目名称:Aurora-Weather,代码行数:38,代码来源:ThunderGenerator.cs


示例15: DrawRectangle

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

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

            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;

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


示例16: Render

 /// <summary>
 /// Отрисовать.
 /// </summary>
 /// <param name="map">Карта расположений.</param>
 /// <param name="session">Сессия.</param>
 /// <param name="region">Регион.</param>
 /// <returns>Результат.</returns>
 public void Render(ITextRender2MeasureMap map, CanvasDrawingSession session, Rect region)
 {
     foreach (var line in map.GetMeasureMapLines())
     {
         if (map.MaxLines.HasValue)
         {
             if (line.LineNumber >= map.MaxLines.Value)
             {
                 break;
             }
         }
         foreach (var element in line.GetMeasureMap())
         {
             var drawRect = new Rect(element.Placement, element.Size);
             var testRect = drawRect;
             testRect.Intersect(region);
             if (!testRect.IsEmpty)
             {
                 DrawElement(element, session, region);
             }
         }
     }
 }
开发者ID:Opiumtm,项目名称:DvachBrowser3,代码行数:30,代码来源:Direct2DTextRender2Renderer.cs


示例17: DrawElement

 private void DrawElement(TextRender2MeasureMapElement element, CanvasDrawingSession session, Rect region)
 {
     var command = element.Command;
     string text;
     var textCnt = command.Content as ITextRenderTextContent;
     if (textCnt != null)
     {
         text = textCnt.Text ?? "";
     }
     else
     {
         text = "";
     }
     using (var format = new CanvasTextFormat())
     {
         format.FontFamily = "Segoe UI";
         format.FontSize = (float)Callback.PostFontSize;
         format.WordWrapping = CanvasWordWrapping.NoWrap;
         format.TrimmingGranularity = CanvasTextTrimmingGranularity.None;
         format.HorizontalAlignment = CanvasHorizontalAlignment.Left;
         session.DrawText(text, new Vector2((float)element.Placement.X, (float)element.Placement.Y), Colors.Black, format);
     }
 }
开发者ID:Opiumtm,项目名称:DvachBrowser3,代码行数:23,代码来源:Direct2DTextRender2Renderer.cs


示例18: DrawTeapot

        void DrawTeapot(ICanvasAnimatedControl sender, CanvasDrawingSession drawingSession)
        {
            Vector2 size = sender.Size.ToVector2();

            // Draw some text (using Win2D) to make sure this appears behind the teapot.
            if (!ThumbnailGenerator.IsDrawingThumbnail)
            {
                drawingSession.DrawText("Text drawn before the teapot", size * new Vector2(0.5f, 0.1f), Colors.Gray);
            }

            // Draw the teapot (using Direct3D).
            teapot.SetWorld(Matrix4x4.CreateFromYawPitchRoll(-spinTheTeapot, spinTheTeapot / 23, spinTheTeapot / 42));
            teapot.SetView(Matrix4x4.CreateLookAt(new Vector3(1.5f, 1, 0), Vector3.Zero, Vector3.UnitY));
            teapot.SetProjection(Matrix4x4.CreatePerspectiveFieldOfView(1, size.X / size.Y, 0.1f, 10f));

            teapot.Draw(drawingSession);

            // Draw more text (using Win2D) to make sure this appears above the teapot.
            if (!ThumbnailGenerator.IsDrawingThumbnail)
            {
                drawingSession.DrawText("\nText drawn after the teapot", size * new Vector2(0.5f, 0.1f), Colors.Gray);
            }
        }
开发者ID:jiatingxiu,项目名称:Win2D,代码行数:23,代码来源:Direct3DInteropExample.xaml.cs


示例19: DrawForegroundText

 private void DrawForegroundText(CanvasDrawingSession ds)
 {
     if (showTextLabels && !ThumbnailGenerator.IsDrawingThumbnail)
     {
         textFormat.VerticalAlignment = CanvasVerticalAlignment.Bottom;
         textFormat.HorizontalAlignment = CanvasHorizontalAlignment.Right;
         ds.DrawText("Dry Ink Foreground", new Vector2((float)canvasControl.Size.Width - 10, (float)canvasControl.Size.Height - 10), Colors.DarkGoldenrod, textFormat);
     }
 }
开发者ID:SarahAnnTolsma,项目名称:Win2D,代码行数:9,代码来源:InkExample.xaml.cs


示例20: DrawBackgroundText

 private void DrawBackgroundText(CanvasDrawingSession ds)
 {
     if (showTextLabels && !ThumbnailGenerator.IsDrawingThumbnail)
     {
         textFormat.VerticalAlignment = CanvasVerticalAlignment.Top;
         textFormat.HorizontalAlignment = CanvasHorizontalAlignment.Left;
         ds.DrawText("Dry Ink Background", new Vector2(10, 10), Colors.DarkGray, textFormat);
     }
 }
开发者ID:SarahAnnTolsma,项目名称:Win2D,代码行数:9,代码来源:InkExample.xaml.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Http.HttpClient类代码示例发布时间:2022-05-26
下一篇:
C# DependencyInjection.ServiceCollection类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap