Beispiel #1
0
 public void RenderText(string text, Vector point)
 {
     session?.DrawText(text,
                       new ToVector2Adapter(point),
                       HexToColor("#ffdff9fb")
                       );
 }
Beispiel #2
0
        public static void DrawText(this CanvasDrawingSession session, string text, float x, float y, Paint paint)
        {
            CanvasTextFormat textFormat = null;

            if (paint.TextSize is float textSize)
            {
                textFormat          = new CanvasTextFormat();
                textFormat.FontSize = textSize;
            }
            if (paint.TextAlignment is CanvasHorizontalAlignment textAlignmnet)
            {
                textFormat = textFormat ?? new CanvasTextFormat();
                textFormat.HorizontalAlignment = textAlignmnet;
            }

            session.DrawText(text, x, y, paint.Color, textFormat);
            textFormat?.Dispose();
        }
        protected void DrawMaxValue(CanvasControl sender, CanvasDrawingSession ds)
        {
            string  format = "{0:F" + string.Format("{0:F0}", this.Resolution) + "}";
            double  radian = RadiansFromDegrees(c_endAngle);
            float   atX    = (float)(Math.Cos(radian) * (this.Radius - 1 * c_arcThickness)) + Center.X - 2;
            float   atY    = (float)(Math.Sin(radian) * (this.Radius - 1 * c_arcThickness)) + Center.Y;
            Vector2 at     = new Vector2(atX, atY);

            using (var textFormat = new CanvasTextFormat()
            {
                HorizontalAlignment = CanvasHorizontalAlignment.Right,
                VerticalAlignment = CanvasVerticalAlignment.Center,
                FontSize = (float)this.LabelsFontSize
            })
            {
                ds.DrawText(string.Format(format, this.MaxValue), at, this.GaugeColor, textFormat);
            }
        }
        void Draw(CanvasDrawingSession drawingSession, string text, Size size)
        {
            // Background gradient.
            using (var brush = CanvasRadialGradientBrush.CreateRainbow(drawingSession, 0))
            {
                brush.Center = size.ToVector2() / 2;

                brush.RadiusX = (float)size.Width;
                brush.RadiusY = (float)size.Height;

                drawingSession.FillRectangle(0, 0, (float)size.Width, (float)size.Height, brush);
            }

            // Text label.
            var label = string.Format("{0}\n{1:0} x {2:0}", text, size.Width, size.Height);

            drawingSession.DrawText(label, size.ToVector2() / 2, Colors.Black, textLabelFormat);
        }
        static void DrawTile(CanvasDrawingSession ds, float width, float height)
        {
            using (var cl = new CanvasCommandList(ds))
            {
                using (var clds = cl.CreateDrawingSession())
                {
                    var text = string.Format("{0}\n{1}", DateTime.Now.ToString("ddd"), DateTime.Now.ToString("HH:mm"));

                    var textFormat = new CanvasTextFormat()
                    {
                        FontFamily          = "Segoe UI Black",
                        HorizontalAlignment = CanvasHorizontalAlignment.Right,
                        VerticalAlignment   = CanvasVerticalAlignment.Center,
                        FontSize            = 20,
                        LineSpacing         = 20
                    };

                    clds.DrawText(text, 0, 0, Colors.White, textFormat);
                }

                var effect = new GaussianBlurEffect()
                {
                    Source     = cl,
                    BlurAmount = 1,
                };

                ds.Clear(Colors.Orange);

                var bounds     = effect.GetBounds(ds);
                var ratio      = bounds.Height / bounds.Width;
                var destHeight = height * ratio;

                ds.DrawImage(effect, new Rect(0, height / 2 - destHeight / 2, width, destHeight), bounds);

                ds.DrawText(string.Format("Generated by Win2D\n{0}\n{1}", DateTime.Now.ToString("d"), DateTime.Now.ToString("t")),
                            12, 12, Colors.Black,
                            new CanvasTextFormat()
                {
                    HorizontalAlignment = CanvasHorizontalAlignment.Left,
                    VerticalAlignment   = CanvasVerticalAlignment.Top,
                    FontSize            = 12
                });
            }
        }
        protected void unitsControl_Draw(CanvasControl sender, CanvasDrawEventArgs args)
        {
            this.EnsureResources(sender, args);
            CanvasDrawingSession ds = args.DrawingSession;

            float   atX = (float)sender.ActualWidth / 2;
            float   atY = 0;
            Vector2 at  = new Vector2(atX, atY);

            using (var textFormat = new CanvasTextFormat()
            {
                HorizontalAlignment = CanvasHorizontalAlignment.Center,
                VerticalAlignment = CanvasVerticalAlignment.Top,
                FontSize = (float)this.UnitsFontSize,
            })
            {
                ds.DrawText(this.Units, at, this.GaugePointerColor, textFormat);
            }
        }
Beispiel #7
0
        protected override void DrawAbstractModification(ref ICanvasImage bitmap, CanvasDrawingSession draw)
        {
            base.DrawAbstractModification(ref bitmap, draw);

            //Debugging information about characters
            if (Utility.SettingsLoad <bool>("debug") && this is IAngle)
            {
                //Current angle in degrees
                draw.DrawText
                (
                    (int)(this as IAngle).Angle + "°"
                    , new System.Numerics.Vector2(X + (float)Width - 30, Y + (float)Height / 2)
                    , Colors.FloralWhite
                );
            }

            //Draws a healthbar above the character
            DrawHealthbar(draw);
        }
Beispiel #8
0
        private void PaintHint(CanvasDrawingSession ds, CanvasBitmap hintField, int x, int y)
        {
            ds.DrawImage(hintField, x, y);

            var hintText         = GameInstance.Level.Hint;
            int fontSize         = hintText.Length > 83 ? 14 : 16;
            var rect             = new Rect(x + 4, y + 4, hintField.Size.Width - 8, hintField.Size.Height - 8);
            var canvasTextFormat = new CanvasTextFormat
            {
                FontStyle           = FontStyle.Italic,
                FontWeight          = FontWeights.Bold,
                FontFamily          = "Arial",
                FontSize            = fontSize,
                HorizontalAlignment = CanvasHorizontalAlignment.Center
            };

            ds.TextAntialiasing = CanvasTextAntialiasing.Aliased;
            ds.DrawText("Hint: " + hintText, rect, Colors.Aqua, canvasTextFormat);
        }
