Пример #1
0
        private static void DrawTextOverWhiteRectangle(CanvasDrawingSession ds, Vector2 paddedTopLeft, CanvasTextLayout textLayout)
        {
            var bounds = textLayout.LayoutBounds;

            var rect = new Rect(bounds.Left + paddedTopLeft.X, bounds.Top + paddedTopLeft.Y, bounds.Width, bounds.Height);

            ds.FillRectangle(rect, Colors.White);
            ds.DrawTextLayout(textLayout, paddedTopLeft, Colors.Black);
        }
 public void drawText(CanvasDrawingSession ds, Color color)
 {
     ds.DrawTextLayout(textLayout, (float)location.X, (float)location.Y, color);
 }
Пример #3
0
        private void DoEffect(CanvasDrawingSession ds, Size size, float amount)
        {
            size.Width = size.Width - ExpandAmount;
            size.Height = size.Height - ExpandAmount;

            var offset = (float)(ExpandAmount / 2);           

            using (var textLayout = CreateTextLayout(ds, size))
            using (var textCommandList = new CanvasCommandList(ds))
            {
                using (var textDs = textCommandList.CreateDrawingSession())
                {                     
                    textDs.DrawTextLayout(textLayout, 0, 0, GlowColor);
                }

                glowEffectGraph.Setup(textCommandList, amount);
                ds.DrawImage(glowEffectGraph.Output, offset, offset);

                ds.DrawTextLayout(textLayout, offset, offset, TextColor);
            }
        }
Пример #4
0
            public void Draw(CanvasDrawingSession ds, int frameCounter, float width, float height)
            {
                ++frameCounter;
                float opacity = (float)(Math.Sin(frameCounter * 0.05) + 1) / 2;

                DoTest(opacity, ignoreSource, premultipliedTarget[0]);
                DoTest(opacity, ignoreSource, ignoreTarget[0]);
                DoTest(opacity, premultipliedSource, premultipliedTarget[1]);
                DoTest(opacity, premultipliedSource, ignoreTarget[1]);

                float halfWidth = width / 2;
                var premultipliedToIgnoreLabel = MakeLabel(ds, "Draw Premultiplied to Ignore", halfWidth);
                var premultipliedToPremultipliedLabel = MakeLabel(ds, "Draw Premultiplied to Premultiplied", halfWidth);
                var ignoreToIgnoreLabel = MakeLabel(ds, "Draw Ignore to Ignore", halfWidth);
                var ignoreToPremultipliedLabel = MakeLabel(ds, "Draw Ignore to Premultiplied", halfWidth);

                var totalHeight = 64 * 8.0f;

                float middle = width / 2;

                float imageX = middle + 10;
                float textRight = middle - 10;

                float y = (height / 2) - (totalHeight / 2);
                float ydiff = 64.0f * 2.0f;

                ds.DrawImage(premultipliedTarget[0], imageX, y);
                ds.DrawTextLayout(premultipliedToPremultipliedLabel, 0, y, Colors.White);
                y += ydiff;

                ds.DrawImage(ignoreTarget[0], imageX, y);
                ds.DrawTextLayout(premultipliedToIgnoreLabel, 0, y, Colors.White);
                y += ydiff;

                ds.DrawImage(premultipliedTarget[1], imageX, y);
                ds.DrawTextLayout(ignoreToPremultipliedLabel, 0, y, Colors.White);
                y += ydiff;

                ds.DrawImage(ignoreTarget[1], imageX, y);
                ds.DrawTextLayout(ignoreToIgnoreLabel, 0, y, Colors.White);
                y += ydiff;
            }
        private void DrawTextWithBackground(CanvasDrawingSession ds, CanvasTextLayout layout, double x, double y)
        {
            var backgroundRect = layout.LayoutBounds;
            backgroundRect.X += x;
            backgroundRect.Y += y;

            backgroundRect.X -= 20;
            backgroundRect.Y -= 20;
            backgroundRect.Width += 40;
            backgroundRect.Height += 40;

            ds.FillRectangle(backgroundRect, Colors.White);
            ds.DrawTextLayout(layout, (float)x, (float)y, Colors.Black);
        }