1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-30 23:16:09 +00:00

SkiaSharp

This commit is contained in:
Yan Maniez 2019-04-30 23:03:34 +02:00
parent 981cae2440
commit 7e70edb832
2 changed files with 13 additions and 13 deletions

View file

@ -5,11 +5,11 @@
x:Class="AideDeJeu.Views.DicesPage"> x:Class="AideDeJeu.Views.DicesPage">
<ContentPage.Content> <ContentPage.Content>
<StackLayout> <StackLayout>
<Label Text="Welcome to Xamarin.Forms!" <!--<Label Text="Welcome to Xamarin.Forms!"
VerticalOptions="CenterAndExpand" VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand" /> HorizontalOptions="CenterAndExpand" />-->
<skviews:SKCanvasView PaintSurface="SKCanvasView_PaintSurface"> <skviews:SKCanvasView HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" PaintSurface="SKCanvasView_PaintSurface">
</skviews:SKCanvasView> </skviews:SKCanvasView>
</StackLayout> </StackLayout>

View file

@ -33,19 +33,19 @@ namespace AideDeJeu.Views
SKImageInfo info = args.Info; SKImageInfo info = args.Info;
SKSurface surface = args.Surface; SKSurface surface = args.Surface;
SKCanvas canvas = surface.Canvas; SKCanvas canvas = surface.Canvas;
SKPaint strokePaint = new SKPaint() { Color = new SKColor(255,0,0,128) }; SKPaint strokePaint = new SKPaint() { Color = new SKColor(0x9B, 0x1C, 0x47), Style = SKPaintStyle.Stroke, StrokeWidth = 2 };
canvas.Clear(); canvas.Clear();
// Draw path with cubic Bezier curve float minx = diceRolls.Min(kv => kv.Value);
using (SKPath path = new SKPath()) float miny = diceRolls.Min(kv => kv.Key);
float maxx = diceRolls.Max(kv => kv.Value);
float maxy = diceRolls.Max(kv => kv.Key);
float sizey = info.Height / (maxy - miny + 1);
foreach (var diceRoll in diceRolls)
{ {
path.MoveTo(0, 0); float x = diceRoll.Value;
foreach (var diceRoll in diceRolls) float y = diceRoll.Key;
{ canvas.DrawRect(new SKRect(0, ((y - miny) * sizey), x * info.Width / maxx, ((y - miny) * sizey) + sizey - 5), strokePaint);
path.LineTo(diceRoll.Key * 20, diceRoll.Value * 20);
}
canvas.DrawPath(path, strokePaint);
} }
} }
} }