Beispiel #9
0
        private void ShowEmoji(int idx, string emoji)
        {
            SSD1603          display = idx == 0 ? _displaySpi : _displayI2c;
            CanvasTextFormat fmt     = idx == 0 ? _fmtBg : _fmtSm;

            if (display != null && display.State == SSD1603.States.Ready)
            {
                //draw
                using (CanvasDrawingSession ds = display.Render.CreateDrawingSession())
                {
                    ds.Antialiasing     = CanvasAntialiasing.Aliased;
                    ds.TextAntialiasing = CanvasTextAntialiasing.Aliased;
                    ds.Clear(SSD1603.BackgroundColor);
                    ds.DrawText(emoji, 0, 0, SSD1603.ForeColor, fmt);
                }

                Debug.WriteLine("display " + emoji);
                display.Display();
            }
        }
Beispiel #10
0
        protected override void TextLines(
            CanvasDrawingSession drawingSession,
            CanvasTextFormat format)
        {
            format.FontSize = FontSize;
            for (var i = 0; i < Lines.Length; i++)
            {
                if (i == Index)
                {
                    format.FontWeight = FontWeights.Bold;
                }
                else
                {
                    format.FontWeight = FontWeights.Normal;
                }

                var position = TextPosition + new Vector2(0.0f, i * LineHeight);
                drawingSession.DrawText(Lines[i], position, TextColor, format);
            }
        }
        protected void valueControl_Draw(CanvasControl sender, CanvasDrawEventArgs args)
        {
            this.EnsureResources(sender, args);
            CanvasDrawingSession ds = args.DrawingSession;

            string  format = "{0:F" + string.Format("{0:F0}", this.Resolution) + "}";
            float   atX    = (float)sender.ActualWidth / 2;
            float   atY    = (float)sender.ActualHeight;
            Vector2 at     = new Vector2(atX, atY);

            using (var textFormat = new CanvasTextFormat()
            {
                HorizontalAlignment = CanvasHorizontalAlignment.Center,
                VerticalAlignment = CanvasVerticalAlignment.Bottom,
                FontSize = (float)this.ValueFontSize,
            })
            {
                ds.DrawText(string.Format(format, this.Value), at, this.GaugePointerColor, textFormat);
            }
        }
Beispiel #12
0
        protected void MaxValueControl_Draw(CanvasControl sender, CanvasDrawEventArgs args)
        {
            this.EnsureResources(sender, args);
            CanvasDrawingSession ds = args.DrawingSession;

            float   xRight = (float)(sender.ActualWidth * _gaugeGridWidth);
            float   center = xRight - (c_gaugeWidth / 2);
            Vector2 at     = new Vector2(center, (float)sender.ActualHeight);
            string  format = "{0:F" + string.Format("{0:F0}", this.Resolution) + "}";

            using (var textFormat = new CanvasTextFormat()
            {
                HorizontalAlignment = CanvasHorizontalAlignment.Center,
                VerticalAlignment = CanvasVerticalAlignment.Bottom,
                FontSize = (float)this.LabelsFontSize,
            })
            {
                ds.DrawText(string.Format(format, this.MaxValue), at, this.GaugeColor, textFormat);
            }
        }
Beispiel #13
0
        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
            });
        }
Beispiel #14
0
        private void canvas_CreateResources(CanvasAnimatedControl sender, CanvasCreateResourcesEventArgs args)
        {
            CanvasCommandList cl = new CanvasCommandList(sender);

            using (CanvasDrawingSession clds = cl.CreateDrawingSession())
            {
                for (int i = 0; i < 100; i++)
                {
                    clds.DrawText("Hello, World!", RndPosition(), Color.FromArgb(255, RndByte(), RndByte(), RndByte()));
                    clds.DrawCircle(RndPosition(), RndRadius(), Color.FromArgb(255, RndByte(), RndByte(), RndByte()));
                    clds.DrawLine(RndPosition(), RndPosition(), Color.FromArgb(255, RndByte(), RndByte(), RndByte()));
                }
            }

            blur = new GaussianBlurEffect()
            {
                Source     = cl,
                BlurAmount = 10.0f
            };
        }
Beispiel #15
0
        //CanvasControl raises Draw whenever your app needs to draw or redraw its content.
        private void canvas_Draw(Microsoft.Graphics.Canvas.UI.Xaml.CanvasControl sender, Microsoft.Graphics.Canvas.UI.Xaml.CanvasDrawEventArgs args)
        {
            CanvasCommandList cl = new CanvasCommandList(sender);

            using (CanvasDrawingSession clds = cl.CreateDrawingSession())
            {
                for (int i = 0; i < 100; i++)
                {
                    clds.DrawText("Hello, World!", RndPosition(), Color.FromArgb(255, RndByte(), RndByte(), RndByte()));
                    clds.DrawCircle(RndPosition(), RndRadius(), Color.FromArgb(255, RndByte(), RndByte(), RndByte()));
                    clds.DrawLine(RndPosition(), RndPosition(), Color.FromArgb(255, RndByte(), RndByte(), RndByte()));
                }
            }

            GaussianBlurEffect blur1 = new GaussianBlurEffect();

            blur1.Source     = cl;
            blur1.BlurAmount = 10.0f;
            args.DrawingSession.DrawImage(blur1);
        }
