Gradients2.vb
''
'' This code is part of Document Solutions for Imaging demos.
'' Copyright (c) MESCIUS 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
Imports GCTEXT = GrapeCity.Documents.Text
Imports GCDRAW = GrapeCity.Documents.Drawing

'' Gradients
Public Class Gradients2
    Function GenerateImage(
        ByVal pixelSize As Size,
        ByVal dpi As Single,
        ByVal opaque As Boolean,
        Optional ByVal sampleParams As String() = Nothing) As GcBitmap

        Dim blue = Color.FromArgb(&HFF2E4884)
        Dim bmp = New GcBitmap(pixelSize.Width, pixelSize.Height, True, dpi, dpi)
        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 GCDRAW.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("DsImaging", New TextFormat() With
                {
                    .Font = GCTEXT.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