mirror of
https://github.com/Nioux/AideDeJeu.git
synced 2025-12-16 15:19:56 +00:00
SkiaSharp
This commit is contained in:
parent
981cae2440
commit
7e70edb832
2 changed files with 13 additions and 13 deletions
|
|
@ -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>
|
||||||
|
|
|
||||||
|
|
@ -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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue