Merge commit 'master' into dev/v1.60.0

This commit is contained in:
Matthew Leibowitz 2017-12-20 01:53:31 +02:00
Родитель cec7c8892a 0a158fdbc3
Коммит 812b9ab8dc
4 изменённых файлов: 82 добавлений и 2 удалений

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

@ -487,7 +487,6 @@ typeMask = Mask.Scale | Mask.RectStaysRect
}
}
[Obsolete ("Use SKMatrix44 instead.", true)]
public class SK3dView : SKObject
{
protected override void Dispose (bool disposing)

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

@ -16,7 +16,7 @@ namespace SkiaSharpSample.Samples
{
}
public override string Title => "3D Rotation";
public override string Title => "3D Rotation (ortho)";
protected override async Task OnInit()
{

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

@ -0,0 +1,80 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using SkiaSharp;
namespace SkiaSharpSample.Samples
{
[Preserve(AllMembers = true)]
public class ThreeDSamplePerspective : AnimatedSampleBase
{
private SK3dView rotationView;
[Preserve]
public ThreeDSamplePerspective()
{
}
public override string Title => "3D Rotation (perspective)";
protected override async Task OnInit()
{
// create the base and step 3D rotation matrices (around the y-axis)
rotationView = new SK3dView();
rotationView.RotateYDegrees(30);
await base.OnInit();
}
protected override async Task OnUpdate(CancellationToken token, TaskScheduler mainScheduler)
{
await Task.Delay(25, token);
// step the rotation matrix
rotationView.RotateYDegrees(5);
}
protected override void OnDrawSample(SKCanvas canvas, int width, int height)
{
// get the 2D equivalent of the 3D matrix
var rotationMatrix = rotationView.Matrix;
// get the properties of the rectangle
var length = Math.Min(width / 6, height / 6);
var rect = new SKRect(-length, -length, length, length);
var side = rotationMatrix.MapPoint(new SKPoint(1, 0)).X > 0;
canvas.Clear(SampleMedia.Colors.XamarinLightBlue);
// first do 2D translation to the center of the screen
canvas.Translate(width / 2, height / 2);
// then apply the 3D rotation
canvas.Concat(ref rotationMatrix);
var paint = new SKPaint
{
Color = side ? SampleMedia.Colors.XamarinPurple : SampleMedia.Colors.XamarinGreen,
Style = SKPaintStyle.Fill,
IsAntialias = true
};
canvas.DrawRoundRect(rect, 30, 30, paint);
var shadow = SKShader.CreateLinearGradient(
new SKPoint(0, 0), new SKPoint(0, length * 2),
new[] { paint.Color.WithAlpha(127), paint.Color.WithAlpha(0) },
null,
SKShaderTileMode.Clamp);
paint = new SKPaint
{
Shader = shadow,
Style = SKPaintStyle.Fill,
IsAntialias = true
};
rect.Offset(0, length * 2 + 5);
canvas.DrawRoundRect(rect, 30, 30, paint);
}
}
}

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

@ -23,6 +23,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Samples\DecodeGifFramesSample.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Samples\BitmapSubsetDecoderSample.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Samples\ThreeDSample.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Samples\ThreeDSamplePerspective.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Samples\ManipulatedBitmapShaderSample.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Samples\PathMeasureSample.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Samples\PathConicToQuadsSample.cs" />