1
0
Fork 0
mirror of https://github.com/Nioux/AideDeJeu.git synced 2025-10-30 15:06:06 +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">
<ContentPage.Content>
<StackLayout>
<Label Text="Welcome to Xamarin.Forms!"
<!--<Label Text="Welcome to Xamarin.Forms!"
VerticalOptions="CenterAndExpand"
HorizontalOptions="CenterAndExpand" />
HorizontalOptions="CenterAndExpand" />-->
<skviews:SKCanvasView PaintSurface="SKCanvasView_PaintSurface">
<skviews:SKCanvasView HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" PaintSurface="SKCanvasView_PaintSurface">
</skviews:SKCanvasView>
</StackLayout>

View file

@ -33,19 +33,19 @@ namespace AideDeJeu.Views
SKImageInfo info = args.Info;
SKSurface surface = args.Surface;
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();
// Draw path with cubic Bezier curve
using (SKPath path = new SKPath())
{
path.MoveTo(0, 0);
float minx = diceRolls.Min(kv => kv.Value);
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.LineTo(diceRoll.Key * 20, diceRoll.Value * 20);
}
canvas.DrawPath(path, strokePaint);
float x = diceRoll.Value;
float y = diceRoll.Key;
canvas.DrawRect(new SKRect(0, ((y - miny) * sizey), x * info.Width / maxx, ((y - miny) * sizey) + sizey - 5), strokePaint);
}
}
}