Beispiel #16
0
        public void draw(CanvasDrawingSession ds)
        {
            //  Draw the head
            ds.FillCircle(Vector.Create(0.5, 0), 0.33f, drawColor);
            //  Draw the body
            //  Draw the body outline
            var c = showNumber == DancerNumbers.OFF || gender == Gender.PHANTOM ? fillColor : fillColor.veryBright();

            switch (gender)
            {
            case Gender.BOY:
                ds.FillRectangle(-0.5f, -0.5f, 1, 1, c);
                ds.DrawRectangle(-0.5f, -0.5f, 1, 1, drawColor, 0.1f);
                break;

            case Gender.GIRL:
                ds.FillCircle(Vector.Create(0, 0), 0.5f, c);
                ds.DrawCircle(Vector.Create(0, 0), 0.5f, drawColor, 0.1f);
                break;

            default: // phantom
                ds.FillRoundedRectangle(-0.5f, -0.5f, 1, 1, 0.3f, 0.3f, c);
                ds.DrawRoundedRectangle(-0.5f, -0.5f, 1, 1, 0.3f, 0.3f, drawColor, 0.1f);
                break;
            }
            //  Draw number if on
            if (showNumber != DancerNumbers.OFF)
            {
                //  The dancer is rotated relative to the display, but of course
                //  the dancer number should not be rotated.
                //  So the number needs to be transformed back
                var angle  = Math.Atan2(ds.Transform.M21, ds.Transform.M22);
                var txtext = Matrix.CreateScale(1, -1) * Matrix.CreateRotation(-angle + Math.PI); // * Matrix.CreateScale(1, -1);
                ds.Transform = txtext * ds.Transform;
                var font = new CanvasTextFormat();
                font.FontSize            = 0.8f;
                font.VerticalAlignment   = CanvasVerticalAlignment.Center;
                font.HorizontalAlignment = CanvasHorizontalAlignment.Center;
                ds.DrawText(showNumber == DancerNumbers.COUPLES ? number_couple : number, 0f, 0f, Colors.Black, font);
            }
        }
Beispiel #17
0
        static void DrawFaceInCenterOfGeometry(CanvasDrawingSession ds, CanvasGeometry geom)
        {
            if (geom == null)
            {
                return;
            }

            var bounds  = geom.ComputeBounds();
            var centerX = bounds.X + bounds.Width / 2;
            var centerY = bounds.Y + bounds.Height / 2;

            var center = new Vector2((float)centerX, (float)centerY);

            ds.DrawText("ಠ⌣ಠ", center, Colors.White,
                        new CanvasTextFormat()
            {
                FontSize           = 36,
                ParagraphAlignment = ParagraphAlignment.Center,
                VerticalAlignment  = CanvasVerticalAlignment.Center
            });
        }
Beispiel #18
0
            protected override void DoDraw(CanvasDrawingSession ds)
            {
                var weight       = Weight;
                var normalWeight = Normalize(weight) * 5;

                ds.DrawLine(new Vector2(From.Location.X + From.Radius, From.Location.Y),
                            new Vector2(To.Location.X - To.Radius, To.Location.Y), weight < 0d ? Colors.Red : Colors.Blue, (float)normalWeight);

                if (ShowToolTip)
                {
                    ds.DrawText(
                        Weight.ToString(),
                        ToolTipPosition, Colors.Black,
                        new CanvasTextFormat()
                    {
                        HorizontalAlignment = CanvasHorizontalAlignment.Center,
                        VerticalAlignment   = CanvasVerticalAlignment.Center,
                        FontSize            = 11
                    });
                }
            }
Beispiel #19
0
        //CreateResources is an event that is fired only when Win2D determines you need to recreate your visual resources, such as when the page is loaded.
        private void canvas_CreateResources(Microsoft.Graphics.Canvas.UI.Xaml.CanvasAnimatedControl sender, Microsoft.Graphics.Canvas.UI.CanvasCreateResourcesEventArgs args)
        {
            CanvasCommandList cl = new CanvasCommandList(sender);

            using (CanvasDrawingSession clds = cl.CreateDrawingSession())
            {
                for (int i = 0; i < 100; i++)
                {
                    clds.DrawText("Hello, World!", RndPosition(), Color.FromArgb(255, RndByte(), RndByte(), RndByte()));
                    clds.DrawCircle(RndPosition(), RndRadius(), Color.FromArgb(255, RndByte(), RndByte(), RndByte()));
                    clds.DrawLine(RndPosition(), RndPosition(), Color.FromArgb(255, RndByte(), RndByte(), RndByte()));
                }
            }

            blur = new GaussianBlurEffect()
            {
                Source     = cl,
                BlurAmount = 10.0f
            };

            System.Diagnostics.Debug.WriteLine("Create" + ">>>" + j++);
        }
Beispiel #20
0
        private void DrawProgression(CanvasDrawingSession drawingSession, Size size, Rect relativeDestination)
        {
            var absoluteDestination = GetAbsoluteDestinationRect(size, relativeDestination);

            DrawTextPosition(drawingSession, _elevationTransform, _elevationPoints, tp => tp.Coordinate.Elevation.ToString("# m"));
            DrawTextPosition(drawingSession, _speedTransform, _speedPoints, tp => tp.Speed.ToString("# km/h"));
            DrawTextPosition(drawingSession, _cadenceTransform, _candencePoints, tp => tp.Cadence.ToString("0 tr/m"));

            var x = (float)(absoluteDestination.Left + _progression * absoluteDestination.Width);

            drawingSession.DrawLine(new Vector2(x, (float)absoluteDestination.Top), new Vector2(x, (float)absoluteDestination.Bottom), Colors.White, 2);

            // Distance
            var totalDistance = trackpoints[trackpoints.Length - 1].AccumulatedDistance.SiValue;
            var distanceKm    = _progression * totalDistance / 1000;

            var whiteBrush = new CanvasSolidColorBrush(drawingSession, Colors.White);

            var position = new Vector2(x + 10, (float)absoluteDestination.Top);

            drawingSession.DrawText(distanceKm.ToString("#.## km"), position, whiteBrush, new CanvasTextFormat());
        }
        private void DrawCanvasState(CanvasControl canvas, CanvasDrawingSession ds, int drawCount)
        {
            Vector2 size = canvas.Size.ToVector2();

            ds.DrawLine(Vector2.Zero, size, Colors.Aqua);
            ds.DrawLine(0, size.Y, size.X, 0, Colors.Aqua);

            if (!ThumbnailGenerator.IsDrawingThumbnail)
            {
                var text = string.Format("{0}x{1}\n{2} redraws", size.X, size.Y, drawCount);

                ds.DrawText(
                    text,
                    0, 0,
                    Colors.FloralWhite,
                    new CanvasTextFormat()
                {
                    VerticalAlignment  = CanvasVerticalAlignment.Top,
                    ParagraphAlignment = ParagraphAlignment.Left,
                    FontSize           = 10
                });
            }
        }
