예제 #1
0
        public static WriteableBitmap Gradient(this WriteableBitmap bitmap, LinearGradientMode mode, Color color1, Color color2, System.Drawing.Rectangle region)
        {
            var result = bitmap.Bitmap();

            using (var g = System.Drawing.Graphics.FromImage(result))
                g.FillRectangle(new LinearGradientBrush(region, color1, color2, mode), region);

            return(result.WriteableBitmap());
        }
예제 #2
0
        public override void Render(WriteableBitmap input)
        {
            var x1 = Region.X;
            var y1 = Region.Y;

            var x2 = Region.X + Region.Width;
            var y2 = Region.Y + Region.Height;

            if (Style.ColorOverlay.IsEnabled)
            {
                input.FillEllipse(x1, y1, x2, y2, Style.ColorOverlay.Color, null);
                return;
            }

            input.FillEllipse(x1, y1, x2, y2, Stroke.Color, null);

            x1 += StrokeThickness.Int32();
            y1 += StrokeThickness.Int32();
            x2 -= StrokeThickness.Int32();
            y2 -= StrokeThickness.Int32();

            x2 = x2 <= x1 ? x1 + 1 : x2;
            y2 = y2 <= y1 ? y1 + 1 : y2;

            input.FillEllipse(x1, y1, x2, y2, Fill.Color, null);

            if (Transform is ScaleTransform)
            {
            }
            if (Transform is SkewTransform)
            {
                if ((Transform as SkewTransform).TopLeft != null)
                {
                    Preview = TransformTool.Shear(input.Bitmap(), (Transform as SkewTransform).TopLeft.X, (Transform as SkewTransform).TopLeft.Y).WriteableBitmap();
                }
            }
        }