Exemple #1
0
        public void UpdateBrush(object sender, MouseEventArgs e)
        {
            // Point position = (Point) ((e.GetPosition(canvasWindowUI.canvas) - gridLayer.GetPosition()) * (1 / grid.unitPerNode * (1 / zoom)));
            double unitM    = 1 / grid.unitPerNode;
            double zoomM    = 1 / zoom;
            Point  position = (Point)((e.GetPosition(canvasWindowUI.canvas) - gridLayer.GetPosition()) * (zoomM) / grid.unitPerNode);

            position.X = (int)(position.X);
            position.Y = (int)(position.Y);

            if (e.LeftButton == MouseButtonState.Pressed)
            {
                grid.FillPixels(brush.GetPixels(new Vector2Int((int)position.X, (int)position.Y)), true);
            }
            else if (e.RightButton == MouseButtonState.Pressed)
            {
                grid.FillPixels(brush.GetPixels(new Vector2Int((int)position.X, (int)position.Y)), false);
            }
            else
            {
                return;
            }

            RenderGrid();
        }