Files

60 lines
2.1 KiB
C#
Raw Permalink Normal View History

2021-12-30 21:07:34 +01:00
using Microcharts;
using NUnit.Framework;
using QuestPDF.Examples.Engine;
using QuestPDF.Fluent;
using QuestPDF.Helpers;
using QuestPDF.Infrastructure;
using SkiaSharp;
namespace QuestPDF.Examples
{
public class CanvasExamples
{
[Test]
public void BorderRadius()
{
RenderingTest
.Create()
.PageSize(175, 100)
2021-12-30 21:28:09 +01:00
.ProduceImages()
2021-12-30 21:07:34 +01:00
.ShowResults()
.Render(container =>
{
container
.Background(Colors.Grey.Lighten2)
2021-12-30 21:07:34 +01:00
.Padding(25)
.MinimalBox()
2021-12-30 21:07:34 +01:00
.Layers(layers =>
{
layers.Layer().Canvas((canvas, size) =>
{
DrawRoundedRectangle(Colors.White, false);
DrawRoundedRectangle(Colors.Blue.Darken2, true);
void DrawRoundedRectangle(string color, bool isStroke)
2021-12-30 21:07:34 +01:00
{
using var paint = new SKPaint
{
Color = SKColor.Parse(color),
IsStroke = isStroke,
StrokeWidth = 2,
IsAntialias = true
};
2021-12-30 21:07:34 +01:00
canvas.DrawRoundRect(0, 0, size.Width, size.Height, 20, 20, paint);
}
2021-12-30 21:07:34 +01:00
});
layers
.PrimaryLayer()
.PaddingVertical(10)
.PaddingHorizontal(20)
2022-03-08 17:27:30 +01:00
.Text("Sample text")
2022-03-11 13:23:36 +01:00
.FontSize(16)
.FontColor(Colors.Blue.Darken2)
2022-03-08 17:27:30 +01:00
.SemiBold();
2021-12-30 21:07:34 +01:00
});
});
}
}
}