Beispiel #22
0
            public void Draw(CanvasDrawingSession ds, Size screenSize)
            {
                var transform = CalculateGameToScreenTransform(screenSize);

                DrawBackground(ds, transform);

                foreach (var letter in letters)
                {
                    letter.Draw(ds, transform);
                }

                ds.Transform = Matrix3x2.Identity;

                if (!ThumbnailGenerator.IsDrawingThumbnail)
                {
                    string scoreText = string.Format("Score: {0}", score);
                    if (highScore != -1)
                    {
                        scoreText += string.Format(" ({0})", highScore);
                    }
                    ds.DrawText(scoreText, 0, 0, Colors.White, scoreFormat);
                }
            }
        protected void TitleControl_Draw(CanvasControl sender, CanvasDrawEventArgs args)
        {
            this.EnsureResources(sender, args);
            CanvasDrawingSession ds = args.DrawingSession;

            Vector2 at = new Vector2((float)sender.ActualWidth / 4, (float)sender.ActualHeight);

            using (var textFormat = new CanvasTextFormat()
            {
                HorizontalAlignment = CanvasHorizontalAlignment.Center,
                VerticalAlignment = CanvasVerticalAlignment.Bottom,
                FontSize = (float)this.TextFontSize,
            })
            {
                // If the text cannot fit into the first column, then push it to the right enough so that the left side of ther text is not cut off.
                Rect titleBoundingRectangle = Utilities.CalculateStringBoundingRectangle(sender, args, this.Text, textFormat);
                if (titleBoundingRectangle.Width > sender.ActualWidth / 2)
                {
                    at.X += (float)((titleBoundingRectangle.Width - sender.ActualWidth / 2F) / 2F);
                }

                ds.DrawText(this.Text, at, this.GaugeColor, textFormat);
            }
        }
Beispiel #24
0
        public void updateRepresentation()
        {
            //UpdateWidth();
            try
            {
                if (boundBox.Height > 0 && boundBox.Width > 0)
                {
                    CanvasDevice device = CanvasDevice.GetSharedDevice();

                    represent = new CanvasRenderTarget(device, (int)this.boundBox.Width, (int)this.boundBox.Height, 96);

                    using (CanvasDrawingSession g2d = represent.CreateDrawingSession())
                    {
                        g2d.Clear(Colors.Transparent);

                        g2d.Antialiasing = CanvasAntialiasing.Antialiased;

                        //int linesize = 5;

                        Color fillbrush = NodeColor;

                        if (hovered)
                        {
                            fillbrush = Colors.Black;
                        }

                        style.DrawStyle(g2d, NodeDrawingStyle, 0, 0, (int)boundBox.Width - 2, (int)boundBox.Height - 2, fillbrush, BorderColor, (int)(borderOffset * scale));

                        g2d.DrawText(text, 0, 0, TextColor, NodeTextStyle);
                    }
                }
            }
            catch (Exception e)
            {
            }
        }
Beispiel #25
0
        void DrawSourceGraphic(PerDeviceResources resources, CanvasDrawingSession ds, float offset)
        {
            var source = GetSourceBitmap(resources);

            if (source != null)
            {
                // We can either draw a precreated bitmap...
                ds.DrawImage(source, offset, offset);
            }
            else
            {
                // ... or directly draw some shapes.
                ds.FillRectangle(offset, offset, testSize, testSize, Colors.Gray);

                ds.DrawLine(offset, offset, offset + testSize, offset + testSize, Colors.Red);
                ds.DrawLine(offset + testSize, offset, offset, offset + testSize, Colors.Red);

                ds.DrawRectangle(offset + 0.5f, offset + 0.5f, testSize - 1, testSize - 1, Colors.Blue);

                ds.DrawText("DPI test", new Vector2(offset + testSize / 2), Colors.Blue, resources.TextFormat);

                resources.AddMessage("DrawingSession ->\n");
            }
        }
Beispiel #26
0
        public void DrawText(FormattedText formattedText, Point point, Rect?clipRect)
        {
            var text = formattedText.Text;

            var vector           = new System.Numerics.Vector2((float)point.X, (float)point.Y);
            var brush            = formattedText.Brush.ToWin2D(drawingSession);
            var canvasTextFormat = new CanvasTextFormat
            {
                FontSize   = formattedText.FontSize,
                FontWeight = formattedText.FontWeight.ToWin2D(),
                FontFamily = formattedText.FontName,
            };

            CanvasActiveLayer layer = null;

            if (clipRect != null)
            {
                layer = drawingSession.CreateLayer(new CanvasSolidColorBrush(drawingSession, Colors.Black.ToWin2D()), clipRect.Value.ToWin2D());
            }

            drawingSession.DrawText(text, vector, brush, canvasTextFormat);

            layer?.Dispose();
        }
