How To Use Blend Modes in PDF Mosaic .NET

This sample shows how to customize a way in which semi-transparent objects will blend on a canvas.

C# :

using PDFMosaic;
using System.Drawing;

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

      PDFDeviceColor red = new PDFColorRGB(255, 0, 0);
      PDFDeviceColor green = new PDFColorRGB(0, 255, 0);
      PDFDeviceColor blue = new PDFColorRGB(0, 0, 255);
      PDFSolidBrush brushRed = new PDFSolidBrush(red);
      PDFSolidBrush brushGreen = new PDFSolidBrush(green);
      PDFSolidBrush brushBlue = new PDFSolidBrush(blue);
      PDFSolidPen pen = new PDFSolidPen();

      canvas.DrawCircle(brushRed, 300, 300, 50);
      canvas.DrawCircle(brushGreen, 300, 350, 50);
      canvas.DrawCircle(brushBlue, 350, 300, 50);
      canvas.BlendMode = PDFBlendMode.Screen;
      canvas.DrawCircle(brushRed, 100, 100, 50);
      canvas.DrawCircle(brushGreen, 100, 150, 50);
      canvas.DrawCircle(brushBlue, 150, 100, 50);
      canvas.BlendMode = PDFBlendMode.Darken;
      canvas.DrawCircle(brushRed, 300, 100, 50);
      canvas.DrawCircle(brushGreen, 300, 150, 50);
      canvas.DrawCircle(brushBlue, 350, 100, 50);
      canvas.BlendMode = PDFBlendMode.Hue;
      canvas.DrawCircle(brushRed, 100, 300, 50);
      canvas.DrawCircle(brushGreen, 100, 350, 50);
      canvas.DrawCircle(brushBlue, 150, 300, 50);

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

VB.NET :

Imports PDFMosaic
Imports System.Drawing

Module BlendMode
  Sub Main()
    Dim document As PDFDocument = New PDFDocument()
    document.Pages.Add(New PDFPage(PDFPaperFormat.A4))
    Dim canvas As PDFCanvas = document.Pages(0).Canvas

    Dim red As PDFDeviceColor = New PDFColorRGB(255, 0, 0)
    Dim green As PDFDeviceColor = New PDFColorRGB(0, 255, 0)
    Dim blue As PDFDeviceColor = New PDFColorRGB(0, 0, 255)
    Dim brushRed As PDFSolidBrush = New PDFSolidBrush(red)
    Dim brushGreen As PDFSolidBrush = New PDFSolidBrush(green)
    Dim brushBlue As PDFSolidBrush = New PDFSolidBrush(blue)
    Dim pen As PDFSolidPen = New PDFSolidPen()

    canvas.DrawCircle(brushRed, 300, 300, 50)
    canvas.DrawCircle(brushGreen, 300, 350, 50)
    canvas.DrawCircle(brushBlue, 350, 300, 50)
    canvas.BlendMode = PDFBlendMode.Screen
    canvas.DrawCircle(brushRed, 100, 100, 50)
    canvas.DrawCircle(brushGreen, 100, 150, 50)
    canvas.DrawCircle(brushBlue, 150, 100, 50)
    canvas.BlendMode = PDFBlendMode.Darken
    canvas.DrawCircle(brushRed, 300, 100, 50)
    canvas.DrawCircle(brushGreen, 300, 150, 50)
    canvas.DrawCircle(brushBlue, 350, 100, 50)
    canvas.BlendMode = PDFBlendMode.Hue
    canvas.DrawCircle(brushRed, 100, 300, 50)
    canvas.DrawCircle(brushGreen, 100, 350, 50)
    canvas.DrawCircle(brushBlue, 150, 300, 50)

    document.Save("BlendMode.pdf", True)
  End Sub
End Module