private void Render()
        {
            context.Clear(null);

            Matrix3x2 worldToFormTransform = GetWorldToFormTransform();

            foreach (var bone in bones)
            {
                var transform  = bone.GetChainedTransform(inputs) * worldToFormTransform;
                var formCenter = Matrix3x2.TransformPoint(transform, bone.Center);
                var formEnd    = Matrix3x2.TransformPoint(transform, bone.End);

                context.DrawEllipse(new Ellipse(formCenter, 5, 5), whiteBrush, 2);
                context.DrawLine(formCenter, formEnd, whiteBrush, 2);
            }

            var formTarget = Matrix3x2.TransformPoint(worldToFormTransform, target);

            float crossSize = 5;

            context.DrawLine(
                formTarget + crossSize * new Vector2(-1, -1),
                formTarget + crossSize * new Vector2(+1, +1),
                redBrush, 2);
            context.DrawLine(
                formTarget + crossSize * new Vector2(-1, +1),
                formTarget + crossSize * new Vector2(+1, -1),
                redBrush, 2);
        }
예제 #2
0
 internal override void DoWork(DeviceContext context)
 {
     if (Fill)
     {
         context.FillEllipse(Ellipse, Brush);
     }
     else
     {
         context.DrawEllipse(Ellipse, Brush, StrokeWidth, StrokeStyle);
     }
 }
예제 #3
0
        private async Task Render()
        {
            DeviceContext renderTarget = _deviceContext;

            renderTarget.BeginDraw();

            renderTarget.Clear(Color.FromKnown(Colors.Black, 1f));


            for (int index = 0; index < PointCount; ++index)
            {
                for (int n = 0; n < NeighborCount; ++n)
                {
                    renderTarget.DrawLine(_brush1, (NeighborCount - n) / (float)(10 * NeighborCount), _points[index], _points[_neighbors[index, n]]);
                }
                renderTarget.DrawEllipse(_brush, 0.5f, new Ellipse(_points[index], 1.5f, 1.5f));
            }

            string text = "Press <Esc> to exit...";

            using (TextFormat textFormat = _directWriteFactory.CreateTextFormat("Segoe UI", 13, FontWeight.Normal))
                using (TextLayout textLayout = _directWriteFactory.CreateTextLayout(text, textFormat, float.MaxValue, float.MaxValue))
                    using (SolidColorBrush textBrush = renderTarget.CreateSolidColorBrush(Color.FromKnown(Colors.White, 1)))
                    {
                        renderTarget.DrawText(
                            text,
                            textFormat,
                            new RectF(10, 10, ClientRectangle.Width, ClientRectangle.Height),
                            textBrush,
                            DrawTextOptions.None,
                            MeasuringMode.Natural
                            );
                    }

            renderTarget.EndDraw();

            _swapChain.Present(1, 0);

            await MovePoints();
        }
예제 #4
0
        private void Render()
        {
            DeviceContext renderTarget = _deviceContext;

            renderTarget.BeginDraw();

            renderTarget.Clear(Color.FromKnown(Colors.Black, 1f));

            _random = new Random(19292);
            for (int index = 0; index < _brushes.Length; ++index)
            {
                float   x       = _random.Next(0, ClientRectangle.Width);
                float   y       = _random.Next(0, ClientRectangle.Height);
                Ellipse ellipse = new Ellipse(x, y, 50, 50);
                renderTarget.FillEllipse(_brushes[index], ellipse);
                renderTarget.DrawEllipse(_pens[index], 1, ellipse);
            }

            string text = "Press <Esc> to exit...";

            using (TextFormat textFormat = _directWriteFactory.CreateTextFormat("Segoe UI", 13, FontWeight.Normal))
                using (TextLayout textLayout = _directWriteFactory.CreateTextLayout(text, textFormat, float.MaxValue, float.MaxValue))
                    using (SolidColorBrush textBrush = renderTarget.CreateSolidColorBrush(Color.FromKnown(Colors.White, 1)))
                    {
                        renderTarget.DrawText(
                            text,
                            textFormat,
                            new RectF(10, 10, ClientRectangle.Width, ClientRectangle.Height),
                            textBrush,
                            DrawTextOptions.None,
                            MeasuringMode.Natural
                            );
                    }

            renderTarget.EndDraw();

            _swapChain.Present(1, 0);
        }
예제 #5
0
        /// <inheritdoc />
        public void DrawEllipse(IBrush brush, IPen pen, Rect rect)
        {
            var rc = rect.ToDirect2D();

            if (brush != null)
            {
                using (var b = CreateBrush(brush, rect.Size))
                {
                    if (b.PlatformBrush != null)
                    {
                        _deviceContext.FillEllipse(new Ellipse
                        {
                            Point   = rect.Center.ToSharpDX(),
                            RadiusX = (float)(rect.Width / 2),
                            RadiusY = (float)(rect.Height / 2)
                        }, b.PlatformBrush);
                    }
                }
            }

            if (pen?.Brush != null)
            {
                using (var wrapper = CreateBrush(pen.Brush, rect.Size))
                    using (var d2dStroke = pen.ToDirect2DStrokeStyle(_deviceContext))
                    {
                        if (wrapper.PlatformBrush != null)
                        {
                            _deviceContext.DrawEllipse(new Ellipse
                            {
                                Point   = rect.Center.ToSharpDX(),
                                RadiusX = (float)(rect.Width / 2),
                                RadiusY = (float)(rect.Height / 2)
                            }, wrapper.PlatformBrush, (float)pen.Thickness, d2dStroke);
                        }
                    }
            }
        }