Gradients2.vb
  1. ''
  2. '' This code is part of Document Solutions for Imaging demos.
  3. '' Copyright (c) MESCIUS inc. All rights reserved.
  4. ''
  5. Imports System.IO
  6. Imports System.Drawing
  7. Imports System.Numerics
  8. Imports GrapeCity.Documents.Drawing
  9. Imports GrapeCity.Documents.Text
  10. Imports GrapeCity.Documents.Imaging
  11. Imports GCTEXT = GrapeCity.Documents.Text
  12. Imports GCDRAW = GrapeCity.Documents.Drawing
  13.  
  14. '' Gradients
  15. Public Class Gradients2
  16. Function GenerateImage(
  17. ByVal pixelSize As Size,
  18. ByVal dpi As Single,
  19. ByVal opaque As Boolean,
  20. Optional ByVal sampleParams As String() = Nothing) As GcBitmap
  21.  
  22. Dim blue = Color.FromArgb(&HFF2E4884)
  23. Dim bmp = New GcBitmap(pixelSize.Width, pixelSize.Height, True, dpi, dpi)
  24. Using g = bmp.CreateGraphics(Color.RoyalBlue)
  25. Dim m = Matrix3x2.CreateSkew(Math.PI / 7, 0, New Vector2(175, 90))
  26. g.Transform = m * Matrix3x2.CreateScale(2.0F) * Matrix3x2.CreateTranslation(100, 100)
  27. Dim pen = New GCDRAW.Pen(Color.Yellow, 0.5F)
  28.  
  29. Dim rgBrush = New RadialGradientBrush(Color.White, Color.Navy) With
  30. {
  31. .GradientOrigin = New PointF(0.8F, 0.3F),
  32. .AllowEllipticGradients = True
  33. }
  34. g.FillEllipse(New RectangleF(30, 30, 240, 140), rgBrush)
  35.  
  36. pen.Color = Color.Red
  37. pen.Width = 2
  38. g.DrawRectangle(New RectangleF(30, 30, 240, 140), pen)
  39.  
  40. pen.Color = Color.LightGreen
  41. pen.Width = 3.5F
  42. pen.DashStyle = DashStyle.DashDotDot
  43. pen.DashOffset = -3
  44. pen.LineCap = PenLineCap.Round
  45. g.DrawEllipse(New RectangleF(30, 30, 240, 140), pen)
  46.  
  47. g.DrawString("DsImaging", New TextFormat() With
  48. {
  49. .Font = GCTEXT.Font.FromFile(Path.Combine("Resources", "Fonts", "calibri.ttf")),
  50. .ForeColor = Color.White,
  51. .FontSize = 20.0F
  52. }, New PointF(100, 110))
  53. End Using
  54. '' Done
  55. Return bmp
  56. End Function
  57. End Class
  58.