Table of Contents

Class LengthPixelScaleExtensions

Namespace
Thunder.UnitsNET.Vectors.MonoGame
Assembly
Thunder.UnitsNET.Vectors.MonoGame.dll

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

worldLength Length

The world-space length that represents one unit of the scale. Its unit becomes the Unit of the result.

pixels double

The number of screen pixels that worldLength occupies.

Returns

PixelScale

A PixelScale encoding the relationship between worldLength and pixels.

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);
latest ▼