Beispiel #27
0
        //Draw Wide Date Live Tile
        async Task ClockTileWideDate()
        {
            try
            {
                //Load Tile Render Variables
                if (!TileRenderVarsLoaded)
                {
                    CanvasHorizontalAlignment HorizontalAlignmentTime = CanvasHorizontalAlignment.Right;
                    switch (setDisplayHorizontalAlignmentTime)
                    {
                    case 1: { HorizontalAlignmentTime = CanvasHorizontalAlignment.Left; break; }

                    case 2: { HorizontalAlignmentTime = CanvasHorizontalAlignment.Center; break; }

                    case 3: { HorizontalAlignmentTime = CanvasHorizontalAlignment.Right; break; }
                    }

                    //Live tile font styles
                    Win2DCanvasTextFormatTitle = new CanvasTextFormat()
                    {
                        FontFamily = setLiveTileFont, FontWeight = Win2DFontWeightTitle, FontSize = 90 + setLiveTileFontSize, WordWrapping = CanvasWordWrapping.NoWrap, HorizontalAlignment = HorizontalAlignmentTime, VerticalAlignment = CanvasVerticalAlignment.Center, OpticalAlignment = CanvasOpticalAlignment.NoSideBearings
                    };
                    Win2DCanvasTextFormatBody = new CanvasTextFormat()
                    {
                        FontFamily = setLiveTileFont, FontWeight = Win2DFontWeightBody, FontSize = 90 + setLiveTileFontSize, WordWrapping = CanvasWordWrapping.NoWrap, HorizontalAlignment = HorizontalAlignmentTime, VerticalAlignment = CanvasVerticalAlignment.Center, OpticalAlignment = CanvasOpticalAlignment.NoSideBearings
                    };

                    if (setDisplayAMPMFont)
                    {
                        Win2DCanvasTextFormatSub = new CanvasTextFormat()
                        {
                            FontFamily = setLiveTileFont, FontWeight = Win2DFontWeightSub, FontSize = 38 + setLiveTileFontSize, WordWrapping = CanvasWordWrapping.NoWrap, HorizontalAlignment = CanvasHorizontalAlignment.Right, OpticalAlignment = CanvasOpticalAlignment.NoSideBearings
                        };
                    }
                    else
                    {
                        Win2DCanvasTextFormatSub = new CanvasTextFormat()
                        {
                            FontFamily = "Segoe UI", FontWeight = Win2DFontWeightSub, FontSize = 38 + setLiveTileFontSize, WordWrapping = CanvasWordWrapping.NoWrap, HorizontalAlignment = CanvasHorizontalAlignment.Right, OpticalAlignment = CanvasOpticalAlignment.NoSideBearings
                        };
                    }

                    Win2DCanvasTextFormatTextLeft = new CanvasTextFormat()
                    {
                        FontFamily = setLiveTileFont, FontWeight = Win2DFontWeightBody, FontSize = 67 + (setLiveTileFontSize / 2), WordWrapping = CanvasWordWrapping.NoWrap, HorizontalAlignment = CanvasHorizontalAlignment.Left, VerticalAlignment = CanvasVerticalAlignment.Bottom, OpticalAlignment = CanvasOpticalAlignment.NoSideBearings
                    };

                    //Live tile text positions
                    switch (setLiveTileFont)
                    {
                    case "Segoe UI": { TimeHeight1 = -82; break; }

                    case "/Assets/Fonts/Gothic720-Light.ttf#Gothic720 Lt BT": { TimeHeight1 = -90; break; }

                    case "/Assets/Fonts/HelveticaNeue-UltraLight.ttf#Helvetica Neue": { TimeHeight1 = -95; break; }

                    case "/Assets/Fonts/Existence-Light.ttf#Existence": { TimeHeight1 = -94; break; }

                    case "/Assets/Fonts/OneDay-Light.ttf#ONE DAY": { TimeHeight1 = -103; break; }

                    case "/Assets/Fonts/Pier-Regular.ttf#Pier Sans": { TimeHeight1 = -78; break; }

                    case "/Assets/Fonts/Panama-Light.ttf#Panama": { TimeHeight1 = -89; break; }

                    case "/Assets/Fonts/Bellota-Light.ttf#Bellota": { TimeHeight1 = -80; break; }

                    case "/Assets/Fonts/Nooa-Semiserif.ttf#Nooa Semiserif": { TimeHeight1 = -99; break; }

                    case "/Assets/Fonts/Modeka-Light.ttf#Modeka": { TimeHeight1 = -97; break; }

                    case "/Assets/Fonts/Rawengulk-Light.ttf#Rawengulk": { TimeHeight1 = -105; break; }

                    case "/Assets/Fonts/Dense-Regular.ttf#Dense": { TimeHeight1 = -101; break; }

                    case "/Assets/Fonts/DigitalDisplay.ttf#digital display tfb": { TimeHeight1 = -104; break; }
                    }
                    switch (setLiveTileFont)
                    {
                    case "Segoe UI": { BottomTextHeight1 = -1; break; }

                    case "/Assets/Fonts/Gothic720-Light.ttf#Gothic720 Lt BT": { BottomTextHeight1 = -9; break; }

                    case "/Assets/Fonts/HelveticaNeue-UltraLight.ttf#Helvetica Neue": { BottomTextHeight1 = -13; break; }

                    case "/Assets/Fonts/Existence-Light.ttf#Existence": { BottomTextHeight1 = -9; break; }

                    case "/Assets/Fonts/OneDay-Light.ttf#ONE DAY": { BottomTextHeight1 = -11; break; }

                    case "/Assets/Fonts/Pier-Regular.ttf#Pier Sans": { BottomTextHeight1 = -3; break; }

                    case "/Assets/Fonts/Panama-Light.ttf#Panama": { BottomTextHeight1 = -9; break; }

                    case "/Assets/Fonts/Bellota-Light.ttf#Bellota": { BottomTextHeight1 = 8; break; }

                    case "/Assets/Fonts/Nooa-Semiserif.ttf#Nooa Semiserif": { BottomTextHeight1 = -9; break; }

                    case "/Assets/Fonts/Modeka-Light.ttf#Modeka": { BottomTextHeight1 = -15; break; }

                    case "/Assets/Fonts/Rawengulk-Light.ttf#Rawengulk": { BottomTextHeight1 = -25; break; }

                    case "/Assets/Fonts/Dense-Regular.ttf#Dense": { BottomTextHeight1 = -23; break; }

                    case "/Assets/Fonts/DigitalDisplay.ttf#digital display tfb": { BottomTextHeight1 = -22; break; }
                    }

                    TileRenderVarsLoaded = true;
                }

                using (CanvasDrawingSession ds = Win2DCanvasRenderTarget.CreateDrawingSession())
                {
                    //Live tile content - Time
                    DrawTimeOnTileSolo(ds, 0, false, false);

                    //Live tile content - Left
                    ds.DrawText(TextAlarmClock + DisplayPosition1Text, LiveTilePadding, BottomTextHeight1, LiveTileWidth, LiveTileHeight, Win2DFontColorTrans, Win2DCanvasTextFormatTextLeft);
                }
                await ExportLiveTile();
            }
            catch { }
        }
