* Add support for multi-thread wasm blazor * Order the folder name parts (#2774) * this * handle the matrix of st/mt and /simd/non-simd * Merge remote-tracking branch 'origin/main' into dev/mt-main # Conflicts: # scripts/azure-templates-stages.yml * wasm things * Added a sample
38 lines
1 KiB
C#
38 lines
1 KiB
C#
using System.Runtime.InteropServices.JavaScript;
|
|
using SkiaSharp;
|
|
|
|
Console.WriteLine("Hello, Browser!");
|
|
Console.WriteLine("Your platform color type is " + SKImageInfo.PlatformColorType);
|
|
|
|
// crate a surface
|
|
var info = new SKImageInfo(256, 256);
|
|
using var bitmap = new SKBitmap(info);
|
|
|
|
// the the canvas and properties
|
|
using var canvas = new SKCanvas(bitmap);
|
|
|
|
// make sure the canvas is blank
|
|
canvas.Clear(SKColors.White);
|
|
|
|
// draw some text
|
|
using var paint = new SKPaint
|
|
{
|
|
Color = SKColors.Black,
|
|
IsAntialias = true,
|
|
Style = SKPaintStyle.Fill
|
|
};
|
|
using var font = new SKFont
|
|
{
|
|
Size = 24
|
|
};
|
|
var coord = new SKPoint(info.Width / 2, (info.Height + font.Size) / 2);
|
|
canvas.DrawText("SkiaSharp", coord, SKTextAlign.Center, font, paint);
|
|
|
|
// render the image
|
|
Renderer.Render(info.Width, info.Height, bitmap.GetPixelSpan());
|
|
|
|
partial class Renderer
|
|
{
|
|
[JSImport("renderer.render", "main.js")]
|
|
internal static partial void Render(int width, int height, [JSMarshalAs<JSType.MemoryView>] Span<byte> buffer);
|
|
}
|