첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

TestProject.zip
0.01MB

▶ MainForm.cs

using System;
using System.Drawing;
using System.Windows.Forms;

using Steema.TeeChart.Drawing;
using Steema.TeeChart.Styles;

namespace TestProject
{
    /// <summary>
    /// 메인 폼
    /// </summary>
    public partial class MainForm : Form
    {
        //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor
        ////////////////////////////////////////////////////////////////////////////////////////// Public

        #region 생성자 - MainForm()

        /// <summary>
        /// 생성자
        /// </summary>
        public MainForm()
        {
            InitializeComponent();

            Text = "Surface 클래스 : 3D 원통 만들기";

            this.tChart.Aspect.View3D         = true;
            this.tChart.Aspect.Orthogonal     = false;
            this.tChart.Aspect.Chart3DPercent = 100;
            this.tChart.Aspect.Zoom           = 80;
            this.tChart.Aspect.Rotation       = 320;
            this.tChart.Aspect.Elevation      = 350;
            this.tChart.Panel.Pen             = new ChartPen(Color.Black);
            this.tChart.Walls.Visible         = false;
            this.tChart.Axes.Visible          = false;
            this.tChart.Legend.Visible        = false;

            Surface topSurface = new Surface(this.tChart.Chart);

            topSurface.IrregularGrid = true;
            topSurface.XValues.Order = ValueListOrder.None;
            topSurface.YValues.Order = ValueListOrder.None;

            Surface bottomSurface = new Surface(this.tChart.Chart);

            bottomSurface.IrregularGrid = true;
            bottomSurface.XValues.Order = ValueListOrder.None;
            bottomSurface.YValues.Order = ValueListOrder.None;

            int arcCount = 50; // 원호 카운트
            int zCount   = 20; // 원통 길이

            Random random = new Random();

            double radian180 = GetRadianAngle(180);

            for(int z = 0; z < zCount; z++)
            {
                for(int i = 0; i < arcCount; i++)
                {
                    double alpha = GetRadianAngle(i * 359 / arcCount);

                    double x = Math.Cos(alpha);
                    double y = Math.Sin(alpha);

                    Color color = Color.FromArgb(random.Next(255), random.Next(255), random.Next(255));

                    if(alpha < radian180)
                    {
                        topSurface.Add(x, y, z, "", color);
                    }
                    else
                    {
                        bottomSurface.Add(x, y, z, "", color);
                    }
                }

                Color color1 = Color.FromArgb(random.Next(255), random.Next(255), random.Next(255));
                Color color2 = Color.FromArgb(random.Next(255), random.Next(255), random.Next(255));

                bottomSurface.Add(topSurface.XValues.Maximum, Math.Sin(Math.Acos(topSurface.XValues.Maximum)), z, "", color1);
                bottomSurface.Add(topSurface.XValues.Minimum, Math.Sin(Math.Acos(topSurface.XValues.Minimum)), z, "", color2);
            }
        }

        #endregion

        //////////////////////////////////////////////////////////////////////////////////////////////////// Method
        ////////////////////////////////////////////////////////////////////////////////////////// Private

        #region 라디안 각도 구하기 - GetRadianAngle(angle)

        /// <summary>
        /// 라디안 각도 구하기
        /// </summary>
        /// <param name="angle">각도</param>
        /// <returns>라디안 각도</returns>
        private double GetRadianAngle(double angle)
        {
            return angle * (Math.PI / 180d);
        }

        #endregion
    }
}
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요