|
2 | 2 |
|
3 | 3 | namespace Json_exe.Blazor.Cropper.Model; |
4 | 4 |
|
| 5 | +/// <summary> |
| 6 | +/// Represents the cropping data of an image, including position, size, rotation, and scaling factors. |
| 7 | +/// </summary> |
5 | 8 | public record CropData |
6 | 9 | { |
7 | | - public double X { get; set; } |
8 | | - public double Y { get; set; } |
9 | | - public double Width { get; set; } |
10 | | - public double Height { get; set; } |
11 | | - public double Rotate { get; set; } |
12 | | - public double ScaleX { get; set; } |
13 | | - public double ScaleY { get; set; } |
| 10 | + /// <summary> |
| 11 | + /// The horizontal position of the cropping area on the source image. |
| 12 | + /// </summary> |
| 13 | + public double X { get; init; } |
| 14 | + |
| 15 | + /// <summary> |
| 16 | + /// The vertical position of the cropping area on the source image. |
| 17 | + /// </summary> |
| 18 | + public double Y { get; init; } |
| 19 | + |
| 20 | + /// <summary> |
| 21 | + /// The width dimension of the object, typically used to define size or scale in rendering or cropping contexts. |
| 22 | + /// </summary> |
| 23 | + public double Width { get; init; } |
| 24 | + |
| 25 | + /// <summary> |
| 26 | + /// The destination height of the output canvas. |
| 27 | + /// </summary> |
| 28 | + public double Height { get; init; } |
| 29 | + |
| 30 | + /// <summary> |
| 31 | + /// The rotation angle of the cropped image, in degrees. |
| 32 | + /// </summary> |
| 33 | + public double Rotate { get; init; } |
| 34 | + |
| 35 | + /// <summary> |
| 36 | + /// The horizontal scaling factor applied to the image during cropping. |
| 37 | + /// </summary> |
| 38 | + public double ScaleX { get; init; } |
| 39 | + |
| 40 | + /// <summary> |
| 41 | + /// The vertical scaling factor applied to the image during cropping. |
| 42 | + /// </summary> |
| 43 | + public double ScaleY { get; init; } |
14 | 44 | } |
15 | 45 |
|
| 46 | +/// <summary> |
| 47 | +/// Represents configurable options for customizing the output canvas of a cropped image, |
| 48 | +/// including canvas dimensions, color settings, and image smoothing properties. |
| 49 | +/// Read more at: https://github.com/fengyuanchen/cropperjs/blob/v1/README.md#getcroppedcanvasoptions |
| 50 | +/// </summary> |
16 | 51 | public sealed class CropCanvasOptions |
17 | 52 | { |
18 | 53 | /// <summary> |
19 | 54 | /// The destination width of the output canvas. |
20 | 55 | /// </summary> |
21 | 56 | public double Width { get; set; } |
| 57 | + |
22 | 58 | /// <summary> |
23 | 59 | /// The destination height of the output canvas. |
24 | 60 | /// </summary> |
25 | 61 | public double Height { get; set; } |
| 62 | + |
26 | 63 | /// <summary> |
27 | 64 | /// The minimum destination width of the output canvas. |
28 | 65 | /// </summary> |
29 | 66 | public double MinWidth { get; set; } = 0; |
| 67 | + |
30 | 68 | /// <summary> |
31 | 69 | /// The minimum destination height of the output canvas. |
32 | 70 | /// </summary> |
33 | 71 | public double MinHeight { get; set; } = 0; |
| 72 | + |
34 | 73 | /// <summary> |
35 | 74 | /// The maximum destination width of the output canvas. |
36 | 75 | /// </summary> |
37 | 76 | [JsonNumberHandling(JsonNumberHandling.AllowNamedFloatingPointLiterals)] |
38 | 77 | public double MaxWidth { get; set; } = double.PositiveInfinity; |
| 78 | + |
39 | 79 | /// <summary> |
40 | 80 | /// The maximum destination height of the output canvas. |
41 | 81 | /// </summary> |
42 | 82 | [JsonNumberHandling(JsonNumberHandling.AllowNamedFloatingPointLiterals)] |
43 | 83 | public double MaxHeight { get; set; } = double.PositiveInfinity; |
| 84 | + |
44 | 85 | /// <summary> |
45 | 86 | /// A color to fill any alpha values in the output canvas. |
46 | 87 | /// </summary> |
47 | 88 | public string FillColor { get; set; } = "transparent"; |
| 89 | + |
48 | 90 | /// <summary> |
49 | 91 | /// Set to change if images are smoothed or not. |
50 | 92 | /// </summary> |
51 | 93 | public bool ImageSmoothingEnabled { get; set; } = true; |
| 94 | + |
52 | 95 | /// <summary> |
53 | 96 | /// Set the quality of image smoothing. |
54 | 97 | /// </summary> |
55 | 98 | [JsonConverter(typeof(JsonStringEnumConverter))] |
56 | 99 | public ImageSmoothingQuality ImageSmoothingQuality { get; set; } = ImageSmoothingQuality.low; |
| 100 | + |
57 | 101 | /// <summary> |
58 | 102 | /// Set to true to use rounded values. |
59 | 103 | /// </summary> |
60 | 104 | public bool Rounded { get; set; } = false; |
61 | 105 | } |
62 | 106 |
|
| 107 | +/// <summary> |
| 108 | +/// Defines the quality levels for image smoothing when rendering a cropped image on a canvas. |
| 109 | +/// </summary> |
63 | 110 | public enum ImageSmoothingQuality |
64 | 111 | { |
65 | 112 | low, |
|
0 commit comments