-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathRenderSettings.cs
More file actions
192 lines (169 loc) · 3.48 KB
/
RenderSettings.cs
File metadata and controls
192 lines (169 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
using System;
using SkiaSharp;
namespace Waher.Layout.Layout2D
{
/// <summary>
/// Affects the size of the rendered image.
/// </summary>
public enum RenderedImageSize
{
/// <summary>
/// Scales the layout to fit the desired image size.
/// </summary>
ScaleToFit,
/// <summary>
/// Resizes the output to match the size of the layout.
/// </summary>
ResizeImage
}
/// <summary>
/// Render settings.
/// </summary>
public class RenderSettings
{
private RenderedImageSize imageSize = RenderedImageSize.ResizeImage;
private int width = 800;
private int height = 600;
private float zoom = 1;
private float offsetX = 0;
private float offsetY = 0;
private SKColor backgroundColor = SKColors.White;
private SKColor penColor = SKColors.Black;
private SKColor textColor = SKColors.Black;
private string fontName = SKTypeface.Default.FamilyName;
private float fontSize = 12;
private float pixelsPerInch = 96;
/// <summary>
/// Determines the size of the rendered image.
/// </summary>
public RenderSettings()
{
}
/// <summary>
/// Offset along X-axis.
/// </summary>
public RenderedImageSize ImageSize
{
get => this.imageSize;
set => this.imageSize = value;
}
/// <summary>
/// Width of image
/// </summary>
public int Width
{
get => this.width;
set
{
if (value <= 0)
throw new ArgumentException("Invalid width.", nameof(this.Width));
this.width = value;
}
}
/// <summary>
/// Height of image
/// </summary>
public int Height
{
get => this.height;
set
{
if (value <= 0)
throw new ArgumentException("Invalid height.", nameof(this.Height));
this.height = value;
}
}
/// <summary>
/// Zoom factor
/// </summary>
public float Zoom
{
get => this.zoom;
set
{
if (value <= 0)
throw new ArgumentException("Invalid zoom factor.", nameof(this.Zoom));
this.zoom = value;
}
}
/// <summary>
/// Offset along X-axis.
/// </summary>
public float OffsetX
{
get => this.offsetX;
set => this.offsetX = value;
}
/// <summary>
/// Offset along Y-axis.
/// </summary>
public float OffsetY
{
get => this.offsetY;
set => this.offsetY = value;
}
/// <summary>
/// Background color
/// </summary>
public SKColor BackgroundColor
{
get => this.backgroundColor;
set => this.backgroundColor = value;
}
/// <summary>
/// Pen color
/// </summary>
public SKColor PenColor
{
get => this.penColor;
set => this.penColor = value;
}
/// <summary>
/// Text color
/// </summary>
public SKColor TextColor
{
get => this.textColor;
set => this.textColor = value;
}
/// <summary>
/// Font name
/// </summary>
public string FontName
{
get => this.fontName;
set
{
if (string.IsNullOrEmpty(value))
throw new ArgumentException("Invalid font name.", nameof(this.FontName));
this.fontName = value;
}
}
/// <summary>
/// Font size, in points
/// </summary>
public float FontSize
{
get => this.fontSize;
set
{
if (value <= 0)
throw new ArgumentException("Invalid font size.", nameof(this.FontSize));
this.fontSize = value;
}
}
/// <summary>
/// Pixels per inch (default=96 pixels/inch)
/// </summary>
public float PixelsPerInch
{
get => this.pixelsPerInch;
set
{
if (value <= 0)
throw new ArgumentException("Invalid number of pixels per inch.", nameof(this.PixelsPerInch));
this.pixelsPerInch = value;
}
}
}
}