KinectWithVRServer.MainWindow.DrawJointPointOnColor C# (CSharp) Method

DrawJointPointOnColor() private method

private DrawJointPointOnColor ( Microsoft.Kinect.Joint joint, Color jointColor, double radius, Point offset, int kinectID ) : void
joint Microsoft.Kinect.Joint
jointColor Color
radius double
offset Point
kinectID int
return void
        private void DrawJointPointOnColor(Joint joint, Color jointColor, double radius, Point offset, int kinectID)
        {
            if (joint.TrackingState != TrackingState.NotTracked)
            {
                //Map the joint from the skeleton to the color image
                Point point = server.kinects[kinectID].MapJointToColor(joint, false);

                //Don't draw points that are off the image
                if (point.X < 0 || point.Y < 0 || point.X >= colorSource.PixelWidth || point.Y >= colorSource.PixelHeight)
                {
                    return;
                }

                //Calculate the coordinates on the image (the offset is also added in this section)
                Point imagePoint = new Point(0.0, 0.0);
                imagePoint.X = ((double)point.X / colorSource.PixelWidth) * ColorImage.ActualWidth + offset.X;
                imagePoint.Y = ((double)point.Y / colorSource.PixelHeight) * ColorImage.ActualHeight + offset.Y;

                if (joint.TrackingState == TrackingState.Inferred)
                {
                    radius = radius / 2.0; //If the joint is inferred, use a circle half the size
                }

                //Generate the circle for the joint
                Ellipse circle = new Ellipse();
                circle.Fill = new SolidColorBrush(jointColor);
                circle.StrokeThickness = 0.0;
                circle.Margin = new Thickness(imagePoint.X - radius, imagePoint.Y - radius, 0, 0);
                circle.HorizontalAlignment = HorizontalAlignment.Left;
                circle.VerticalAlignment = VerticalAlignment.Top;
                circle.Height = radius * 2;
                circle.Width = radius * 2;
                ColorImageCanvas.Children.Add(circle);
            }
        }
MainWindow