コード例 #1
0
        private void Draw()
        {
            Brush br1 = new SolidBrush(Color.FromArgb(colorDec(_rhombus), colorDec(_rhombus), colorInc(_rhombus))); // кисть ромба
            Brush br2 = new SolidBrush(Color.FromArgb(colorInc(_square), colorDec(_square), colorInc(_square)));    //кисть квадрата

            if (!start)
            {
                MoveAll(1, 1);
                start = true;
            }

            var offset = SizeSide * _rhombus.CoeffSize;

            if (_rhombus.CenterPoint.X + offset > pictureBox1.Width)
            {
                _rhombus.Direction = EnumDirection.Left;
            }
            if (_rhombus.CenterPoint.X - offset < 0)
            {
                _rhombus.Direction = EnumDirection.Right;
            }
            if (_rhombus.Direction == EnumDirection.Right)
            {
                MoveAll(1, 0);
            }
            else
            {
                MoveAll(-1, 0);
            }

            _graphic.Clear(SystemColors.Control); // стирание
            _graphic.FillPolygon(br1, _rhombus.RenderPoints());
            _graphic.FillPolygon(br2, _square.RenderPoints());
            lblXcYc.Text =
                String.Format("X: {0:0.00}, Y: {1:0.00}",
                              _rhombus.CenterPoint.X,
                              _rhombus.CenterPoint.Y); // вывод координат центра тяжести точки
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: sttrox/gr
        private void Draw()
        {
            Brush br1 = new SolidBrush(Color.FromArgb(colorDec(), colorDec(), colorInc())); // кисть ромба
            Brush br2 = new SolidBrush(Color.FromArgb(colorInc(), colorDec(), colorInc())); //кисть квадрата

            _rhombus.CenterPoint = new PointF((float)
                                              (_rhombus.CenterPoint.X + SpeedFigure),
                                              (float)((pictureBox1.Height / 4.0f) * Math.Cos(_rhombus.CenterPoint.X * Math.PI / 180) +
                                                      (pictureBox1.Height / 2.0f)));


            _graphic.Clear(SystemColors.Control); // стирание
            _graphic.FillPolygon(br2, _rhombus.RenderPoints());
            _graphic.FillPolygon(br1, _square.RenderPoints());


            //file.WriteLine(String.Format("xc = {0}; xy = {1};  00 = {2}; 01 = {3}; 10 = {4}; 11 = {5}", xc,yc  ,square[0], square[1], square[2], square[3]));

            lblXcYc.Text =
                String.Format("X: {0:0.00}, Y: {1:0.00}",
                              _rhombus.CenterPoint.X,
                              _rhombus.CenterPoint.Y); // вывод координат центра тяжести точки
        }