Class LengthPixelScaleExtensions
Extension methods on UnitsNet.Length for constructing PixelScale values.
public static class LengthPixelScaleExtensions
- Inheritance
-
LengthPixelScaleExtensions
- Inherited Members
Methods
ToPixels(Length, double)
Creates a PixelScale where this length in world space corresponds to
pixels pixels on screen.
public static PixelScale ToPixels(this Length worldLength, double pixels)
Parameters
worldLengthLengthThe world-space length that represents one unit of the scale. Its unit becomes the Unit of the result.
pixelsdoubleThe number of screen pixels that
worldLengthoccupies.
Returns
- PixelScale
A PixelScale encoding the relationship between
worldLengthandpixels.
Examples
// One metre occupies 32 pixels
var metreScale = Length.FromMeters(1).ToPixels(32);
// One centimetre occupies 2 pixels (centimetre-unit world)
var cmScale = Length.FromCentimeters(1).ToPixels(2);