Beispiel #28
0
        void DrawStuff(CanvasDrawingSession ds)
        {
            int horizontalLimit = (int)m_canvasControl.ActualWidth;
            int verticalLimit   = (int)m_canvasControl.ActualHeight;

            DrawnContentType drawnContentType = (DrawnContentType)m_drawnContentTypeCombo.SelectedValue;

            ds.Clear(NextRandomColor());

            Vector2 point;
            float   radiusX;
            float   radiusY;

            Random random = new Random();

            m_canvasSwapChainPanel.Visibility = Windows.UI.Xaml.Visibility.Collapsed;

            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.Rectangle_Filled:
                Point bound0 = NextRandomPoint(horizontalLimit, verticalLimit);
                Point bound1 = NextRandomPoint(horizontalLimit, verticalLimit);

                m_linearGradientBrush.StartPoint = bound0.ToVector2();
                m_linearGradientBrush.EndPoint   = bound1.ToVector2();

                ds.FillRectangle(
                    new Rect(bound0, bound1),
                    m_linearGradientBrush);

                break;

            case DrawnContentType.Ellipse_Fill:
                NextRandomEllipse(horizontalLimit, verticalLimit, out point, out radiusX, out radiusY);
                ds.FillEllipse(
                    point, radiusX, radiusY,
                    NextRandomColor());
                break;

            case DrawnContentType.Circle_Fill:
                ds.FillCircle(
                    NextRandomPoint(horizontalLimit, verticalLimit).ToVector2(),
                    100,
                    NextRandomColor());
                break;

            case DrawnContentType.Text:
                var p     = NextRandomPoint(horizontalLimit, verticalLimit);
                var x     = (float)p.X;
                var y     = (float)p.Y;
                var color = NextRandomColor();
                ds.DrawLine(new Vector2(x, 0), new Vector2(x, verticalLimit), color);
                ds.DrawLine(new Vector2(0, y), new Vector2(horizontalLimit, y), color);
                ds.DrawText(
                    "Centered",
                    p.ToVector2(),
                    color,
                    new CanvasTextFormat()
                {
                    FontSize           = 18,
                    VerticalAlignment  = CanvasVerticalAlignment.Center,
                    ParagraphAlignment = ParagraphAlignment.Center
                });

                var r = NextRandomRect(horizontalLimit, verticalLimit);
                ds.DrawRectangle(r, color);
                ds.DrawText(
                    m_quiteLongText,
                    r,
                    NextRandomColor(),
                    new CanvasTextFormat()
                {
                    FontFamily         = "Comic Sans MS",
                    FontSize           = 18,
                    ParagraphAlignment = ParagraphAlignment.Justify,
                    Options            = CanvasDrawTextOptions.Clip
                });
                break;

            case DrawnContentType.ImageBrush:
                if (m_bitmap_tiger != null)
                {
                    m_imageBrush.Image   = m_bitmap_tiger;
                    m_imageBrush.ExtendX = (CanvasEdgeBehavior)(m_random.Next(3));
                    m_imageBrush.ExtendY = (CanvasEdgeBehavior)(m_random.Next(3));
                    ds.FillRectangle(new Rect(0, 0, horizontalLimit, verticalLimit), m_imageBrush);
                }
                else
                {
                    DrawNoBitmapErrorMessage(ds, horizontalLimit / 2, verticalLimit / 2);
                }
                break;

            case DrawnContentType.OffscreenTarget:
                m_imageBrush.Image   = m_offscreenTarget;
                m_imageBrush.ExtendX = (CanvasEdgeBehavior)(m_random.Next(3));
                m_imageBrush.ExtendY = (CanvasEdgeBehavior)(m_random.Next(3));
                ds.FillRectangle(new Rect(0, 0, horizontalLimit, verticalLimit), m_imageBrush);
                break;

            case DrawnContentType.Gradients:
                Vector2 center = NextRandomPoint(horizontalLimit, verticalLimit).ToVector2();
                m_radialGradientBrush.Center = center;
                float radius = m_random.Next(horizontalLimit / 2);
                m_radialGradientBrush.OriginOffset = new Vector2(radius, radius);
                m_radialGradientBrush.RadiusX      = radius;
                m_radialGradientBrush.RadiusY      = radius;
                ds.FillCircle(center, radius, m_radialGradientBrush);

                Vector2 line0 = NextRandomPoint(horizontalLimit, verticalLimit).ToVector2();
                Vector2 line1 = NextRandomPoint(horizontalLimit, verticalLimit).ToVector2();
                m_linearGradientBrush.StartPoint = line0;
                m_linearGradientBrush.EndPoint   = line1;
                float thickness = m_random.Next(horizontalLimit / 2);
                ds.DrawLine(line0, line1, m_linearGradientBrush, thickness);
                break;

            case DrawnContentType.AlternateBitmapLoading:
                if (m_bitmap_colorGrids != null)
                {
                    Matrix3x2 scale = Matrix3x2.CreateScale(20);

                    ds.Transform = scale;
                    ds.DrawImage(m_bitmap_colorGrids[0]);

                    ds.Transform = scale * Matrix3x2.CreateTranslation(200, 0);
                    ds.DrawImage(m_bitmap_colorGrids[1]);

                    ds.Transform = scale * Matrix3x2.CreateTranslation(0, 200);
                    ds.DrawImage(m_bitmap_colorGrids[2]);
                }
                else
                {
                    DrawNoBitmapErrorMessage(ds, horizontalLimit / 2, verticalLimit / 2);
                }
                break;

            case DrawnContentType.SwapChainPanel:
                m_canvasSwapChainPanel.Visibility = Windows.UI.Xaml.Visibility.Visible;

                float swapChainWidth  = horizontalLimit * ((float)random.NextDouble() / 2 + 0.5f);
                float swapChainHeight = verticalLimit * ((float)random.NextDouble() / 2 + 0.5f);

                if (m_swapChain == null)
                {
                    m_swapChain = new CanvasSwapChain(ds, swapChainWidth, swapChainHeight);
                    m_canvasSwapChainPanel.SwapChain = m_swapChain;
                }
                else
                {
                    m_swapChain.ResizeBuffers(swapChainWidth, swapChainHeight);
                }

                using (CanvasDrawingSession panelDS = m_swapChain.CreateDrawingSession(NextRandomColor()))
                {
                    panelDS.DrawCircle(swapChainWidth / 2.0f, swapChainHeight / 2.0f, 100.0f, NextRandomColor(), 20.0f);
                }
                m_swapChain.Present();
                break;

            case DrawnContentType.Test_Scene0_Default:
                GeometryTestScene0.DrawGeometryTestScene(ds, TestSceneRenderingType.Default);
                break;

            case DrawnContentType.Test_Scene0_Wireframe:
                GeometryTestScene0.DrawGeometryTestScene(ds, TestSceneRenderingType.Wireframe);
                break;

            case DrawnContentType.Test_Scene1_Default:
                GeometryTestScene1.DrawGeometryTestScene(ds, TestSceneRenderingType.Default);
                break;

            case DrawnContentType.Test_Scene1_Randomized:
                GeometryTestScene1.DrawGeometryTestScene(ds, TestSceneRenderingType.Randomized);
                break;

            case DrawnContentType.Test_Scene1_Wireframe:
                GeometryTestScene1.DrawGeometryTestScene(ds, TestSceneRenderingType.Wireframe);
                break;

            default:
                System.Diagnostics.Debug.Assert(false);     // Unexpected
                break;
            }
        }
        public void Draw(CanvasAnimatedDrawEventArgs args, CanvasDrawingSession ds, float width, float height)
        {
            drawCount++;

            const int maxEntries = 120;
            updatesPerDraw.Enqueue(updatesThisDraw);
            while (updatesPerDraw.Count > maxEntries)
                updatesPerDraw.Dequeue();

            ds.Antialiasing = CanvasAntialiasing.Aliased;

            var barWidth = width / (float)maxEntries;

            const float heightPerUpdate = 10.0f;
            float barBottom = height * 0.25f;

            int maxUpdates = 0;
            int maxIndex = -1;

            int index = 0;
            foreach (int update in updatesPerDraw)
            {
                float barHeight = update * heightPerUpdate;
                Color color = Colors.Gray;
                if ((Math.Max(0, drawCount - maxEntries) + index) % 60 == 0)
                    color = Colors.White;

                ds.FillRectangle(barWidth * index, height - barHeight - barBottom, barWidth, barHeight + barBottom, color);

                if (update > maxUpdates)
                {
                    maxIndex = index;
                    maxUpdates = update;
                }
                index++;
            }

            if (maxUpdates > 0)
            {
                var y = height - maxUpdates * heightPerUpdate - barBottom;

                ds.DrawLine(0, y, width, y, Colors.White, 1, maxStroke);

                ds.DrawText(
                    maxUpdates.ToString(),
                    0, 
                    height - maxUpdates * heightPerUpdate - barBottom,
                    Colors.White,
                    new CanvasTextFormat()
                    {
                        FontSize = heightPerUpdate * 2,
                        HorizontalAlignment = CanvasHorizontalAlignment.Left,
                        VerticalAlignment = CanvasVerticalAlignment.Bottom
                    });
            }

            using (var textFormat = new CanvasTextFormat()
            {
                FontSize = width * 0.05f,
                HorizontalAlignment = CanvasHorizontalAlignment.Left,
                VerticalAlignment = CanvasVerticalAlignment.Top
            })
            {
                float y = 1;
                ds.DrawText("Updates per Draw", 1, y, Colors.White, textFormat);
                y += textFormat.FontSize * 2;

                textFormat.FontSize *= 0.6f;

                ds.DrawText(string.Format("{0} total updates", args.Timing.UpdateCount), 1, y, Colors.Red, textFormat);
                y += textFormat.FontSize * 1.2f;

                ds.DrawText(string.Format("{0} total draws", drawCount), 1, y, Colors.Green, textFormat);
            }

            updatesThisDraw = 0;
        }
            public void Draw(CanvasDrawingSession ds, Size screenSize)
            {
                var transform = CalculateGameToScreenTransform(screenSize);

                DrawBackground(ds, transform);

                foreach (var letter in letters)
                {
                    letter.Draw(ds, transform);
                }

                ds.Transform = Matrix3x2.Identity;

                if (!ThumbnailGenerator.IsDrawingThumbnail)
                {
                    string scoreText = string.Format("Score: {0}", score);
                    if (highScore != -1)
                    {
                        scoreText += string.Format(" ({0})", highScore);
                    }
                    ds.DrawText(scoreText, 0, 0, Colors.White, scoreFormat);
                }
            }
