Struct FrameTime
A struct that represents a time relative to a frame sequence, with an optional subframe value.
Namespace: Unity.LiveCapture
Syntax
public struct FrameTime : IComparable, IComparable<FrameTime>, IEquatable<FrameTime>
Constructors
FrameTime(Int32, Subframe)
Creates a new FrameTime instance.
Declaration
public FrameTime(int frameNumber, Subframe subframe = default(Subframe))
Parameters
Type | Name | Description |
---|---|---|
Int32 | frameNumber | The number of the frame in the sequence. |
Subframe | subframe | The subframe value used to indicate a time somewhere within the duration of the frame. |
Properties
FrameNumber
The number of the frame in the sequence.
Declaration
public readonly int FrameNumber { get; }
Property Value
Type | Description |
---|---|
Int32 |
Subframe
The time within the frame.
Declaration
public readonly Subframe Subframe { get; }
Property Value
Type | Description |
---|---|
Subframe |
Methods
Ceil()
Gets the frame time rounded up to the start of the next frame.
Declaration
public FrameTime Ceil()
Returns
Type | Description |
---|---|
FrameTime | A FrameTime with no subframe component. |
CompareTo(Object)
Compares this instance to a specified object and returns an indication of their relative values.
Declaration
public int CompareTo(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | The object to compare with this instance. |
Returns
Type | Description |
---|---|
Int32 | A signed number indicating the relative values of this instance and
|
CompareTo(FrameTime)
Compares this instance to a specified FrameTime and returns an indication of their relative values.
Declaration
public int CompareTo(FrameTime other)
Parameters
Type | Name | Description |
---|---|---|
FrameTime | other | The value to compare with this instance. |
Returns
Type | Description |
---|---|
Int32 | A signed number indicating the relative values of this instance and
|
Equals(Object)
Returns a value indicating whether this instance is equal to a specified object.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
Object | obj | An object to compare with this instance. |
Returns
Type | Description |
---|---|
Boolean | true if |
Equals(FrameTime)
Returns a value indicating whether this instance is equal to a specified FrameTime.
Declaration
public bool Equals(FrameTime other)
Parameters
Type | Name | Description |
---|---|---|
FrameTime | other | A value to compare with this instance. |
Returns
Type | Description |
---|---|
Boolean | true if |
Floor()
Gets the frame time rounded down to the start of the current frame.
Declaration
public FrameTime Floor()
Returns
Type | Description |
---|---|
FrameTime | A FrameTime with no subframe component. |
FromFrameTime(Double, Int32)
Creates a new FrameTime instance from a frame time.
Declaration
public static FrameTime FromFrameTime(double frameTime, int subframeResolution = null)
Parameters
Type | Name | Description |
---|---|---|
Double | frameTime | The frame time with the frame number in the integer part and the subframe in the decimal part. |
Int32 | subframeResolution | The number of possible subframe values in the frame. If this value is not greater than zero, the subframe value is treated as zero. |
Returns
Type | Description |
---|---|
FrameTime | A new FrameTime that represents the given frame time. |
FromSeconds(FrameRate, Double, Int32)
Creates a new FrameTime instance from a time in seconds and a frame rate.
Declaration
public static FrameTime FromSeconds(FrameRate frameRate, double time, int subframeResolution = null)
Parameters
Type | Name | Description |
---|---|---|
FrameRate | frameRate | The frame rate of the frame sequence. |
Double | time | The time in seconds. |
Int32 | subframeResolution | The number of possible subframe values in the frame. If this value is not greater than zero, the subframe value is treated as zero. |
Returns
Type | Description |
---|---|
FrameTime | A new FrameTime that represents the given time, or langword_csharp_default
if |
Remarks
The input time is clamped to the range [-MaxRepresentableSeconds(FrameRate), MaxRepresentableSeconds(FrameRate)] defined for the provided FrameRate.
GetHashCode()
Returns the hash code for this instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
Int32 | The hash code for this instance. |
MaxRepresentableSeconds(FrameRate)
Calculates the maximum length of a frame sequence in seconds that can be represented by a FrameTime.
Declaration
public static double MaxRepresentableSeconds(FrameRate frameRate)
Parameters
Type | Name | Description |
---|---|---|
FrameRate | frameRate | The frame rate of the frame sequence. |
Returns
Type | Description |
---|---|
Double | The maximum time in seconds, or langword_csharp_default if |
Remap(FrameTime, FrameRate, FrameRate)
Converts a FrameTime in a frame sequence with a given FrameRate to a time in a frame sequence with a different FrameTime.
Declaration
public static FrameTime Remap(FrameTime frameTime, FrameRate srcRate, FrameRate dstRate)
Parameters
Type | Name | Description |
---|---|---|
FrameTime | frameTime | The frame time to remap. |
FrameRate | srcRate | The original frame rate. |
FrameRate | dstRate | The frame rate to convert to. |
Returns
Type | Description |
---|---|
FrameTime | A new FrameTime remapped to the the target frame rate, or langword_csharp_default
if |
Round()
Gets the frame time rounded to the nearest start of a frame.
Declaration
public FrameTime Round()
Returns
Type | Description |
---|---|
FrameTime | A FrameTime with no subframe component. |
Remarks
Subframe values exactly half way in a frame are rounded towards negative infinity.
ToSeconds(FrameRate)
Declaration
public double ToSeconds(FrameRate frameRate)
Parameters
Type | Name | Description |
---|---|---|
FrameRate | frameRate | The frame rate of the frame sequence. |
Returns
Type | Description |
---|---|
Double | The time in seconds since the start of the frame sequence, or langword_csharp_default
if |
ToString()
Returns a string that represents the current instance.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | A string that represents the current instance. |
Operators
Addition(FrameTime, FrameTime)
Calculates the sum of two specified FrameTime values.
Declaration
public static FrameTime operator +(FrameTime a, FrameTime b)
Parameters
Type | Name | Description |
---|---|---|
FrameTime | a | The first frame time. |
FrameTime | b | The second frame time. |
Returns
Type | Description |
---|---|
FrameTime | The sum of |
Decrement(FrameTime)
Decrements a FrameTime by a single frame.
Declaration
public static FrameTime operator --(FrameTime a)
Parameters
Type | Name | Description |
---|---|---|
FrameTime | a | The frame time to Decrement. |
Returns
Type | Description |
---|---|
FrameTime | The decremented frame time. |
Equality(FrameTime, FrameTime)
Determines whether two specified instances of FrameTime are equal.
Declaration
public static bool operator ==(FrameTime a, FrameTime b)
Parameters
Type | Name | Description |
---|---|---|
FrameTime | a | The first instance to compare. |
FrameTime | b | The second instance to compare. |
Returns
Type | Description |
---|---|
Boolean |
Explicit(FrameTime to Double)
Gets the value of a FrameTime as a
Declaration
public static explicit operator double (FrameTime rate)
Parameters
Type | Name | Description |
---|---|---|
FrameTime | rate | The value to cast. |
Returns
Type | Description |
---|---|
Double | The frame time with the frame number in the integer part and the subframe in the decimal part. |
Explicit(FrameTime to Single)
Gets the value of a FrameTime as a
Declaration
public static explicit operator float (FrameTime rate)
Parameters
Type | Name | Description |
---|---|---|
FrameTime | rate | The value to cast. |
Returns
Type | Description |
---|---|
Single | The frame time with the frame number in the integer part and the subframe in the decimal part. |
GreaterThan(FrameTime, FrameTime)
Declaration
public static bool operator>(FrameTime a, FrameTime b)
Parameters
Type | Name | Description |
---|---|---|
FrameTime | a | The first instance to compare. |
FrameTime | b | The second instance to compare. |
Returns
Type | Description |
---|---|
Boolean |
GreaterThanOrEqual(FrameTime, FrameTime)
Determines whether one specified FrameTime is later than or the same as another specified FrameTime.
Declaration
public static bool operator >=(FrameTime a, FrameTime b)
Parameters
Type | Name | Description |
---|---|---|
FrameTime | a | The first instance to compare. |
FrameTime | b | The second instance to compare. |
Returns
Type | Description |
---|---|
Boolean |
Increment(FrameTime)
Increments a FrameTime by a single frame.
Declaration
public static FrameTime operator ++(FrameTime a)
Parameters
Type | Name | Description |
---|---|---|
FrameTime | a | The frame time to increment. |
Returns
Type | Description |
---|---|
FrameTime | The incremented frame time. |
Inequality(FrameTime, FrameTime)
Determines whether two specified instances of FrameTime are not equal.
Declaration
public static bool operator !=(FrameTime a, FrameTime b)
Parameters
Type | Name | Description |
---|---|---|
FrameTime | a | The first instance to compare. |
FrameTime | b | The second instance to compare. |
Returns
Type | Description |
---|---|
Boolean | true if |
LessThan(FrameTime, FrameTime)
Declaration
public static bool operator <(FrameTime a, FrameTime b)
Parameters
Type | Name | Description |
---|---|---|
FrameTime | a | The first instance to compare. |
FrameTime | b | The second instance to compare. |
Returns
Type | Description |
---|---|
Boolean |
LessThanOrEqual(FrameTime, FrameTime)
Determines whether one specified FrameTime is earlier than or the same as another specified FrameTime.
Declaration
public static bool operator <=(FrameTime a, FrameTime b)
Parameters
Type | Name | Description |
---|---|---|
FrameTime | a | The first instance to compare. |
FrameTime | b | The second instance to compare. |
Returns
Type | Description |
---|---|
Boolean | true if |
Subtraction(FrameTime, FrameTime)
Calculates the difference between two specified FrameTime values.
Declaration
public static FrameTime operator -(FrameTime a, FrameTime b)
Parameters
Type | Name | Description |
---|---|---|
FrameTime | a | The frame time. |
FrameTime | b | The frame time to subtract. |
Returns
Type | Description |
---|---|
FrameTime | The difference of |