Added a workbook that uses the NuGets

This commit is contained in:
Matthew Leibowitz 2017-02-11 20:14:50 +04:00
Родитель c3fe5b5ba0
Коммит ff4f90efad
2 изменённых файлов: 59 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,15 @@
using System;
using System.IO;
using SkiaSharp;
var assemblyLocation = Path.GetDirectoryName(typeof(SKBitmap).Assembly.Location);
var packageLocation = Path.GetDirectoryName(Path.GetDirectoryName(assemblyLocation));
var isMac = Environment.OSVersion.Platform == PlatformID.MacOSX || Environment.OSVersion.Platform == PlatformID.Unix;
var runtime = isMac ? "osx" : ("win7-" + (Environment.Is64BitProcess ? "x64" : "x86"));
var nativeName = isMac ? "libSkiaSharp.dylib" : "libSkiaSharp.dll";
var nativeLocation = Path.Combine(packageLocation, "runtimes", runtime, "native", nativeName);
var newLocation = Path.Combine(assemblyLocation, nativeName);
if (!File.Exists(newLocation)) {
File.Copy(nativeLocation, newLocation, true);
}

Просмотреть файл

@ -0,0 +1,44 @@
---
uti: com.xamarin.workbook
platforms:
- Console
packages:
- id: SkiaSharp.Svg
version: 1.56.1
- id: SkiaSharp
version: 1.56.1
---
```csharp
#r "SkiaSharp"
#r "SkiaSharp.Svg"
#load "SkiaSharp.csx"
using SkiaSharp;
```
```csharp
var bitmap = new SKBitmap(256, 256);
var canvas = new SKCanvas(bitmap);
canvas.Clear(SKColors.Transparent);
```
```csharp
canvas.Clear(SKColors.Transparent);
var paint = new SKPaint {
IsAntialias = true,
TextSize = 50,
TextAlign = SKTextAlign.Center,
Color = 0xFF3498DB, // Xamarin light blue
Style = SKPaintStyle.Fill,
Typeface = SKTypeface.FromFamilyName("Trebuchet")
};
canvas.DrawText("SkiaSharp", 128, 128 + (paint.TextSize / 2), paint);
```
```csharp
bitmap
```