0
Answer

draw a lines rotated along a number of degrees

Photo of Andreas Jung

Andreas Jung

1d
70
1

hello, I want to (in c#) draw lines with a positive rotation, like the title says.

I have the code below , but its not exactly what I want.

private void button1_Click(object sender, EventArgs e)
        {
            this.Invalidate(true);
            this.pictureBox1.Paint += new System.Windows.Forms.PaintEventHandler(this.FillRectangle1);
            this.pictureBox2.Paint += new System.Windows.Forms.PaintEventHandler(this.FillRectangle2);
        }

        private void FillRectangle1(object sender, PaintEventArgs e)
        {
            for (int i = 0; i<=90; i +=10) 
            {
                Matrix matrix = new Matrix();
                matrix.Rotate(i);  
                e.Graphics.Transform = matrix;
                e.Graphics.DrawLine(Pens.Black, 0, 0, 250, 0);
                e.Graphics.DrawString(i.ToString(), this.Font, Brushes.Black, new PointF(250, -5)); 
            }
        }
        private void FillRectangle2(object sender, PaintEventArgs e)
        {
            for (int i = 0; i<=90; i +=10)
            {
                Matrix matrix = new Matrix();
                matrix.RotateAt(i, new PointF(25, 25));
                e.Graphics.Transform = matrix;
                e.Graphics.DrawLine(Pens.Black, 25, 25, 245, 25);
                e.Graphics.DrawString(i.ToString(), this.Font, Brushes.Black, new PointF(245, 20));
            }
        }

 

Rather I want to program such a picture. Thank you for your help.

:

Answers (0)

Next Recommended Forum