Gradients2.cs
//
// This code is part of GrapeCity Documents for Imaging samples.
// Copyright (c) GrapeCity, Inc. All rights reserved.
//
using System;
using System.IO;
using System.Drawing;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using GrapeCity.Documents.Drawing;
using GrapeCity.Documents.Text;
using GrapeCity.Documents.Imaging;

namespace GcImagingWeb.Samples
{
    // Gradients
    public class Gradients2
    {
        public GcBitmap GenerateImage(int pixelWidth = 1024, int pixelHeight = 1024, bool opaque = true, float dpiX = 96, float dpiY = 96)
        {
            var blue = Color.FromArgb(unchecked((int)0xFF2e4884));
            var bmp = new GcBitmap(pixelWidth, pixelHeight, true, dpiX, dpiY);
            using (var g = bmp.CreateGraphics(Color.RoyalBlue))
            {
                var m = Matrix3x2.CreateSkew((float)Math.PI / 7, 0, new Vector2(175, 90));
                g.Transform = m * Matrix3x2.CreateScale(2f) * Matrix3x2.CreateTranslation(100, 100);
                var pen = new Pen(Color.Yellow, 0.5f);

                var rgBrush = new RadialGradientBrush(Color.White, Color.Navy)
                {
                    GradientOrigin = new PointF(0.8f, 0.3f),
                    AllowEllipticGradients = true
                };
                g.FillEllipse(new RectangleF(30, 30, 240, 140), rgBrush);

                pen.Color = Color.Red;
                pen.Width = 2;
                g.DrawRectangle(new RectangleF(30, 30, 240, 140), pen);

                pen.Color = Color.LightGreen;
                pen.Width = 3.5f;
                pen.DashStyle = DashStyle.DashDotDot;
                pen.DashOffset = -3;
                pen.LineCap = PenLineCap.Round;
                g.DrawEllipse(new RectangleF(30, 30, 240, 140), pen);

                g.DrawString("GcImaging", new TextFormat()
                {
                    Font = Font.FromFile(Path.Combine("Resources", "Fonts", "calibri.ttf")),
                    ForeColor = Color.White,
                    FontSize = 20f
                }, new PointF(100, 110));
            }
            return bmp;
        }
    }
}