CUE.NET.Brushes.ImageBrush.GetColorAtPoint C# (CSharp) Метод

GetColorAtPoint() защищенный Метод

Gets the color at an specific point assuming the brush is drawn into the given rectangle.
protected GetColorAtPoint ( RectangleF rectangle, BrushRenderTarget renderTarget ) : CorsairColor
rectangle System.Drawing.RectangleF The rectangle in which the brush should be drawn.
renderTarget BrushRenderTarget The target (key/point) from which the color should be taken.
Результат CUE.NET.Devices.Generic.CorsairColor
        protected override CorsairColor GetColorAtPoint(RectangleF rectangle, BrushRenderTarget renderTarget)
        {
            if (Image == null || Image.Width == 0 || Image.Height == 0)
                return CorsairColor.Transparent;

            //TODO DarthAffe 16.03.2016: Refactor to allow more scale-/interpolation-modes
            float scaleX = Image.Width / rectangle.Width;
            float scaleY = Image.Height / rectangle.Height;

            int x = (int)(renderTarget.Point.X * scaleX);
            int y = (int)(renderTarget.Point.Y * scaleY);

            x = Math.Max(0, Math.Min(x, Image.Width - 1));
            y = Math.Max(0, Math.Min(y, Image.Height - 1));

            return Image.GetPixel(x, y);
        }