Beispiel #31
0
        public async Task <Point> DrawQuote(CanvasDrawingSession ds, CanvasDevice device, CanvasBitmap canvasBitmap, Point drawPoint)
        {
            if (!SettingsHelper.GetSetting <bool>(SettingKey.IsDisplayQuote.ToString()))
            {
                return(drawPoint);
            }

            if (SettingsHelper.GetSetting <bool>(SettingKey.IsOfflineQuote.ToString()))
            {
                if (OfflineQuote == null)
                {
                    return(new Point(0, 0));
                }
                Quote.QuoteString = "\"" + OfflineQuote + "\"";
                Quote.Author      = "- " + OfflineAuthor;
            }
            else
            {
                await GetRandomQuote();
            }

            Size screenSize = SettingManager.GetWindowsResolution();

            //Qoute rect coordinate
            //X: 5.5 of 10
            //Y: 8 of 10
            //width: 4.35 of 10
            //heigh: depend

            Rect quoteRect = new Rect(0, 0, 0, 0)
            {
                X     = (screenSize.Width / 10) * 5.5,
                Width = (screenSize.Width / 10) * 4.35,
                Y     = (screenSize.Height / 10) * 8
            };

            Rect creditRect = new Rect(0, 0, 0, 0);

            CanvasTextFormat textFormat = new CanvasTextFormat
            {
                WordWrapping = CanvasWordWrapping.WholeWord,
                FontFamily   = "Segoe UI Light",
                FontSize     = (float)(screenSize.Height * 4.5 / 100)
            };

            Rect quoteSize = BitmapHelper.TextRect(Quote.QuoteString, textFormat, ds, quoteRect.Width, 200);


            Rect creditSize = BitmapHelper.TextRect(Quote.Author, textFormat, ds, quoteRect.Width);

            creditRect.X = quoteRect.X;
            var distanceToEnd = screenSize.Width - creditRect.X;

            if (creditSize.Width + quoteSize.Width <= distanceToEnd)
            {
                creditRect.X = quoteRect.X + quoteRect.Width * 1 / 2;
            }
            else
            {
                creditRect.X = screenSize.Width - creditSize.Width - screenSize.Height * 2.2 / 100;
            }

            creditRect.Y      = quoteRect.Y;
            creditRect.Width  = creditSize.Width;
            creditRect.Height = creditSize.Height;
            var tempSpace = screenSize.Width - (screenSize.Width / 10 * 5.5 - screenSize.Height * 1.3 / 100)
                            - (creditRect.X + creditRect.Width - quoteRect.X + screenSize.Height * 2.5 / 100);
            double tempX = quoteRect.X, temp;

            if (drawPoint.X == 0)
            {
                tempX = screenSize.Height * 1.3 / 100 + tempSpace;
            }

            if (Math.Abs(drawPoint.X - screenSize.Width / 2) < 0.5)
            {
                var haftWidth = (creditRect.X + creditRect.Width - quoteRect.X + screenSize.Height * 2.5 / 100) / 2;
                tempX = screenSize.Width / 2 - haftWidth - (screenSize.Height * 1.3 / 100) / 2;
            }

            if (drawPoint.Y >= screenSize.Height)
            {
                var tempHeight = creditSize.Height + screenSize.Height * 4 / 100;
                var tempSpace1 = drawPoint.Y > screenSize.Height ? drawPoint.Y - screenSize.Height - tempHeight : screenSize.Height - tempHeight - screenSize.Height * 3 / 100;
                var temp1      = quoteRect.Y - tempSpace1;
                quoteRect.Y  -= temp1;
                creditRect.Y -= temp1;
            }
            else
            {
                var tempHeight = quoteSize.Height + screenSize.Height / 100;
                var newY       = drawPoint.Y + tempHeight;
                quoteRect.Y  = newY;
                creditRect.Y = newY;
            }

            if (BitmapHelper.IsBrightArea(canvasBitmap,
                                          (int)(tempX - screenSize.Height * 1.3 / 100),
                                          (int)(quoteRect.Y - quoteSize.Height - screenSize.Height * 1.3 / 100),
                                          (int)(creditRect.X + creditRect.Width - quoteRect.X + screenSize.Height * 2.5 / 100),
                                          (int)(quoteSize.Height + creditSize.Height + screenSize.Height * 3.7 / 100)))
            {
                ds.FillRoundedRectangle(
                    new Rect((int)(tempX - screenSize.Height * 1.3 / 100),
                             (int)(quoteRect.Y - quoteSize.Height - screenSize.Height * 1.3 / 100),
                             (int)(creditRect.X + creditRect.Width - quoteRect.X + screenSize.Height * 2.5 / 100),
                             (int)(quoteSize.Height + creditSize.Height + screenSize.Height * 3.7 / 100)), 20, 20,
                    new CanvasSolidColorBrush(device, Colors.Black)
                {
                    Opacity = 0.4F
                });
            }

            //Draw the credit

            if (quoteSize.Height > creditSize.Height)
            {
                temp        = quoteRect.X - tempX;
                quoteRect.X = tempX;
                ds.DrawText(Quote.QuoteString, quoteRect, Colors.White, new CanvasTextFormat
                {
                    FontSize            = (float)(screenSize.Height * 4.5 / 100),
                    FontFamily          = "Segoe UI Light",
                    FontWeight          = FontWeights.Thin,
                    VerticalAlignment   = CanvasVerticalAlignment.Bottom,
                    HorizontalAlignment = CanvasHorizontalAlignment.Center
                });
            }
            else
            {
                temp        = quoteRect.X - tempX;
                quoteRect.X = tempX;
                ds.DrawText(Quote.QuoteString, quoteRect, Colors.White, new CanvasTextFormat
                {
                    FontSize            = (float)(screenSize.Height * 4.5 / 100),
                    FontFamily          = "Segoe UI Light",
                    FontWeight          = FontWeights.Thin,
                    VerticalAlignment   = CanvasVerticalAlignment.Top,
                    HorizontalAlignment = CanvasHorizontalAlignment.Left
                });
            }
            creditRect.X -= temp;
            ds.DrawText(Quote.Author, creditRect, Colors.White, new CanvasTextFormat
            {
                FontSize            = (float)(screenSize.Height * 4.5 / 100),
                FontFamily          = "Segoe UI Light",
                FontWeight          = FontWeights.Thin,
                FontStyle           = FontStyle.Oblique,
                HorizontalAlignment = CanvasHorizontalAlignment.Left,
            });

            if (drawPoint.Y >= screenSize.Height)
            {
                var tempY = quoteRect.Y - quoteSize.Height - screenSize.Height / 100;
                if (tempY + screenSize.Height <= screenSize.Height * 2)
                {
                    return(new Point(drawPoint.X, tempY + screenSize.Height));
                }
                return(new Point(-1, -1));
            }
            else
            {
                var tempY = quoteRect.Y - quoteSize.Height - screenSize.Height / 100 + quoteSize.Height + creditSize.Height + screenSize.Height * 4 / 100;
                if (tempY <= screenSize.Height)
                {
                    return(new Point(drawPoint.X, tempY));
                }
                return(new Point(-1, -1));
            }
        }
            private void DrawBackground(CanvasDrawingSession ds, Matrix3x2 transform)
            {
                const int levelUpTime = 60;

                // After levelling up we flash the screen white for a bit
                Color normalColor = Colors.Blue;
                Color levelUpFlashColor = Colors.White;

                var flashAmount = Math.Min(1, (leveledUpTimer / (float)levelUpTime));

                ds.Clear(InterpolateColors(normalColor, levelUpFlashColor, flashAmount));

                var topLeft = Vector2.Transform(new Vector2(0, 0), transform);
                var bottomRight = Vector2.Transform(new Vector2(1, 1), transform);

                var middle = (bottomRight.X - topLeft.X) / 2 + topLeft.X;

                // and display some text to let the player know what happened
                if (leveledUpTimer < levelUpTime * 2)
                {
                    ds.DrawText("Level Up!", middle, 0, Colors.White, levelUpFormat);
                }

                // Draw some lines to show where the top / bottom of the play area is.
                var topLine = topLeft.Y - Letter.TextFormat.FontSize;
                var bottomLine = bottomRight.Y + Letter.TextFormat.FontSize;

                Color lineColor = levelUpFlashColor;
                lineColor.A = 128;

                ds.DrawLine(0, topLine, bottomRight.X, topLine, lineColor, 3);
                ds.DrawLine(0, bottomLine, bottomRight.X, bottomLine, lineColor, 3);
            }
            public void Draw(CanvasDrawingSession ds, Matrix3x2 transform)
            {
                var pos = Vector2.Transform(Pos, transform);

                var mu = (float)Math.Sin(DeadMu * Math.PI * 0.5);

                var scale = Matrix3x2.CreateScale(1.0f + mu * 10.0f);

                var center = new Vector2(pos.X, pos.Y);
                ds.Transform = Matrix3x2.CreateTranslation(-center) * scale * Matrix3x2.CreateTranslation(center);
                Color c = Color.FromArgb((byte)((1.0f - mu) * 255.0f), 255, 255, 255);

                ds.DrawText(Value.ToString(), pos, c, TextFormat);
            }