| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 |
- using QuestPDF.Fluent;
- using QuestPDF.Helpers;
- using QuestPDF.Infrastructure;
- namespace QuestPDF.DocumentationExamples;
- public class ShadowExamples
- {
- [Test]
- public void Simple()
- {
- Document
- .Create(document =>
- {
- document.Page(page =>
- {
- page.MinSize(new PageSize(0, 0));
- page.MaxSize(new PageSize(1000, 1000));
- page.DefaultTextStyle(x => x.FontSize(20));
- page.Margin(50);
- page.PageColor(Colors.White);
- page.Content()
- .Border(1, Colors.Black)
- .Shadow(new BoxShadowStyle
- {
- Color = Colors.Grey.Medium,
- Blur = 5,
- Spread = 5,
- OffsetX = 5,
- OffsetY = 5
- })
- .Background(Colors.White)
- .Padding(15)
- .Text("Important content");
- });
- })
- .GenerateImages(x => $"shadow-simple.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.Best, RasterDpi = 144 });
- }
-
- [Test]
- public void OffsetX()
- {
- Document
- .Create(document =>
- {
- document.Page(page =>
- {
- page.MinSize(new PageSize(0, 0));
- page.MaxSize(new PageSize(1000, 1000));
- page.DefaultTextStyle(x => x.FontSize(20));
- page.Margin(50);
- page.PageColor(Colors.White);
- page.Content()
- .Row(row =>
- {
- row.Spacing(50);
-
- foreach (var offsetX in new[] { -10, 0, 10 })
- {
- row.ConstantItem(100)
- .AspectRatio(1)
- .Shadow(new BoxShadowStyle
- {
- Color = Colors.Grey.Darken1,
- Blur = 10,
- OffsetX = offsetX
- })
- .Background(Colors.White);
- }
- });
- });
- })
- .GenerateImages(x => $"shadow-offset-x.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.Best, RasterDpi = 144 });
- }
-
- [Test]
- public void OffsetY()
- {
- Document
- .Create(document =>
- {
- document.Page(page =>
- {
- page.MinSize(new PageSize(0, 0));
- page.MaxSize(new PageSize(1000, 1000));
- page.DefaultTextStyle(x => x.FontSize(20));
- page.Margin(50);
- page.PageColor(Colors.White);
- page.Content()
- .Row(row =>
- {
- row.Spacing(50);
-
- foreach (var offsetY in new[] { -10, 0, 10 })
- {
- row.ConstantItem(100)
- .AspectRatio(1)
- .Shadow(new BoxShadowStyle
- {
- Color = Colors.Grey.Darken2,
- Blur = 10,
- OffsetY = offsetY
- })
- .Background(Colors.White);
- }
- });
- });
- })
- .GenerateImages(x => $"shadow-offset-y.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.Best, RasterDpi = 144 });
- }
-
- [Test]
- public void Color()
- {
- Document
- .Create(document =>
- {
- document.Page(page =>
- {
- page.MinSize(new PageSize(0, 0));
- page.MaxSize(new PageSize(1000, 1000));
- page.DefaultTextStyle(x => x.FontSize(20));
- page.Margin(50);
- page.PageColor(Colors.White);
- page.Content()
- .Row(row =>
- {
- row.Spacing(50);
-
- var colors = new[]
- {
- Colors.Red.Darken2,
- Colors.Green.Darken2,
- Colors.Blue.Darken2
- };
-
- foreach (var color in colors)
- {
- row.ConstantItem(100)
- .AspectRatio(1)
- .Shadow(new BoxShadowStyle
- {
- Color = color,
- Blur = 10
- })
- .Background(Colors.White);
- }
- });
- });
- })
- .GenerateImages(x => $"shadow-color.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.Best, RasterDpi = 144 });
- }
-
- [Test]
- public void Blur()
- {
- Document
- .Create(document =>
- {
- document.Page(page =>
- {
- page.MinSize(new PageSize(0, 0));
- page.MaxSize(new PageSize(1000, 1000));
- page.DefaultTextStyle(x => x.FontSize(20));
- page.Margin(50);
- page.PageColor(Colors.White);
- page.Content()
- .Row(row =>
- {
- row.Spacing(50);
- foreach (var blur in new[] { 5, 10, 20 })
- {
- row.ConstantItem(100)
- .AspectRatio(1)
- .Shadow(new BoxShadowStyle
- {
- Color = Colors.Grey.Darken1,
- Blur = blur
- })
- .Background(Colors.White);
- }
- });
- });
- })
- .GenerateImages(x => $"shadow-blur.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.Best, RasterDpi = 144 });
- }
-
- [Test]
- public void Spread()
- {
- Document
- .Create(document =>
- {
- document.Page(page =>
- {
- page.MinSize(new PageSize(0, 0));
- page.MaxSize(new PageSize(1000, 1000));
- page.DefaultTextStyle(x => x.FontSize(20));
- page.Margin(50);
- page.PageColor(Colors.White);
- page.Content()
- .Row(row =>
- {
- row.Spacing(50);
- foreach (var spread in new[] { 0, 5, 10 })
- {
- row.ConstantItem(100)
- .AspectRatio(1)
- .Shadow(new BoxShadowStyle
- {
- Color = Colors.Grey.Darken1,
- Blur = 5,
- Spread = spread
- })
- .Background(Colors.White);
- }
- });
- });
- })
- .GenerateImages(x => $"shadow-spread.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.Best, RasterDpi = 144 });
- }
-
- [Test]
- public void NoBlur()
- {
- Document
- .Create(document =>
- {
- document.Page(page =>
- {
- page.MinSize(new PageSize(0, 0));
- page.MaxSize(new PageSize(1000, 1000));
- page.DefaultTextStyle(x => x.FontSize(20));
- page.Margin(50);
- page.PageColor(Colors.White);
- page.Content()
- .Row(row =>
- {
- row.Spacing(50);
- row.ConstantItem(100)
- .AspectRatio(1)
- .Shadow(new BoxShadowStyle
- {
- Color = Colors.Grey.Lighten1,
- Blur = 0,
- OffsetX = 8,
- OffsetY = 8
- })
- .Border(1, Colors.Black)
- .Background(Colors.White);
-
- row.ConstantItem(100)
- .AspectRatio(1)
- .Shadow(new BoxShadowStyle
- {
- Color = Colors.Grey.Lighten1,
- Blur = 0,
- OffsetX = 8,
- OffsetY = 8
- })
- .Border(1, Colors.Black)
- .CornerRadius(16)
- .Background(Colors.White);
- });
- });
- })
- .GenerateImages(x => $"shadow-no-blur.webp", new ImageGenerationSettings() { ImageFormat = ImageFormat.Webp, ImageCompressionQuality = ImageCompressionQuality.Best, RasterDpi = 144 });
- }
- }
|