Mit Hilfe einer matrix zu drehen, Rechteck einzeln

Mit ein bisschen eine Zeichnung Komplikation würden Sie das nennen. Mein Mathe ist ein bisschen eingerostet, wenn es um Matrizen und zeichnen Drehungen Formen. Hier ist ein wenig code:

private void Form1_Paint(object sender, PaintEventArgs e)
    {
        g = e.Graphics;
        g.SmoothingMode = SmoothingMode.HighQuality;
        DoRotation(e);
        g.DrawRectangle(new Pen(Color.Black), r1);
        g.DrawRectangle(new Pen(Color.Black), r2);

        //draw a line (PEN, CenterOfObject(X, Y), endpoint(X,Y) )
        g.DrawLine(new Pen(Color.Black), new Point((r1.X + 50), (r1.Y + 75)), new Point((/*r1.X + */50), (/*r1.Y - */25)));

        this.lblPoint.Text = "X-pos: " + r1.X + " Y-pos: " + r1.Y;

        //this.Invalidate();
    }
    public void DoRotation(PaintEventArgs e)
    {
        //move the rotation point to the center of object
        e.Graphics.TranslateTransform((r1.X + 50), (r1.Y + 75));
        //rotate
        e.Graphics.RotateTransform((float)rotAngle);
        //move back to the top left corner of the object
        e.Graphics.TranslateTransform(-(r1.X + 50), -(r1.Y + 75));
    }
    public void Form1_KeyDown(object sender, KeyEventArgs e)
    {
        case Keys.T:
                rotAngle += 1.0f;
    }

wenn ich drehen (was ich denke, sollte r1) sowohl r1 und r2 drehen. Ich muss in der Lage sein zu drehen jede Form individuell, wie ich hinzufügen, weitere Formen.

InformationsquelleAutor Orthmius | 2012-04-18

Schreibe einen Kommentar