Beispiel #1
0
        private void Draw(Shape s)
        {
            int CountOfVertex = 0;

            if (s.NameOfShape == "Triangle")
            {
                CountOfVertex = 3;
            }
            if (s.NameOfShape == "Quadrangle")
            {
                CountOfVertex = 4;
            }
            if (s.NameOfShape == "Pentagon")
            {
                CountOfVertex = 5;
            }
            if (s.NameOfShape == "Hexagon")
            {
                CountOfVertex = 6;
            }

            Gl.glColor3d(s.ColorArray[0], s.ColorArray[1], s.ColorArray[2]);
            Gl.glBegin(Gl.GL_POLYGON);
            Gl.glVertex2d(s.MainPoint.X, s.MainPoint.Y);
            Gl.glVertex2d(s.MainPoint.X + s.KoefOfChange, s.MainPoint.Y);
            Gl.glVertex2d(s.MainPoint.X + s.KoefOfChange, s.MainPoint.Y - s.KoefOfChange);
            if (CountOfVertex > 5)
            {
                Gl.glVertex2d(s.MainPoint.X + s.KoefOfChange * 0.7, s.MainPoint.Y - s.KoefOfChange * 1.7);
                Gl.glVertex2d(s.MainPoint.X + s.KoefOfChange * 0.3, s.MainPoint.Y - s.KoefOfChange * 1.7);
                Gl.glVertex2d(s.MainPoint.X, s.MainPoint.Y - s.KoefOfChange);
            }
            else
            {
                if (CountOfVertex == 4)
                {
                    Gl.glVertex2d(s.MainPoint.X, s.MainPoint.Y - s.KoefOfChange);
                }
                if (CountOfVertex == 5)
                {
                    Gl.glVertex2d(s.MainPoint.X + s.KoefOfChange * 0.5, s.MainPoint.Y + s.KoefOfChange);
                }
            }



            Gl.glEnd();

            Gl.glFlush();
            Gl.glRasterPos2f(s.MainPoint.X, s.MainPoint.Y);
            text(s.NameOfShape);
            OpenGlo.Invalidate();
        }
Beispiel #2
0
        private void button2_Click_1(object sender, EventArgs e)
        {
            Gl.glClear(Gl.GL_COLOR_BUFFER_BIT);
            if (Shapes.Count != 0)
            {
                Shapes.RemoveAt(Shapes.Count - 1);

                for (int i = 0; i < Shapes.Count; i++)
                {
                    Draw(Shapes[i]);
                }
                OpenGlo.Invalidate();
            }
            else
            {
                //OpenGlo.Invalidate();
                MessageBox.Show("All shapes are removed");
            }
        }