Example #1
0
            public void DrawTo(State state, Joint otherJoint, Joint.State otherState)
            {
                if (!Visible)
                {
                    return;
                }

                if (DrawType == DrawJointType.CircleLine)
                {
                    float dx = state.Location.X - otherState.Location.X;
                    float dy = state.Location.Y - otherState.Location.Y;
                    float r  = (float)Math.Sqrt((double)(dx * dx + dy * dy)) / 2;

                    float x = otherState.Location.X + dx / 2;
                    float y = otherState.Location.Y + dy / 2;

                    Drawing.Circle(new PointF(x, y), r, state.JointColor);
                }
                else if (DrawType == DrawJointType.CircleRadius)
                {
                    float r = state.Thickness;
                    float x = state.Location.X;
                    float y = state.Location.Y;

                    Drawing.Circle(new PointF(x, y), r, state.JointColor, 5 * (int)Math.Sqrt(r));
                }
                else
                {
                    Drawing.CappedLine(state.Location, otherState.Location, state.Thickness, state.JointColor);
                }

                if (state.BitmapIndex != -1)
                {
                    int    ID     = Bitmaps[state.BitmapIndex].Item1;
                    Bitmap bitmap = Bitmaps[state.BitmapIndex].Item2.Item2;

                    double angle     = MathUtil.Angle(state.Location, otherState.Location);
                    double angleDiff = Math.PI * BitmapOffsets[bitmap].Item1 / 180;
                    angle += angleDiff;
                    PointF Offsets = MathUtil.Rotate(BitmapOffsets[bitmap].Item2, (float)angle);

                    angle *= 180.0 / Math.PI;

                    Drawing.BitmapOriginRotation(new PointF(
                                                     state.Location.X + Offsets.X,
                                                     state.Location.Y + Offsets.Y), bitmap.Size, (float)angle, 255, ID);
                }
            }