Example #1
0
        public void MidPoint_Circle(Circle circle)
        {
            int x, y, centerX, centerY, p, R;

            R = 0;
            //get color of the circle
            Color color = circle.getColor();

            //get the point at radius
            x       = circle.getEndPoint().X;
            y       = circle.getEndPoint().Y;
            centerX = circle.getCenterPoint().X;
            centerY = circle.getCenterPoint().Y;
            //if (x == centerX || y != centerY)
            //{
            //    R = Math.Abs(y - centerY);
            //}
            //else if (y == centerY)
            //{
            //    R = Math.Abs(x - centerX);
            //}
            R = round(circle.getRadius());
            int max = round((float)(Math.Sqrt(2) / 2 * R));

            p = 5 / 4 - R;
            x = 0; y = R;
            put8pixel(x, y, centerX, centerY, color);

            while (x <= max)
            {
                if (p < 0)
                {
                    p = p + 2 * x + 3;
                }
                else
                {
                    p = p + 2 * (x - y) + 5;
                    y = y - 1;
                }
                x = x + 1;
                put8pixel(x, y, centerX, centerY, color);
            }
        }
Example #2
0
        private void getInfoShape()
        {
            if (choosedShape != null)
            {
                frm.richTextBox1.Clear();
                frm.richTextBox1.AppendText("Tên hình ảnh: " + choosedShape.getName() + "\n");
                frm.richTextBox1.AppendText("Màu sắc: " + choosedShape.getColor().ToString() + "\n");
                switch (choosedShape.getTypeDraw())
                {
                case TypeDraw.Line:
                    Line line = (Line)choosedShape;
                    frm.richTextBox1.AppendText("Điểm đầu: " + line.getStartPoint().ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm cuối: " + line.getEndPoint().ToString() + "\n");
                    frm.richTextBox1.AppendText("Chiều dài: " + line.getLength().ToString());
                    break;

                case TypeDraw.Circle:
                    Circle circle = (Circle)choosedShape;
                    frm.richTextBox1.AppendText("Tâm: " + circle.getCenterPoint().ToString() + "\n");
                    frm.richTextBox1.AppendText("Bán kính: " + circle.getRadius().ToString());
                    break;

                case TypeDraw.Ellipse:
                    Ellipse ellipse = (Ellipse)choosedShape;
                    frm.richTextBox1.AppendText("Tâm: " + ellipse.getStartPoint().ToString() + "\n");
                    frm.richTextBox1.AppendText("Bán kính nhỏ: " + ellipse.getWidthRadius().ToString() + "\n");
                    frm.richTextBox1.AppendText("Bán kính lớn: " + ellipse.getHeightRadius().ToString());
                    break;

                case TypeDraw.Parallelogram:
                    Parallelogram parallelogram = (Parallelogram)choosedShape;
                    frm.richTextBox1.AppendText("Điểm thứ I: " + parallelogram.getPoint1().ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ II: " + parallelogram.getPoint2().ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ III: " + parallelogram.getPoint3().ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ IV: " + parallelogram.getPoint4().ToString() + "\n");
                    frm.richTextBox1.AppendText("Chiều dài:" + parallelogram.getHeight().ToString() + "\n");
                    frm.richTextBox1.AppendText("Chiều rộng:" + parallelogram.getWidth().ToString() + "\n");
                    break;

                case TypeDraw.Rectangle:
                    Rectangle rectangle = (Rectangle)choosedShape;
                    frm.richTextBox1.AppendText("Điểm thứ I: " + rectangle.getStartPoint().ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ II: " + rectangle.getPoint12().ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ III: " + rectangle.getEndPoint().ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ VI: " + rectangle.getPoint21().ToString() + "\n");
                    frm.richTextBox1.AppendText("Chiều dài:" + rectangle.getHeigth() + "\n");
                    frm.richTextBox1.AppendText("Chiều rộng:" + rectangle.getWidth() + "\n");
                    break;

                case TypeDraw.Triangle:
                    Triangle triangle = (Triangle)choosedShape;
                    frm.richTextBox1.AppendText("Điểm thứ I" + triangle.getPoint1().ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ II" + triangle.getPoint2().ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ III" + triangle.getPoint3().ToString() + "\n");
                    frm.richTextBox1.AppendText("Độ dài cạnh I: " + triangle.getLength1() + "\n");
                    frm.richTextBox1.AppendText("Độ dài cạnh II: " + triangle.getLength2() + "\n");
                    frm.richTextBox1.AppendText("Độ dài cạnh III: " + triangle.getLength3() + "\n");
                    break;

                case TypeDraw.Square:
                    Square square = (Square)choosedShape;
                    frm.richTextBox1.AppendText("Điểm thứ I: " + square.getPoint1().ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ II: " + square.getPoint2().ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ III: " + square.getPoint3().ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ IV: " + square.getPoint4().ToString() + "\n");
                    frm.richTextBox1.AppendText("Độ dài cạnh: " + square.getEdge().ToString() + "\n");
                    break;

                case TypeDraw.Cube:
                    Cube cube = (Cube)choosedShape;
                    frm.richTextBox1.AppendText("Điểm thứ I: " + cube.getList3D().ElementAt(0).ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ II: " + cube.getList3D().ElementAt(1).ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ III: " + cube.getList3D().ElementAt(2).ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ IV: " + cube.getList3D().ElementAt(3).ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ V: " + cube.getList3D().ElementAt(4).ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ VI: " + cube.getList3D().ElementAt(5).ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ VII: " + cube.getList3D().ElementAt(6).ToString() + "\n");
                    break;

                case TypeDraw.Cylinder:
                    Cylinder cylinder = (Cylinder)choosedShape;
                    frm.richTextBox1.AppendText("Điểm thứ I: " + cylinder.getList3D().ElementAt(0).ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ II: " + cylinder.getList3D().ElementAt(1).ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ III: " + cylinder.getList3D().ElementAt(2).ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ IV: " + cylinder.getList3D().ElementAt(3).ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ V: " + cylinder.getList3D().ElementAt(4).ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ VI: " + cylinder.getList3D().ElementAt(5).ToString() + "\n");
                    frm.richTextBox1.AppendText("Điểm thứ VII: " + cylinder.getList3D().ElementAt(6).ToString() + "\n");
                    break;
                }
            }
        }