Adding a gradient sample to the Forms app

- Removing an unused count argument from CreateTwoPointConicalGradient
 - Bump the skia submodule to pick up the missing SK_API fix
This commit is contained in:
Bill Holmes 2015-11-21 08:33:19 -05:00
Родитель 808addc311
Коммит a3778ac07e
5 изменённых файлов: 48 добавлений и 6 удалений

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

@ -69,12 +69,12 @@ namespace SkiaSharp
return new SKShader (SkiaApi.sk_shader_new_sweep_gradient (ref center, colors, colorPos, colors.Length, ref localMatrix));
}
public static SKShader CreateTwoPointConicalGradient (SKPoint start, float startRadius, SKPoint end, float endRadius, SKColor [] colors, float [] colorPos, int count, SKShaderTileMode mode)
public static SKShader CreateTwoPointConicalGradient (SKPoint start, float startRadius, SKPoint end, float endRadius, SKColor [] colors, float [] colorPos, SKShaderTileMode mode)
{
return new SKShader (SkiaApi.sk_shader_new_two_point_conical_gradient (ref start, startRadius, ref end, endRadius, colors, colorPos, colors.Length, mode, IntPtr.Zero));
}
public static SKShader CreateTwoPointConicalGradient (SKPoint start, float startRadius, SKPoint end, float endRadius, SKColor [] colors, float [] colorPos, int count, SKShaderTileMode mode, SKMatrix localMatrix)
public static SKShader CreateTwoPointConicalGradient (SKPoint start, float startRadius, SKPoint end, float endRadius, SKColor [] colors, float [] colorPos, SKShaderTileMode mode, SKMatrix localMatrix)
{
return new SKShader (SkiaApi.sk_shader_new_two_point_conical_gradient (ref start, startRadius, ref end, endRadius, colors, colorPos, colors.Length, mode, ref localMatrix));
}

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

@ -373,8 +373,8 @@
public static SkiaSharp.SKShader CreateRadialGradient(SkiaSharp.SKPoint center, float radius, SkiaSharp.SKColor[] colors, System.Single[] colorPos, SkiaSharp.SKShaderTileMode mode, SkiaSharp.SKMatrix localMatrix) { return default(SkiaSharp.SKShader); }
public static SkiaSharp.SKShader CreateSweepGradient(SkiaSharp.SKPoint center, SkiaSharp.SKColor[] colors, System.Single[] colorPos) { return default(SkiaSharp.SKShader); }
public static SkiaSharp.SKShader CreateSweepGradient(SkiaSharp.SKPoint center, SkiaSharp.SKColor[] colors, System.Single[] colorPos, SkiaSharp.SKMatrix localMatrix) { return default(SkiaSharp.SKShader); }
public static SkiaSharp.SKShader CreateTwoPointConicalGradient(SkiaSharp.SKPoint start, float startRadius, SkiaSharp.SKPoint end, float endRadius, SkiaSharp.SKColor[] colors, System.Single[] colorPos, int count, SkiaSharp.SKShaderTileMode mode) { return default(SkiaSharp.SKShader); }
public static SkiaSharp.SKShader CreateTwoPointConicalGradient(SkiaSharp.SKPoint start, float startRadius, SkiaSharp.SKPoint end, float endRadius, SkiaSharp.SKColor[] colors, System.Single[] colorPos, int count, SkiaSharp.SKShaderTileMode mode, SkiaSharp.SKMatrix localMatrix) { return default(SkiaSharp.SKShader); }
public static SkiaSharp.SKShader CreateTwoPointConicalGradient(SkiaSharp.SKPoint start, float startRadius, SkiaSharp.SKPoint end, float endRadius, SkiaSharp.SKColor[] colors, System.Single[] colorPos, SkiaSharp.SKShaderTileMode mode) { return default(SkiaSharp.SKShader); }
public static SkiaSharp.SKShader CreateTwoPointConicalGradient(SkiaSharp.SKPoint start, float startRadius, SkiaSharp.SKPoint end, float endRadius, SkiaSharp.SKColor[] colors, System.Single[] colorPos, SkiaSharp.SKShaderTileMode mode, SkiaSharp.SKMatrix localMatrix) { return default(SkiaSharp.SKShader); }
public void Dispose() { }
protected virtual void Dispose(bool disposing) { }
~SKShader() { }

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

@ -129,7 +129,47 @@ namespace Skia.Forms.Demo
canvas.DrawText ("Skia", 20.0f, 224.0f, paint);
}
}
public static void DrawGradient (SKCanvas canvas, int width, int height)
{
var ltColor = SKColors.White;
var dkColor = SKColors.Black;
using (var paint = new SKPaint ()) {
using (var shader = SKShader.CreateLinearGradient (
new SKPoint (0, 0),
new SKPoint (0, height),
new [] {ltColor, dkColor},
null,
SKShaderTileMode.Clamp)) {
paint.Shader = shader;
canvas.DrawPaint (paint);
}
}
// Center and Scale the Surface
var scale = (width < height ? width : height) / (240f);
canvas.Translate (width/2f, height/2f);
canvas.Scale (scale, scale);
canvas.Translate (-128, -128);
using (var paint = new SKPaint ()) {
using (var shader = SKShader.CreateTwoPointConicalGradient (
new SKPoint (115.2f, 102.4f),
25.6f,
new SKPoint (102.4f, 102.4f),
128.0f,
new [] {ltColor, dkColor},
null,
SKShaderTileMode.Clamp
)) {
paint.Shader = shader;
canvas.DrawOval (new SKRect (51.2f, 51.2f, 204.8f, 204.8f), paint);
}
}
}
}
}

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

@ -21,7 +21,7 @@ namespace Skia.Forms.Demo
BarTextColor = Xamarin.Forms.Color.White,
};
listView.ItemsSource = new [] {"Xamagon", "Text Sample"};
listView.ItemsSource = new [] {"Xamagon", "Text Sample", "Gradient Sample"};
listView.ItemSelected += (sender, e) => {
if (e.SelectedItem == null) return;
@ -41,6 +41,8 @@ namespace Skia.Forms.Demo
return DrawHelpers.DrawXamagon;
case "Text Sample":
return DrawHelpers.TextSample;
case "Gradient Sample":
return DrawHelpers.DrawGradient;
}
throw new NotImplementedException ();

2
skia

@ -1 +1 @@
Subproject commit 2e74eb03db87ed53376401071c32315f92d8e3b3
Subproject commit fd370f0131e526963a77eb528819101cdc8eb871