VectSharp  2.2.1
A light library for C# vector graphics
Brush.cs
1 /*
2  VectSharp - A light library for C# vector graphics.
3  Copyright (C) 2020-2022 Giorgio Bianchini
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, version 3.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public License
15  along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17 
18 using System;
19 using System.Collections;
20 using System.Collections.Generic;
21 using System.Collections.Immutable;
22 using System.Linq;
23 using System.Text;
24 
25 namespace VectSharp
26 {
27  /// <summary>
28  /// Represents a brush used to fill or stroke graphics elements. This could be a solid colour, or a more complicated gradient or pattern.
29  /// </summary>
30  public abstract class Brush
31  {
32  internal Brush() { }
33 
34  /// <summary>
35  /// Returns a brush corresponding the current instance, with the specified <paramref name="opacity"/> multiplication applied.
36  /// </summary>
37  /// <param name="opacity">The value that will be used to multiply the opacity of the brush.</param>
38  /// <returns>A brush corresponding the current instance, with the specified <paramref name="opacity"/> multiplication applied.</returns>
39  public abstract Brush MultiplyOpacity(double opacity);
40 
41  /// <summary>
42  /// Implicitly converts a <see cref="Colour"/> into a <see cref="SolidColourBrush"/>.
43  /// </summary>
44  /// <param name="colour">The <see cref="Colour"/> to use for the brush.</param>
45  public static implicit operator Brush(Colour colour)
46  {
47  return new SolidColourBrush(colour);
48  }
49  }
50 
51  /// <summary>
52  /// Represents a brush painting with a single solid colour.
53  /// </summary>
54  public class SolidColourBrush : Brush
55  {
56  /// <summary>
57  /// The colour of the brush.
58  /// </summary>
59  public Colour Colour { get; }
60 
61  /// <summary>
62  /// Red component of the colour. Range: [0, 1].
63  /// </summary>
64  public double R => Colour.R;
65 
66  /// <summary>
67  /// Green component of the colour. Range: [0, 1].
68  /// </summary>
69  public double G => Colour.G;
70 
71  /// <summary>
72  /// Blue component of the colour. Range: [0, 1].
73  /// </summary>
74  public double B => Colour.B;
75 
76  /// <summary>
77  /// Alpha component of the colour. Range: [0, 1].
78  /// </summary>
79  public double A => Colour.A;
80 
81  /// <summary>
82  /// Creates a new <see cref="SolidColourBrush"/> with the specified <paramref name="colour"/>.
83  /// </summary>
84  /// <param name="colour">The <see cref="Colour"/> to use for the brush.</param>
85  public SolidColourBrush(Colour colour)
86  {
87  this.Colour = colour;
88  }
89 
90  /// <inheritdoc/>
91  public override Brush MultiplyOpacity(double opacity)
92  {
93  return new SolidColourBrush(this.Colour.WithAlpha(this.Colour.A * opacity));
94  }
95 
96  /// <summary>
97  /// Implicitly converts a <see cref="Colour"/> into a <see cref="SolidColourBrush"/>.
98  /// </summary>
99  /// <param name="colour">The <see cref="Colour"/> to use for the brush.</param>
100  public static implicit operator SolidColourBrush(Colour colour)
101  {
102  return new SolidColourBrush(colour);
103  }
104  }
105 
106  /// <summary>
107  /// Represents a colour stop in a gradient.
108  /// </summary>
109  public struct GradientStop
110  {
111  /// <summary>
112  /// The <see cref="Colour"/> at the gradient stop.
113  /// </summary>
114  public Colour Colour { get; }
115 
116  /// <summary>
117  /// The offset of the gradient stop. Range: [0, 1].
118  /// </summary>
119  public double Offset { get; }
120 
121  /// <summary>
122  /// Creates a new <see cref="GradientStop"/> instance.
123  /// </summary>
124  /// <param name="colour">The <see cref="Colour"/> at the gradient stop.</param>
125  /// <param name="offset">The offset of the gradient stop. Range: [0, 1].</param>
126  public GradientStop(Colour colour, double offset)
127  {
128  this.Colour = colour;
129  this.Offset = Math.Max(0, Math.Min(1, offset));
130  }
131 
132  /// <summary>
133  /// Returns a <see cref="GradientStop"/> corresponding to the current instance, whose colour's opacity has been multiplied by the specified value.
134  /// </summary>
135  /// <param name="opacity">The value that will be used to multiply the colour's opacity.</param>
136  /// <returns>A <see cref="GradientStop"/> corresponding to the current instance, whose colour's opacity has been multiplied by the specified value.</returns>
137  public GradientStop MultiplyOpacity(double opacity)
138  {
139  return new GradientStop(this.Colour.WithAlpha(this.Colour.A * opacity), this.Offset);
140  }
141  }
142 
143  /// <summary>
144  /// Represents a read-only list of <see cref="GradientStop"/>s.
145  /// </summary>
146  public class GradientStops : IReadOnlyList<GradientStop>
147  {
148  /// <summary>
149  /// The minimum distance that is enforced between consecutive gradient stops.
150  /// </summary>
151  public static readonly double StopTolerance = 1e-7;
152 
153  /// <inheritdoc/>
154  public GradientStop this[int index] => gradientStops[index];
155 
156  /// <inheritdoc/>
157  public int Count => gradientStops.Count;
158 
159  private ImmutableList<GradientStop> gradientStops { get; set; }
160 
161  /// <inheritdoc/>
162  public IEnumerator<GradientStop> GetEnumerator()
163  {
164  return ((IEnumerable<GradientStop>)gradientStops).GetEnumerator();
165  }
166 
167  IEnumerator IEnumerable.GetEnumerator()
168  {
169  return ((IEnumerable)gradientStops).GetEnumerator();
170  }
171 
172  /// <summary>
173  /// Creates a new <see cref="GradientStops"/> instance containing the specified gradient stops.
174  /// </summary>
175  /// <param name="gradientStops">The gradient stops that will be contained in the <see cref="GradientStops"/> object.</param>
176  public GradientStops(IEnumerable<GradientStop> gradientStops)
177  {
178  List<GradientStop> stops = (from el in gradientStops orderby el.Offset ascending select el).ToList();
179 
180  if (stops.Count == 0)
181  {
182  stops.Add(new GradientStop(Colour.FromRgba(0, 0, 0, 0), 0));
183  }
184 
185  if (stops[0].Offset > 0)
186  {
187  stops.Insert(0, new GradientStop(stops[0].Colour, 0));
188  }
189 
190  if (stops[stops.Count - 1].Offset < 1)
191  {
192  stops.Add(new GradientStop(stops[stops.Count - 1].Colour, 1));
193  }
194 
195  for (int i = 1; i < stops.Count - 1; i++)
196  {
197  bool closeToPrevious = (stops[i].Offset - stops[i - 1].Offset < StopTolerance);
198  bool closeToNext = (stops[i + 1].Offset - stops[i].Offset < StopTolerance);
199 
200  if (closeToPrevious && !closeToNext)
201  {
202  stops[i] = new GradientStop(stops[i].Colour, stops[i - 1].Offset + StopTolerance);
203  }
204  else if (!closeToPrevious && closeToNext)
205  {
206  stops[i] = new GradientStop(stops[i].Colour, stops[i + 1].Offset - StopTolerance);
207  }
208  else if (closeToPrevious && closeToNext)
209  {
210  stops.RemoveAt(i);
211  i--;
212  }
213  }
214 
215  this.gradientStops = ImmutableList.Create(stops.ToArray());
216  }
217 
218  /// <summary>
219  /// Creates a new <see cref="GradientStops"/> instance containing the specified gradient stops.
220  /// </summary>
221  /// <param name="gradientStops">The gradient stops that will be contained in the <see cref="GradientStops"/> object.</param>
222  public GradientStops(params GradientStop[] gradientStops) : this((IEnumerable<GradientStop>)gradientStops)
223  {
224 
225  }
226  }
227 
228  /// <summary>
229  /// Represents a brush painting with a gradient.
230  /// </summary>
231  public abstract class GradientBrush : Brush
232  {
233  /// <summary>
234  /// The colour stops in the gradient.
235  /// </summary>
236  public GradientStops GradientStops { get; protected internal set; }
237 
238  internal GradientBrush() { }
239  }
240 
241  /// <summary>
242  /// Represents a brush painting with a linear gradient.
243  /// </summary>
245  {
246  /// <summary>
247  /// The starting point of the gradient. Note that this is relative to the current coordinate system when the gradient is used.
248  /// </summary>
249  public Point StartPoint { get; }
250 
251  /// <summary>
252  /// The end point of the gradient. Note that this is relative to the current coordinate system when the gradient is used.
253  /// </summary>
254  public Point EndPoint { get; }
255 
256  /// <summary>
257  /// Creates a new <see cref="LinearGradientBrush"/> with the specified start point, end point and gradient stops.
258  /// </summary>
259  /// <param name="startPoint">The starting point of the gradient. Note that this is relative to the current coordinate system when the gradient is used.</param>
260  /// <param name="endPoint">The ending point of the gradient. Note that this is relative to the current coordinate system when the gradient is used.</param>
261  /// <param name="gradientStops">The colour stops in the gradient.</param>
262  public LinearGradientBrush(Point startPoint, Point endPoint, IEnumerable<GradientStop> gradientStops)
263  {
264  this.StartPoint = startPoint;
265  this.EndPoint = endPoint;
266 
267  this.GradientStops = new GradientStops(gradientStops);
268  }
269 
270  /// <summary>
271  /// Creates a new <see cref="LinearGradientBrush"/> with the specified start point, end point and gradient stops.
272  /// </summary>
273  /// <param name="startPoint">The starting point of the gradient. Note that this is relative to the current coordinate system when the gradient is used.</param>
274  /// <param name="endPoint">The ending point of the gradient. Note that this is relative to the current coordinate system when the gradient is used.</param>
275  /// <param name="gradientStops">The colour stops in the gradient.</param>
276  public LinearGradientBrush(Point startPoint, Point endPoint, params GradientStop[] gradientStops)
277  {
278  this.StartPoint = startPoint;
279  this.EndPoint = endPoint;
280  List<GradientStop> stops = (from el in gradientStops orderby el.Offset ascending select el).ToList();
281 
282  if (stops.Count == 0)
283  {
284  stops.Add(new GradientStop(Colour.FromRgba(0, 0, 0, 0), 0));
285  }
286 
287  if (stops[0].Offset > 0)
288  {
289  stops.Insert(0, new GradientStop(stops[0].Colour, 0));
290  }
291 
292  if (stops[stops.Count - 1].Offset < 1)
293  {
294  stops.Add(new GradientStop(stops[stops.Count - 1].Colour, 1));
295  }
296 
297  this.GradientStops = new GradientStops(gradientStops);
298  }
299 
300  /// <summary>
301  /// Returns a <see cref="LinearGradientBrush"/> with the same gradient stops as the current instance, whose start and end point correspond to the points of the current instance in the
302  /// original reference frame of the <paramref name="referenceGraphics"/>. This involves computing the current transform matrix of the <paramref name="referenceGraphics" />, inverting it,
303  /// and applying the inverse matrix to the <see cref="StartPoint"/> and <see cref="EndPoint"/> of the current instance.
304  /// </summary>
305  /// <param name="referenceGraphics">The <see cref="Graphics"/> whose original reference frame is to be used.</param>
306  /// <returns>A <see cref="LinearGradientBrush"/> with the same gradient stops as the current instance, whose start and end point correspond to the points of the current instance in the
307  /// original reference frame of the <paramref name="referenceGraphics"/>.</returns>
308  public LinearGradientBrush RelativeTo(Graphics referenceGraphics)
309  {
310  Stack<double[,]> transformMatrix = new Stack<double[,]>();
311  double[,] currMatrix = new double[3, 3] { { 1, 0, 0 }, { 0, 1, 0 }, { 0, 0, 1 } };
312 
313  for (int i = 0; i < referenceGraphics.Actions.Count; i++)
314  {
315  if (referenceGraphics.Actions[i] is TransformAction)
316  {
317  TransformAction trf = referenceGraphics.Actions[i] as TransformAction;
318 
319  if (trf.Delta != null)
320  {
321  currMatrix = Graphics.Multiply(currMatrix, Graphics.TranslationMatrix(trf.Delta.Value.X, trf.Delta.Value.Y));
322  }
323  else if (trf.Angle != null)
324  {
325  currMatrix = Graphics.Multiply(currMatrix, Graphics.RotationMatrix(trf.Angle.Value));
326  }
327  else if (trf.Scale != null)
328  {
329  currMatrix = Graphics.Multiply(currMatrix, Graphics.ScaleMatrix(trf.Scale.Value.Width, trf.Scale.Value.Height));
330  }
331  else if (trf.Matrix != null)
332  {
333  currMatrix = Graphics.Multiply(currMatrix, trf.Matrix);
334  }
335  }
336  else if (referenceGraphics.Actions[i] is StateAction)
337  {
338  if (((StateAction)referenceGraphics.Actions[i]).StateActionType == StateAction.StateActionTypes.Save)
339  {
340  transformMatrix.Push(currMatrix);
341  }
342  else
343  {
344  currMatrix = transformMatrix.Pop();
345  }
346  }
347  }
348 
349  currMatrix = Graphics.Invert(currMatrix);
350 
351  Point p1 = Graphics.Multiply(currMatrix, this.StartPoint);
352  Point p2 = Graphics.Multiply(currMatrix, this.EndPoint);
353 
354  return new LinearGradientBrush(p1, p2, this.GradientStops);
355  }
356 
357  /// <inheritdoc/>
358  public override Brush MultiplyOpacity(double opacity)
359  {
360  return new LinearGradientBrush(this.StartPoint, this.EndPoint, from el in this.GradientStops select el.MultiplyOpacity(opacity));
361  }
362  }
363 
364  /// <summary>
365  /// Represents a brush painting with a radial gradient.
366  /// </summary>
368  {
369  /// <summary>
370  /// The focal point of the gradient (i.e. the point within the circle where the gradient starts).
371  /// </summary>
372  public Point FocalPoint { get; }
373 
374  /// <summary>
375  /// Represents the centre of the gradient.
376  /// </summary>
377  public Point Centre { get; }
378 
379  /// <summary>
380  /// The radius of the gradient.
381  /// </summary>
382  public double Radius { get; }
383 
384  /// <summary>
385  /// Creates a new <see cref="RadialGradientBrush"/> with the specified focal point, centre, radius and gradient stops.
386  /// </summary>
387  /// <param name="focalPoint">The focal point of the gradient. Note that this is relative to the current coordinate system when the gradient is used.</param>
388  /// <param name="centre">The centre of the gradient. Note that this is relative to the current coordinate system when the gradient is used.</param>
389  /// <param name="radius">The radius of the gradient. Note that this is relative to the current coordinate system when the gradient is used.</param>
390  /// <param name="gradientStops">The colour stops in the gradient.</param>
391  public RadialGradientBrush(Point focalPoint, Point centre, double radius, params GradientStop[] gradientStops)
392  {
393  if (new Point(focalPoint.X - centre.X, focalPoint.Y - centre.Y).Modulus() > radius)
394  {
395  Point norm = new Point(focalPoint.X - centre.X, focalPoint.Y - centre.Y).Normalize();
396  focalPoint = new Point(centre.X + norm.X * radius, centre.Y + norm.Y * radius);
397  }
398 
399  this.FocalPoint = focalPoint;
400  this.Centre = centre;
401  this.Radius = radius;
402 
403  List<GradientStop> stops = (from el in gradientStops orderby el.Offset ascending select el).ToList();
404 
405  if (stops.Count == 0)
406  {
407  stops.Add(new GradientStop(Colour.FromRgba(0, 0, 0, 0), 0));
408  }
409 
410  if (stops[0].Offset > 0)
411  {
412  stops.Insert(0, new GradientStop(stops[0].Colour, 0));
413  }
414 
415  if (stops[stops.Count - 1].Offset < 1)
416  {
417  stops.Add(new GradientStop(stops[stops.Count - 1].Colour, 1));
418  }
419 
420  this.GradientStops = new GradientStops(gradientStops);
421  }
422 
423  /// <summary>
424  /// Creates a new <see cref="RadialGradientBrush"/> with the specified focal point, centre, radius and gradient stops.
425  /// </summary>
426  /// <param name="focalPoint">The focal point of the gradient. Note that this is relative to the current coordinate system when the gradient is used.</param>
427  /// <param name="centre">The centre of the gradient. Note that this is relative to the current coordinate system when the gradient is used.</param>
428  /// <param name="radius">The radius of the gradient. Note that this is relative to the current coordinate system when the gradient is used.</param>
429  /// <param name="gradientStops">The colour stops in the gradient.</param>
430  public RadialGradientBrush(Point focalPoint, Point centre, double radius, IEnumerable<GradientStop> gradientStops)
431  {
432  if (new Point(focalPoint.X - centre.X, focalPoint.Y - centre.Y).Modulus() > radius)
433  {
434  Point norm = new Point(focalPoint.X - centre.X, focalPoint.Y - centre.Y).Normalize();
435  focalPoint = new Point(centre.X + norm.X * radius, centre.Y + norm.Y * radius);
436  }
437 
438  this.FocalPoint = focalPoint;
439  this.Centre = centre;
440  this.Radius = radius;
441 
442  List<GradientStop> stops = (from el in gradientStops orderby el.Offset ascending select el).ToList();
443 
444  if (stops.Count == 0)
445  {
446  stops.Add(new GradientStop(Colour.FromRgba(0, 0, 0, 0), 0));
447  }
448 
449  if (stops[0].Offset > 0)
450  {
451  stops.Insert(0, new GradientStop(stops[0].Colour, 0));
452  }
453 
454  if (stops[stops.Count - 1].Offset < 1)
455  {
456  stops.Add(new GradientStop(stops[stops.Count - 1].Colour, 1));
457  }
458 
459  this.GradientStops = new GradientStops(gradientStops);
460  }
461 
462  /// <inheritdoc/>
463  public override Brush MultiplyOpacity(double opacity)
464  {
465  return new RadialGradientBrush(this.FocalPoint, this.Centre, this.Radius, from el in this.GradientStops select el.MultiplyOpacity(opacity));
466  }
467  }
468 }
VectSharp.LinearGradientBrush.LinearGradientBrush
LinearGradientBrush(Point startPoint, Point endPoint, params GradientStop[] gradientStops)
Creates a new LinearGradientBrush with the specified start point, end point and gradient stops.
Definition: Brush.cs:276
VectSharp.GradientStops
Represents a read-only list of GradientStops.
Definition: Brush.cs:147
VectSharp.RadialGradientBrush.MultiplyOpacity
override Brush MultiplyOpacity(double opacity)
Returns a brush corresponding the current instance, with the specified opacity multiplication applie...
Definition: Brush.cs:463
VectSharp.SolidColourBrush.R
double R
Red component of the colour. Range: [0, 1].
Definition: Brush.cs:64
VectSharp.Colour
Represents an RGB colour.
Definition: Colour.cs:26
VectSharp.GradientStop.Offset
double Offset
The offset of the gradient stop. Range: [0, 1].
Definition: Brush.cs:119
VectSharp.Colour.R
double R
Red component of the colour. Range: [0, 1].
Definition: Colour.cs:30
VectSharp.SolidColourBrush.A
double A
Alpha component of the colour. Range: [0, 1].
Definition: Brush.cs:79
VectSharp.LinearGradientBrush.RelativeTo
LinearGradientBrush RelativeTo(Graphics referenceGraphics)
Returns a LinearGradientBrush with the same gradient stops as the current instance,...
Definition: Brush.cs:308
VectSharp.GradientStops.GradientStops
GradientStops(IEnumerable< GradientStop > gradientStops)
Creates a new GradientStops instance containing the specified gradient stops.
Definition: Brush.cs:176
VectSharp
Definition: Brush.cs:26
VectSharp.GradientStops.StopTolerance
static readonly double StopTolerance
The minimum distance that is enforced between consecutive gradient stops.
Definition: Brush.cs:151
VectSharp.Brush
Represents a brush used to fill or stroke graphics elements. This could be a solid colour,...
Definition: Brush.cs:31
VectSharp.RadialGradientBrush
Represents a brush painting with a radial gradient.
Definition: Brush.cs:368
VectSharp.GradientBrush.GradientStops
GradientStops GradientStops
The colour stops in the gradient.
Definition: Brush.cs:236
VectSharp.Colour.A
double A
Alpha component of the colour. Range: [0, 1].
Definition: Colour.cs:45
VectSharp.RadialGradientBrush.RadialGradientBrush
RadialGradientBrush(Point focalPoint, Point centre, double radius, params GradientStop[] gradientStops)
Creates a new RadialGradientBrush with the specified focal point, centre, radius and gradient stops.
Definition: Brush.cs:391
VectSharp.GradientStops.Count
int Count
Definition: Brush.cs:157
VectSharp.SolidColourBrush.MultiplyOpacity
override Brush MultiplyOpacity(double opacity)
Returns a brush corresponding the current instance, with the specified opacity multiplication applie...
Definition: Brush.cs:91
VectSharp.Point.Modulus
double Modulus()
Computes the modulus of the vector represented by the Point.
Definition: Point.cs:54
VectSharp.LinearGradientBrush.LinearGradientBrush
LinearGradientBrush(Point startPoint, Point endPoint, IEnumerable< GradientStop > gradientStops)
Creates a new LinearGradientBrush with the specified start point, end point and gradient stops.
Definition: Brush.cs:262
VectSharp.Graphics
Represents an abstract drawing surface.
Definition: Graphics.cs:262
VectSharp.Colour.WithAlpha
static Colour WithAlpha(Colour original, double alpha)
Create a new Colour with the same RGB components as the original Colour, but with the specified alph...
Definition: Colour.cs:330
VectSharp.SolidColourBrush.G
double G
Green component of the colour. Range: [0, 1].
Definition: Brush.cs:69
VectSharp.LinearGradientBrush.EndPoint
Point EndPoint
The end point of the gradient. Note that this is relative to the current coordinate system when the g...
Definition: Brush.cs:254
VectSharp.GradientStop
Represents a colour stop in a gradient.
Definition: Brush.cs:110
VectSharp.RadialGradientBrush.Radius
double Radius
The radius of the gradient.
Definition: Brush.cs:382
VectSharp.GradientBrush
Represents a brush painting with a gradient.
Definition: Brush.cs:232
VectSharp.SolidColourBrush.SolidColourBrush
SolidColourBrush(Colour colour)
Creates a new SolidColourBrush with the specified colour .
Definition: Brush.cs:85
VectSharp.GradientStops.GetEnumerator
IEnumerator< GradientStop > GetEnumerator()
Definition: Brush.cs:162
VectSharp.LinearGradientBrush.StartPoint
Point StartPoint
The starting point of the gradient. Note that this is relative to the current coordinate system when ...
Definition: Brush.cs:249
VectSharp.Colour.B
double B
Blue component of the colour. Range: [0, 1].
Definition: Colour.cs:40
VectSharp.Point.X
double X
Horizontal (x) coordinate, measured to the right of the origin.
Definition: Point.cs:32
VectSharp.GradientStop.MultiplyOpacity
GradientStop MultiplyOpacity(double opacity)
Returns a GradientStop corresponding to the current instance, whose colour's opacity has been multipl...
Definition: Brush.cs:137
VectSharp.LinearGradientBrush
Represents a brush painting with a linear gradient.
Definition: Brush.cs:245
VectSharp.GradientStops.GradientStops
GradientStops(params GradientStop[] gradientStops)
Creates a new GradientStops instance containing the specified gradient stops.
Definition: Brush.cs:222
VectSharp.RadialGradientBrush.Centre
Point Centre
Represents the centre of the gradient.
Definition: Brush.cs:377
VectSharp.SolidColourBrush
Represents a brush painting with a single solid colour.
Definition: Brush.cs:55
VectSharp.Point.Normalize
Point Normalize()
Normalises a Point.
Definition: Point.cs:63
VectSharp.Point
Represents a point relative to an origin in the top-left corner.
Definition: Point.cs:28
VectSharp.RadialGradientBrush.FocalPoint
Point FocalPoint
The focal point of the gradient (i.e. the point within the circle where the gradient starts).
Definition: Brush.cs:372
VectSharp.SolidColourBrush.B
double B
Blue component of the colour. Range: [0, 1].
Definition: Brush.cs:74
VectSharp.LinearGradientBrush.MultiplyOpacity
override Brush MultiplyOpacity(double opacity)
Returns a brush corresponding the current instance, with the specified opacity multiplication applie...
Definition: Brush.cs:358
VectSharp.Colour.G
double G
Green component of the colour. Range: [0, 1].
Definition: Colour.cs:35
VectSharp.Point.Y
double Y
Vertical (y) coordinate, measured to the bottom of the origin.
Definition: Point.cs:37
VectSharp.GradientStop.GradientStop
GradientStop(Colour colour, double offset)
Creates a new GradientStop instance.
Definition: Brush.cs:126
VectSharp.Brush.MultiplyOpacity
abstract Brush MultiplyOpacity(double opacity)
Returns a brush corresponding the current instance, with the specified opacity multiplication applie...
VectSharp.RadialGradientBrush.RadialGradientBrush
RadialGradientBrush(Point focalPoint, Point centre, double radius, IEnumerable< GradientStop > gradientStops)
Creates a new RadialGradientBrush with the specified focal point, centre, radius and gradient stops.
Definition: Brush.cs:430
VectSharp.Colour.FromRgba
static Colour FromRgba(double r, double g, double b, double a)
Create a new colour from RGBA (red, green, blue and alpha) values.
Definition: Colour.cs:99