Ejemplo n.º 1
0
        public BitmapPixelChanges ChangeBrightness(Layer layer, Coordinates coordinates, int toolSize,
                                                   float correctionFactor)
        {
            DoubleCords centeredCoords = CoordinatesCalculator.CalculateThicknessCenter(coordinates, toolSize);

            Coordinates[] rectangleCoordinates = CoordinatesCalculator.RectangleToCoordinates(centeredCoords.Coords1.X,
                                                                                              centeredCoords.Coords1.Y,
                                                                                              centeredCoords.Coords2.X, centeredCoords.Coords2.Y);
            BitmapPixelChanges changes = new BitmapPixelChanges(new Dictionary <Coordinates, Color>());

            for (int i = 0; i < rectangleCoordinates.Length; i++)
            {
                if (Mode == BrightnessMode.Default)
                {
                    if (_pixelsVisited.Contains(rectangleCoordinates[i]))
                    {
                        continue;
                    }
                    _pixelsVisited.Add(rectangleCoordinates[i]);
                }

                Color pixel    = layer.GetPixelWithOffset(rectangleCoordinates[i].X, rectangleCoordinates[i].Y);
                Color newColor = ExColor.ChangeColorBrightness(Color.FromArgb(pixel.A, pixel.R, pixel.G, pixel.B),
                                                               correctionFactor);
                changes.ChangedPixels.Add(new Coordinates(rectangleCoordinates[i].X, rectangleCoordinates[i].Y),
                                          newColor);
            }

            return(changes);
        }
Ejemplo n.º 2
0
        public void TestThatClipboardControllerSavesImageToClipboard()
        {
            Layer testLayer = new Layer("test layer", 10, 10);

            ClipboardController.CopyToClipboard(new [] { testLayer }, CoordinatesCalculator.RectangleToCoordinates(0, 0, 9, 9), 10, 10);
            Assert.True(ClipboardController.IsImageInClipboard());
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Gets points for rounded cap on specified position and thickness.
        /// </summary>
        /// <param name="position">Starting position of cap.</param>
        /// <param name="thickness">Thickness of cap.</param>
        private IEnumerable <Coordinates> GetRoundCap(Coordinates position, int thickness)
        {
            IEnumerable <Coordinates> rectangleCords = CoordinatesCalculator.RectangleToCoordinates(
                CoordinatesCalculator.CalculateThicknessCenter(position, thickness));

            return(circleTool.CreateEllipse(rectangleCords.First(), rectangleCords.Last(), 1, true));
        }
Ejemplo n.º 4
0
        public BitmapPixelChanges Draw(Coordinates startingCoords, Color color, int toolSize)
        {
            int         x1, y1, x2, y2;
            DoubleCords centeredCoords = CoordinatesCalculator.CalculateThicknessCenter(startingCoords, toolSize);

            x1 = centeredCoords.Coords1.X;
            y1 = centeredCoords.Coords1.Y;
            x2 = centeredCoords.Coords2.X;
            y2 = centeredCoords.Coords2.Y;
            return(new BitmapPixelChanges(CoordinatesCalculator.RectangleToCoordinates(x1, y1, x2, y2), color));
        }
Ejemplo n.º 5
0
        protected IEnumerable <Coordinates> GetThickShape(IEnumerable <Coordinates> shape, int thickness)
        {
            List <Coordinates> output = new List <Coordinates>();

            foreach (var item in shape)
            {
                output.AddRange(
                    CoordinatesCalculator.RectangleToCoordinates(
                        CoordinatesCalculator.CalculateThicknessCenter(item, thickness)));
            }
            return(output.Distinct());
        }
Ejemplo n.º 6
0
        protected Coordinates[] GetThickShape(Coordinates[] shape, int thickness)
        {
            List <Coordinates> output = new List <Coordinates>();

            for (int i = 0; i < shape.Length; i++)
            {
                output.AddRange(
                    CoordinatesCalculator.RectangleToCoordinates(
                        CoordinatesCalculator.CalculateThicknessCenter(shape[i], thickness)));
            }
            return(output.Distinct().ToArray());
        }
Ejemplo n.º 7
0
 public int RectangleToCoordinatesAmountTest(int x1, int y1, int x2, int y2)
 {
     return(CoordinatesCalculator.RectangleToCoordinates(x1, y1, x2, y2).Length);
 }
Ejemplo n.º 8
0
 public void TestThatRectangleToCoordinatesReturnsSameAmount(int x1, int y1, int x2, int y2, int expectedResult)
 {
     Assert.Equal(CoordinatesCalculator.RectangleToCoordinates(x1, y1, x2, y2).Length, expectedResult);
 }