How To Draw Polygons Graphics Figure in PDF Mosaic .NET

This sample shows how to draw polygons graphics figure in PDF Mosaic .NET.

C# :

using PDFMosaic;
using System.Drawing;
using System;

namespace Polygon
{
  class Polygon
  {
    static void Main()
    {
      PDFDocument document = new PDFDocument();
      document.Pages.Add(new PDFPage(PDFPaperFormat.A4));
      PDFCanvas canvas = document.Pages[0].Canvas;

      PointF start = new PointF(0, 0);
      PointF[] points = new PointF[5];
      
      points[0].X = 113;
      points[0].Y = 283;
      points[1].X = 70;
      points[1].Y = 156;
      points[2].X = 180;
      points[2].Y = 70;
      points[3].X = 290;
      points[3].Y = 156;
      points[4].X = 250;
      points[4].Y = 283;

      PDFSolidBrush brush = new PDFSolidBrush(new PDFColorRGB(0, 0, 255));
      canvas.DrawPolygon(brush, points);

      document.Save("Polygon.pdf", true);
    }
  }
}

VB.NET :

Imports PDFMosaic
Imports System.Drawing
Imports System

Module Polygon
  Sub Main()
    Dim document As PDFDocument = New PDFDocument()
    document.Pages.Add(New PDFPage(PDFPaperFormat.A4))

    Dim canvas As PDFCanvas = document.Pages(0).Canvas

    Dim start As PointF = New PointF(0, 0)
    Dim points As PointF() = New PointF(4) {New PointF(0, 0), New PointF(0, 0), New PointF(0, 0), New PointF(0, 0), New PointF(0, 0)}
    
    points(0).X = 113
    points(0).Y = 283
    points(1).X = 70
    points(1).Y = 156
    points(2).X = 180
    points(2).Y = 70
    points(3).X = 290
    points(3).Y = 156
    points(4).X = 250
    points(4).Y = 283


    Dim brush As PDFSolidBrush = New PDFSolidBrush(New PDFColorRGB(0, 0, 255))
    canvas.DrawPolygon(Brush, points)
    
    document.Save("Polygon.pdf", True)
  End Sub
End Module