Slide 8
Slide 8 text
Zeichnen mit SkiaSharp
Möglichkeiten
▪ Zeichnen von einfachen Formen
(Linien, Rechtecken, Ellipsen, ...)
▪ Individuelle Pfade
▪ Transformationen
▪ Farbverläufe, Anti-Aliasing
API
▪ Android Graphics API
▪ Pfade orientieren sich am SVG-Modell
Limitationen
▪ Keine Animations-API
▪ Keine direkte Interaktions-API
using (var paint = new SKPaint())
{
// Pfad zeichen
using (var path = new SKPath()) {
path.MoveTo(50f, 60f);
path.LineTo(100f, 60f);
path.CubicTo(100f, 60f, 90f, 100f, 50f, 100f);
path.Close();
canvas.DrawPath(path, paint);
}
// Linie zeichen
canvas.DrawLine(50, 60, 50, 100, paint);
// Rechteck zeichnen
canvas.DrawRect(new SKRect(25f, 80f, 35f, 80f), paint);
// Text rendern
var text = new SKPaint {
IsAntialias = true,
Style = SKPaintStyle.Fill,
Color = SKColors.Purple,
TextSize = 20,
};
var size = paint.MeasureText("Hallo");
canvas.DrawText("Hallo", (width / 2) - size, 20 +
text.TextSize, text);
}
Pfade und Formen zeichnen