示例#1
0
        private void DrawBall(Ball ball, Color ballColor)
        {
            // Turn it into ints
            MyVector topLeft = ball.Position.Clone();

            topLeft.X -= ball.Radius;
            topLeft.Y -= ball.Radius;
            Point topLeftInt = topLeft.ToPoint();
            int   size       = Convert.ToInt32(ball.Radius * 2);

            // Draw the ball
            _graphics.DrawEllipse(new Pen(ballColor, 3), topLeftInt.X, topLeftInt.Y, size, size);
        }
示例#2
0
 private void DrawVector(MyVector fromPoint, MyVector toPoint, Color color)
 {
     _graphics.DrawLine(new Pen(color), fromPoint.ToPoint(), toPoint.ToPoint());
 }
示例#3
0
        /// <summary>
        /// This function draws the vector on the middle of the picturebox (from the middle to the vector coord)
        /// The picturebox is scaled to -10 to 10
        /// </summary>
        private void DrawVector(MyVector vector, Color color)
        {
            const double SCALEFACTOR = 500d / 20d;

            MyVector scaledVector = vector * SCALEFACTOR;

            scaledVector.Y *= -1;      // Invert Y
            scaledVector.Add(250, 250, 0);

            pictureBox1.CreateGraphics().DrawLine(new Pen(color, 5), new Point(250, 250), scaledVector.ToPoint());
        }