Wanzyee Studio
Span

Define a numeric range. More...

Public Member Functions

 Span (float a, float z)
 Initialize with the specified values. More...
 
override string ToString ()
 Return a string of the a and z. More...
 
string ToString (string format)
 Return a string of the a and z. More...
 
bool Contains (float value)
 Determine if the value is within this span. More...
 
float Shuffle ()
 Get a random value within this span. More...
 
float Clamp (float value)
 Get the value clamped by this span. More...
 
float Lerp (float t, bool clamp=true)
 Linearly interpolate between span by the fraction t. More...
 
float InverseLerp (float value, bool clamp=true)
 Calculates the interpolation parameter between this span. More...
 

Static Public Member Functions

static bool TryParse (string s, out Span result)
 Try to parse a string to Span. More...
 
static Span Parse (string s)
 Parse a string to Span. More...
 

Public Attributes

float a
 The start value. More...
 
float z
 The end value. More...
 

Properties

float size [get, set]
 The distance from a to z, negative if z is smaller. More...
 
float center [get, set]
 The center between a and z, keep the size when setting. More...
 
float min [get, set]
 The min value of a and z, keep the sides when setting. More...
 
float max [get, set]
 The max value of a and z, keep the sides when setting. More...
 

Detailed Description

Define a numeric range.

Constructor & Destructor Documentation

Span ( float  a,
float  z 
)

Initialize with the specified values.

Parameters
aThe start value.
zThe end value.

Member Function Documentation

static bool TryParse ( string  s,
out Span  result 
)
static

Try to parse a string to Span.

Parameters
sString.
resultThe result Span.
Returns
true, if success to parse.
static Span Parse ( string  s)
static

Parse a string to Span.

Parameters
sString.
Returns
The result Span.
override string ToString ( )

Return a string of the a and z.

Returns
A string represents this.
string ToString ( string  format)

Return a string of the a and z.

Parameters
formatFormat for float.
Returns
A string represents this.
bool Contains ( float  value)

Determine if the value is within this span.

Parameters
value
Returns
true if the value is within this span.
float Shuffle ( )

Get a random value within this span.

Returns
The random value.
float Clamp ( float  value)

Get the value clamped by this span.

Parameters
valueValue.
Returns
The clamped value.
float Lerp ( float  t,
bool  clamp = true 
)

Linearly interpolate between span by the fraction t.

Parameters
tTime from 0 to 1.
clampIf to clamp within this span.
Returns
The interpolated value.
float InverseLerp ( float  value,
bool  clamp = true 
)

Calculates the interpolation parameter between this span.

Parameters
valueValue.
clampIf to clamp between 0 to 1.
Returns
The interpolation time.

Member Data Documentation

float a

The start value.

float z

The end value.

Property Documentation

float size
getset

The distance from a to z, negative if z is smaller.

float center
getset

The center between a and z, keep the size when setting.

float min
getset

The min value of a and z, keep the sides when setting.

float max
getset

The max value of a and z, keep the sides when setting.