Gradients2.vb
''
'' This code is part of GrapeCity Documents for Imaging samples.
'' Copyright (c) GrapeCity, Inc. All rights reserved.
''
Imports System.IO
Imports System.Drawing
Imports System.Numerics
Imports GrapeCity.Documents.Drawing
Imports GrapeCity.Documents.Text
Imports GrapeCity.Documents.Imaging

'' Gradients
Public Class Gradients2
    Function GenerateImage(
            Optional pixelWidth As Integer = 1024,
            Optional pixelHeight As Integer = 1024,
            Optional opaque As Boolean = True,
            Optional dpiX As Single = 96,
            Optional dpiY As Single = 96) As GcBitmap

        Dim blue = Color.FromArgb(&HFF2E4884)
        Dim bmp = New GcBitmap(pixelWidth, pixelHeight, True, dpiX, dpiY)
        Using g = bmp.CreateGraphics(Color.RoyalBlue)
            Dim m = Matrix3x2.CreateSkew(Math.PI / 7, 0, New Vector2(175, 90))
            g.Transform = m * Matrix3x2.CreateScale(2.0F) * Matrix3x2.CreateTranslation(100, 100)
            Dim pen = New Pen(Color.Yellow, 0.5F)

            Dim rgBrush = New RadialGradientBrush(Color.White, Color.Navy) With
                {
                    .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() With
                {
                    .Font = Font.FromFile(Path.Combine("Resources", "Fonts", "calibri.ttf")),
                    .ForeColor = Color.White,
                    .FontSize = 20.0F
                }, New PointF(100, 110))
        End Using
        '' Done
        Return bmp
    End Function
End Class