Setup

1
2
#r "nuget:SkiaSharp" 
using SkiaSharp;

Code fro Mosaic

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Create an image and fill it blue
int width = 1920;
int height = 700;

int step =50;
SKBitmap bmp = new(width, height);
SKCanvas canvas = new(bmp);

canvas.Clear(SKColor.Parse("#fff"));

Random rand = new();
SKPaint paint = new() 
{ 
    Color = SKColors.White.WithAlpha(100), 
    IsAntialias = true ,
    StrokeWidth = 2,
    ColorF = SKColor.Parse("#003366")
};

for(var i=0; i<height;i+=step)
{
    for(var j=0; j<width;j+=step)
    {

        if(rand.Next(0,100)>50)
            paint.ColorF =SKColor.Parse("#003366");
        else paint.Color =SKColor.Parse("#000f");
        canvas.DrawRect(i,j,step,step,paint);
    }
}
SKFileWStream fs = new("mosaic.jpg");
bmp.Encode(fs, SKEncodedImageFormat.Jpeg, quality: 50);
bmp.Display();

images