MTExample5_5.DrawCylinder.DrawIsometricView C# (CSharp) Method

DrawIsometricView() public method

public DrawIsometricView ( Graphics g ) : void
g System.Drawing.Graphics
return void
        public void DrawIsometricView(Graphics g)
        {
            Point3[] ptsBottom = CircleCoordinates (-h / 2);
            var ptaBottom = new PointF[ptsBottom.Length];
            Point3[] ptsTop = CircleCoordinates (h / 2);
            var ptaTop = new PointF[ptsTop.Length];
            Matrix3 m = Matrix3.Axonometric (35.26f, -45);
            for (int i = 0; i < ptsBottom.Length; i++) {
                ptsBottom [i].Transform (m);
                ptaBottom [i] = Point2D (new CGPoint (ptsBottom [i].X, ptsBottom [i].Y));
                ptsTop [i].Transform (m);
                ptaTop [i] = Point2D (new CGPoint (ptsTop [i].X, ptsTop [i].Y));
            }

            var ptf = new PointF[4];
            for (int i = 1; i < ptsTop.Length; i++) {
                ptf [0] = ptaBottom [i - 1];
                ptf [1] = ptaTop [i - 1];
                ptf [2] = ptaTop [i];
                ptf [3] = ptaBottom [i];
                if (i < 5 || i > ptsTop.Length - 12) {
                    g.FillPolygon (Brushes.White, ptf);
                    g.DrawPolygon (Pens.Black, ptf);
                }
            }

            g.FillPolygon (Brushes.White, ptaTop);
            g.DrawPolygon (Pens.Black, ptaTop);
        }

Usage Example

        private void PlotPanelPaint(object sender, PaintEventArgs e)
        {
            Graphics g         = e.Graphics;
            var      borderPen = new Pen(Brushes.Black, 1);

            g.DrawRectangle(borderPen, panel1.Bounds);
            borderPen.Dispose();
            float        a  = panel1.Height / 4;
            DrawCylinder dc = new DrawCylinder(this, a, 2 * a);

            dc.DrawIsometricView(g);
        }
All Usage Examples Of MTExample5_5.DrawCylinder::DrawIsometricView