예제 #1
0
        public static ColorF WithLightness(this IColorType original, double lightness)
        {
            ColorF colorF = original.ToColorF();

            colorF.GetHSL(out double hue0To1, out double saturation0To1, out _);

            return(ColorF.FromHSL(hue0To1, saturation0To1, lightness));
        }
예제 #2
0
        public static ColorF AdjustLightness(this IColorType original, double lightnessMultiplier)
        {
            ColorF colorF = original.ToColorF();

            colorF.GetHSL(out double hue0To1, out double saturation0To1, out double lightness0To1);
            lightness0To1 *= lightnessMultiplier;

            return(ColorF.FromHSL(hue0To1, saturation0To1, lightness0To1));
        }
예제 #3
0
        public static ColorF WithLightness(this IColorType original, double lightness)
        {
            double hue0To1;
            double saturation0To1;
            double lightness0To1;

            ColorF colorF = original is ColorF ? (ColorF)original : original.ToColorF();

            colorF.GetHSL(out hue0To1, out saturation0To1, out lightness0To1);

            return(ColorF.FromHSL(hue0To1, saturation0To1, lightness));
        }
예제 #4
0
        public static ColorF WithLightnessAdjustment(this IColorType original, double lightnessMultiplier)
        {
            double hue0To1;
            double saturation0To1;
            double lightness0To1;

            ColorF colorF = original is ColorF ? (ColorF)original : original.ToColorF();

            colorF.GetHSL(out hue0To1, out saturation0To1, out lightness0To1);
            lightness0To1 *= lightnessMultiplier;

            return(ColorF.FromHSL(hue0To1, saturation0To1, lightness0To1));
        }
예제 #5
0
        public void clear(IColorType in_c)
        {
            int    y;
            ColorF colorFloat = in_c.ToColorF();

            if (Width != 0)
            {
                for (y = 0; y < Height; y++)
                {
                    base.copy_hline(0, (int)y, (int)Width, colorFloat);
                }
            }
        }
예제 #6
0
        public override void Render(IVertexSource vertexSource, IColorType colorBytes)
        {
            rasterizer.reset();
            Affine transform = GetTransform();

            if (!transform.is_identity())
            {
                vertexSource = new VertexSourceApplyTransform(vertexSource, transform);
            }

            rasterizer.add_path(vertexSource);
            if (destImageByte != null)
            {
                scanlineRenderer.RenderSolid(destImageByte, rasterizer, scanlineCache, colorBytes.ToColor());
                DestImage.MarkImageChanged();
            }
            else
            {
                scanlineRenderer.RenderSolid(destImageFloat, rasterizer, scanlineCache, colorBytes.ToColorF());
                destImageFloat.MarkImageChanged();
            }
        }
예제 #7
0
        public override void Clear(IColorType iColor)
        {
            RectangleDouble clippingRect    = GetClippingRect();
            var             clippingRectInt = new RectangleInt((int)clippingRect.Left, (int)clippingRect.Bottom, (int)clippingRect.Right, (int)clippingRect.Top);

            if (DestImage != null)
            {
                var    color  = iColor.ToColor();
                byte[] buffer = DestImage.GetBuffer();
                switch (DestImage.BitDepth)
                {
                case 8:
                {
                    for (int y = clippingRectInt.Bottom; y < clippingRectInt.Top; y++)
                    {
                        int bufferOffset       = DestImage.GetBufferOffsetXY((int)clippingRect.Left, y);
                        int bytesBetweenPixels = DestImage.GetBytesBetweenPixelsInclusive();
                        for (int x = 0; x < clippingRectInt.Width; x++)
                        {
                            buffer[bufferOffset] = color.blue;
                            bufferOffset        += bytesBetweenPixels;
                        }
                    }
                }

                break;

                case 24:
                    for (int y = clippingRectInt.Bottom; y < clippingRectInt.Top; y++)
                    {
                        int bufferOffset       = DestImage.GetBufferOffsetXY((int)clippingRect.Left, y);
                        int bytesBetweenPixels = DestImage.GetBytesBetweenPixelsInclusive();
                        for (int x = 0; x < clippingRectInt.Width; x++)
                        {
                            buffer[bufferOffset + 0] = color.blue;
                            buffer[bufferOffset + 1] = color.green;
                            buffer[bufferOffset + 2] = color.red;
                            bufferOffset            += bytesBetweenPixels;
                        }
                    }

                    break;

                case 32:
                {
                    for (int y = clippingRectInt.Bottom; y < clippingRectInt.Top; y++)
                    {
                        int bufferOffset       = DestImage.GetBufferOffsetXY((int)clippingRect.Left, y);
                        int bytesBetweenPixels = DestImage.GetBytesBetweenPixelsInclusive();
                        for (int x = 0; x < clippingRectInt.Width; x++)
                        {
                            buffer[bufferOffset + 0] = color.blue;
                            buffer[bufferOffset + 1] = color.green;
                            buffer[bufferOffset + 2] = color.red;
                            buffer[bufferOffset + 3] = color.alpha;
                            bufferOffset            += bytesBetweenPixels;
                        }
                    }
                }

                break;

                default:
                    throw new NotImplementedException();
                }

                DestImage.MarkImageChanged();
            }
            else             // it is a float
            {
                if (DestImageFloat == null)
                {
                    throw new Exception("You have to have either a byte or float DestImage.");
                }

                var     color  = iColor.ToColorF();
                int     height = DestImageFloat.Height;
                float[] buffer = DestImageFloat.GetBuffer();
                switch (DestImageFloat.BitDepth)
                {
                case 128:
                    for (int y = 0; y < height; y++)
                    {
                        int bufferOffset       = DestImageFloat.GetBufferOffsetXY(clippingRectInt.Left, y);
                        int bytesBetweenPixels = DestImageFloat.GetFloatsBetweenPixelsInclusive();
                        for (int x = 0; x < clippingRectInt.Width; x++)
                        {
                            buffer[bufferOffset + 0] = color.blue;
                            buffer[bufferOffset + 1] = color.green;
                            buffer[bufferOffset + 2] = color.red;
                            buffer[bufferOffset + 3] = color.alpha;
                            bufferOffset            += bytesBetweenPixels;
                        }
                    }

                    break;

                default:
                    throw new NotImplementedException();
                }
            }
        }
예제 #8
0
 public void line_color(IColorType c)
 {
     m_color = c.ToColorF();
 }