Generate Thumbnail

Wave collapse art

Concept Imagine each image as a collection of small boxes arranged in different positions. Each image has four sides, and our goal is to determine how these images can connect to one another based on the configuration of these sides. Let’s take the example of an image: ...

July 20, 2024 · 6 min · 1130 words · PrashantUnity
Generate Thumbnail

Images on a Skia canvas

Requirements VS Code with Polyglot Notebook .Net Installed Open VS Code create new File Image.ipynb Import SkiaSharp Library Open Image.ipynb File select .Net Interactive as Kernel Create cell inside File 1 2 3 #r "nuget:SkiaSharp" using SkiaSharp; using System.IO; Image Drawer Function Create New Cell and Paste below code 1 2 3 4 5 6 7 8 9 10 11 void DrawImage(string path, SKCanvas canvas, float x = 0, float y = 0) { using (var inputStream = File.OpenRead(path)) { using (var inputBitmap = SKBitmap.Decode(inputStream)) { var imageInfo = new SKImageInfo(inputBitmap.Width, inputBitmap.Height); canvas.DrawBitmap(inputBitmap, x , y); } } } Skia SHarp Setup 1 2 3 4 5 6 7 8 9 10 11 12 int width = 1280; int height = 640; SKBitmap bmp = new(width, height); SKCanvas canvas = new(bmp); canvas.Clear(SKColor.Parse("#fff")); SKPaint paint = new() { Color = SKColors.White.WithAlpha(100), IsAntialias = true, StrokeWidth = 3, ColorF = SKColor.Parse("#003366") }; Uses of Function Created earlier for Importing Image 1 2 3 4 5 6 7 8 DrawImage("image.png", canvas,10, 10); // For saving the image as a file using (SKFileWStream fs = new("image.jpg")) { bmp.Encode(fs, SKEncodedImageFormat.Jpeg, quality: 50); } bmp.Display() That all needed to use image in SkiaSharp

July 20, 2024 · 1 min · 197 words · PrashantUnity