Exemplo n.º 1
0
		static void FillPixels ( 
			Brush brush, Rect [] rects, int width, int height, ref int [] pixels ) {
			foreach (var rc in rects) {
				for (var x = (int)rc.Left; x < rc.Right; x++) {

					var pixelTopColor = new Color { PackedValue = (uint)pixels [((int)rc.Top) * width + x] };
					var pixelBottomColor = new Color { PackedValue = (uint)pixels [((int)rc.Bottom-1) * width + x] };

					var topColor = brush.GetPixel (x, (int)rc.Top, width, height);
					var bottomColor = brush.GetPixel (x, (int)rc.Bottom, width, height);

					// Antialiazing, Top

					if (rc.Top > 0) {
						pixels [((int)rc.Top - 1) * width + x] = (int)Color.Lerp (pixelTopColor, topColor, .65f).PackedValue;
					}
					if (rc.Top > 1) {
						pixels [((int)rc.Top - 2) * width + x] = (int)Color.Lerp (pixelTopColor, topColor, .38f).PackedValue;
					}

					for (var y = (int)rc.Top; y < rc.Bottom; y++) {
						pixels [y * width + x] = (int)brush.GetPixel (x, y, width, height).PackedValue;
					}

					// Antialiazing, Bottom

					if (rc.Bottom < height)
						pixels [((int)rc.Bottom) * width + x] = (int)Color.Lerp (pixelBottomColor, bottomColor, .65f).PackedValue;
						
					if (rc.Bottom < height - 1)
						pixels [(int)(rc.Bottom + 1) * width + x] = (int)Color.Lerp (pixelBottomColor, bottomColor, .38f).PackedValue;
				}
			}
		}