Example #1
0
        public void DrawGorizontalMovedCircle(int step)
        {
            int code = 0;
            for (int i = 0; i < LedLibrary.Materials.Count; i++)
                if (LedLibrary.Materials[i].Name == _material)
                {
                    code = i;
                    break;
                }

            int quadR = LedLibrary.Dist(_masPoints[1], _masPoints[2]),
                r = (int)Math.Sqrt(quadR);

            _masPoints[1].X -= step;
            _masPoints[2].X -= step;

            LedLibrary.Point p = new LedLibrary.Point(0, 0);

            for (int x = _masPoints[1].X - r; x <= _masPoints[1].X + r; x++)
                for (int y = _masPoints[1].Y - r; y <= _masPoints[1].Y + r; y++)
                {
                    p.X = x; p.Y = y;
                    if (LedLibrary.Dist(_masPoints[1], p) <= quadR)
                        LedLibrary.Mas[x, y] = code;
                }
        }
 // в дальнейшем массив
 private void DetectingActiveLayer(int num)
 {
     for (int x = 0; x <= LedLibrary.W; x++)
         for (int y = 0; y <= LedLibrary.H; y++)
             if (LedLibrary.Mas[x, y] == num)
                 _active[_numAct++] = new LedLibrary.Point(x, y);
 }
Example #3
0
 private void удалитьПоследнююТочкуToolStripMenuItem_Click(object sender, EventArgs e)
 {
     _masPoints[_click] = new LedLibrary.Point(0, 0);
     _click--;
     RedrawPicture();
 }
Example #4
0
        private void удалитьТекущуюФигуруToolStripMenuItem_Click(object sender, EventArgs e)
        {
            for (int i = 1; i <= _click; i++)
                _masPoints[i] = new LedLibrary.Point(0, 0);
            _click = 0;

            RedrawPicture();
        }
Example #5
0
        private void RemoveCircle()
        {
            int quadR = LedLibrary.Dist(_masPoints[1], _masPoints[2]),
                r = (int)Math.Sqrt(quadR);

            LedLibrary.Point p = new LedLibrary.Point(0, 0);

            for (int x = _masPoints[1].X - r; x <= _masPoints[1].X + r; x++)
                for (int y = _masPoints[1].Y - r; y <= _masPoints[1].Y + r; y++)
                {
                    p.X = x; p.Y = y;
                    if (LedLibrary.Dist(_masPoints[1], p) <= quadR)
                        LedLibrary.Mas[x, y] = 0;
                }

            _oldClick = 0;
        }
Example #6
0
        private LedLibrary.Point NearestPoint(int x, int y)
        {
            int step = LedLibrary.StepOfCursor;

            LedLibrary.Point[] masPoint = new LedLibrary.Point[4];
            int x1 = (x / step) * step,
                y1 = (y / step) * step,
                x2 = x1 + step,
                y2 = y1 + step;

            masPoint[0] = new LedLibrary.Point(x1, y1);
            masPoint[1] = new LedLibrary.Point(x1, y2);
            masPoint[2] = new LedLibrary.Point(x2, y2);
            masPoint[3] = new LedLibrary.Point(x2, y1);

            int min = Int32.MaxValue, minPos = -1;
            LedLibrary.Point curr = new LedLibrary.Point(x1, y1);
            for (int i = 0; i < 4; i++)
            {
                int d = LedLibrary.Dist(curr, masPoint[i]);
                if (d < min)
                {
                    min = d;
                    minPos = i;
                }
            }

            LedLibrary.Point res = new LedLibrary.Point(masPoint[minPos].X, masPoint[minPos].Y);
            return res;
        }
Example #7
0
        private void MakePolygon(int code)
        {
            _click++;
            _masPoints[_click] = new LedLibrary.Point(_currPoint.X, _currPoint.Y);

            if (_click >= 3 && _masPoints[1].X == _currPoint.X && _masPoints[1].Y == _currPoint.Y)
                DrawPolygon(code);
        }
Example #8
0
        private void MakeCircle(int code)
        {
            _click++;
            _masPoints[_click] = new LedLibrary.Point(_currPoint.X, _currPoint.Y);

            if (_click == 2)
            {
                DrawCircle(code);
            }
        }
Example #9
0
        private void DrawCircle(int code)
        {
            int quadR = LedLibrary.Dist(_masPoints[1], _masPoints[2]),
                r = (int) Math.Sqrt(quadR);

            LedLibrary.Point p = new LedLibrary.Point(0, 0);

            for (int x = Math.Max(_masPoints[1].X - r, LedLibrary.Border); x <= Math.Min(_masPoints[1].X + r, LedLibrary.RealW - LedLibrary.Border); x++)
                for (int y = Math.Max(_masPoints[1].Y - r, LedLibrary.Border); y <= Math.Min(_masPoints[1].Y + r, LedLibrary.RealH - LedLibrary.Border); y++)
                {
                    p.X = x; p.Y = y;
                    if (LedLibrary.Dist(_masPoints[1], p) <= quadR)
                        LedLibrary.Mas[x, y] = code;
                }

            _oldClick = _click;
            _click = 0;
        }