VegaRise.NET
Back to DOM

PercentageClass

Definition

Namespace
DOM.MeasurementUnits
Assembly
DOM.dll

Represents a percentage-style measurement used for relative document values.

Remarks

Instances either hold a nullable absolute percentage value (in the property) or an unspecified (null) state. The class provides implicit conversions from numeric types to make creating percentage values concise. Numeric inputs are clamped by the extension to a safe range before being stored. Value ToRange(double,double,double) Note: The concrete range used by the conversion is determined by the call to in the implicit operators and constructors. Consumers should be aware that values will be clamped to that range. ToRange(-10000, 10000) Percentages are used throughout the DOM for relative sizing, scaling, tinting, shading, and stop positions in gradients.

Examples

csharp
1// 1. Create from an int or double (implicit conversion)
2Percentage p1 = 50;
3Percentage p2 = 75.5;
4
csharp
1// 2. Automatic clamping to the safe range
2Percentage p = 15000; // stored as 10000
3Console.WriteLine(p.Value); // 10000
4
csharp
1// 3. Use as a DocumentUnit (relative value)
2DocumentUnit u = new Percentage(120);
3Console.WriteLine(u.Percentage.Value); // 120
4
csharp
1// 4. Use for scaling a font
2var font = new Font { Scale = new Percentage(90) }; // 90% width
3

Constructors

Percentage()

Initializes a new instance with no value set. Percentage

Percentage(int value)

Initializes a new instance from an integer value. Percentage

Percentage(double value)

Initializes a new instance from a double value. Percentage

Properties

Valuedouble

Gets or sets the percentage value.

Methods

Implicitly converts a to a . Double, Percentage

Returns a string representation of the stored percentage value.

VegaRiseVDocs.NET

Reset Password

Enter your email and we'll send you a link to reset your password.

Remember your password? Sign in