GraphicsTester: add ScaleCanvas scenario
Add a new abstract scenario to demonstrate Canvas.Scale() with distinct X and Y scales. This test currently demonstrates a bug described by #302 where only the X scale is respected when drawing paths.
This commit is contained in:
Родитель
7fcf55c64f
Коммит
a112ced109
|
@ -0,0 +1,37 @@
|
|||
using Microsoft.Maui.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace GraphicsTester.Scenarios
|
||||
{
|
||||
internal class ScaleCanvas : AbstractScenario
|
||||
{
|
||||
public ScaleCanvas() : base(720, 1024)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Draw(ICanvas canvas)
|
||||
{
|
||||
DrawTestShapesOnScaledCanvas(canvas, 1, 1, Colors.Black);
|
||||
DrawTestShapesOnScaledCanvas(canvas, 2, 2, Colors.Magenta);
|
||||
DrawTestShapesOnScaledCanvas(canvas, 2, 1, Colors.Green);
|
||||
DrawTestShapesOnScaledCanvas(canvas, 1, 2, Colors.Orange);
|
||||
}
|
||||
|
||||
private void DrawTestShapesOnScaledCanvas(ICanvas canvas, float xScale, float yScale, Color color)
|
||||
{
|
||||
PathF path = new(100, 100);
|
||||
path.AddArc(100, 100, 200, 200, 0, 180, true);
|
||||
path.LineTo(150, 100);
|
||||
path.Close();
|
||||
|
||||
canvas.SaveState();
|
||||
canvas.Scale(xScale, yScale);
|
||||
canvas.StrokeColor = color;
|
||||
canvas.StrokeSize = 2;
|
||||
canvas.DrawPath(path);
|
||||
canvas.RestoreState();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -61,6 +61,7 @@ namespace GraphicsTester.Scenarios
|
|||
new ClipRect(),
|
||||
new SubtractFromClip(),
|
||||
new DimensionTest(),
|
||||
new ScaleCanvas(),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче