new ONumber(value)
Creates an ONumber object representing the value argument.
It is highly recommended to use the static factory
instead as it is optimised to
avoid creating unnecessary instances.
Parameters:
Name | Type | Description |
---|---|---|
value |
number |
Members
-
<static> Accumulator
-
<static> Animate
-
<static> AnimateFullDefinition
-
<static> Cap
-
<static> Derivate
-
<static> derivate
-
<static> Diff
-
<static> Div
-
<static> EASING :function
-
<static, constant, non-null> INFINITY :olympe.df.ONumber
-
<static> Integrate
-
<static> Minus
-
<static, constant, non-null> MINUSINFINITY :olympe.df.ONumber
-
<static, constant, non-null> NAN :olympe.df.ONumber
-
<static> Offset
-
<static, constant, non-null> ONE :olympe.df.ONumber
-
<static, constant, non-null> PI :olympe.df.ONumber
-
<static> Plus
-
<static> PlusEqual
-
<static> ToggleSign
-
<static> ToOString
-
<static, constant, non-null> TWO :olympe.df.ONumber
-
<static, constant, non-null> ZERO :olympe.df.ONumber
Methods
-
<static> accumulator(onu [, min] [, max], easingFunction)
-
Parameters:
Name Type Argument Description onu
olympe.df.PONumber | number min
olympe.df.PONumber | number <optional>
max
olympe.df.PONumber | number <optional>
easingFunction
function easing function to use when min or max change value
Returns:
- Type
- olympe.df.PONumber
-
<static> animate(value, duration [, animationFunction] [, onDone])
-
Transforms a numerical data-flow into another one where the changes in the initial data-flow are 'animated' over the specified duration.
Compute the animation with requestAnimationFrame A new duration value is not taken into account if there is an animation running
Parameters:
Name Type Argument Description value
olympe.df.PONumber | number The initial data-flow.
duration
olympe.df.PONumber | number The duration in milliseconds.
animationFunction
function <optional>
animation function takes as first parameter a number between 0 and 1 (time) and returns a number (the position)
onDone
olympe.df.ONumber.AnimateCallback <optional>
function to be called when animation is finished
Returns:
The resulting data-flow.
- Type
- olympe.df.PONumber
-
<static> animateFullDefinition(myOnu, duration, myFunc)
-
Compute the animation without requestAnimationFrame
Parameters:
Name Type Description myOnu
olympe.df.PONumber duration
olympe.df.PONumber | number myFunc
function animation function takes as first parameter a number between 0 and 1 (time) and returns a number (the position)
Returns:
- Type
- olympe.df.PONumber
-
<static> animateOnce(start, end, duration [, animationFunction] [, onDone] [, flow])
-
Creates a numerical data-flow where the value will change over the specified duration from the initial value to the specified end value.
Parameters:
Name Type Argument Default Description start
olympe.df.ONumber | number Starting value.
end
olympe.df.ONumber | number End value.
duration
number 1000 Duration, in milliseconds, for the transition.
animationFunction
function <optional>
The function to calculate each incremental step. Default is
LinearTween
.onDone
olympe.df.ONumber.AnimateCallback <optional>
Function that will be called at the end of the animation.
flow
olympe.df.FlowSource.<!olympe.df.ONumber> <optional>
The
FlowSource
to update. A new one will be create if omitted.Returns:
The resulting data-flow.
- Type
- olympe.df.PONumber
-
<static> cap(myOnu, min, max)
-
Returns the input value (myOnu) if within [min, max] range Returns min if myOnu smaller than min Returns max if myOnu bigger than max
Parameters:
Name Type Description myOnu
olympe.df.PONumber | number min
olympe.df.PONumber | number max
olympe.df.PONumber | number Returns:
- Type
- olympe.df.PONumber
-
<static> derivative(myOnu)
-
Returns the ratio of the difference between last value and current value over the time elapsed during the change in value
Parameters:
Name Type Description myOnu
olympe.df.Proxy.<olympe.df.ONumber> Returns:
- Type
- olympe.df.PONumber
-
<static> diff(myOnu)
-
Returns the difference between last value and current value
Parameters:
Name Type Description myOnu
olympe.df.Proxy.<olympe.df.ONumber> Returns:
- Type
- olympe.df.PONumber
-
<static> div(oNum1, oNum2)
-
Divides 2 numbers and returns the result.
Parameters:
Name Type Description oNum1
olympe.df.PONumber | number the dividend
oNum2
olympe.df.PONumber | number the divisor
Returns:
the result of oNum1 / oNum2
- Type
- olympe.df.PONumber
-
<static> fromJSON(json)
-
Deserializes an
ONumber
from a JSON object or string.Parameters:
Name Type Description json
string | Object Returns:
- Type
- olympe.df.ONumber
-
<static> hexToONumber(hex)
-
Converts an hexadecimal string into a
ONumber
.Parameters:
Name Type Description hex
olympe.df.POString Returns:
the converted
ONumber
- Type
- olympe.df.PONumber
-
<static> integrate(myOnu)
-
Returns the integral of the value function of the time in milli seconds
Parameters:
Name Type Description myOnu
olympe.df.Proxy.<olympe.df.ONumber> Returns:
- Type
- olympe.df.PONumber
-
<static> max(oNumbers)
-
Returns the ONumber with the highest value.
Please note that this method only accepts enumerable of proxy to ONumber.
Parameters:
Name Type Description oNumbers
olympe.df.Enumerable.<olympe.df.PONumber> Returns:
the ONumber with the highest value
- Type
- olympe.df.PONumber
-
<static> maxF(oNumbers)
-
Returns the ONumber with the highest value.
Parameters:
Name Type Argument Description oNumbers
olympe.df.PONumber | number <repeatable>
a set of numbers
Returns:
the ONumber with the highest value.
- Type
- olympe.df.PONumber
-
<static> minF(oNumbers)
-
Returns the ONumber with the smallest value.
Parameters:
Name Type Argument Description oNumbers
olympe.df.PONumber | number <repeatable>
a set of numbers
Returns:
the ONumber with the smallest value
- Type
- olympe.df.PONumber
-
<static> minus(oNum1, oNum2)
-
Subtracts 2 numbers and return the result.
Parameters:
Name Type Description oNum1
olympe.df.PONumber | number oNum2
olympe.df.PONumber | number Returns:
the result of oNum1 - oNum2
- Type
- olympe.df.PONumber
-
<static> offset(myOnu)
-
Returns the diff between initial call and current value
Parameters:
Name Type Description myOnu
olympe.df.PONumber Returns:
- Type
- olympe.df.PONumber
-
<static> plus(oNum1, oNum2)
-
Adds 2 numbers and returns the result.
Parameters:
Name Type Description oNum1
olympe.df.PONumber | number oNum2
olympe.df.PONumber | number Returns:
the result of oNum1 + oNum2
- Type
- olympe.df.PONumber
-
<static> plusEqual(thisONum [, valueToAdd])
-
Adds a value to the specified
ONumber
.Parameters:
Name Type Argument Description thisONum
olympe.df.Proxy.<olympe.df.ONumber> the Proxy of
ONumber
to add the value tovalueToAdd
olympe.df.PONumber | number <optional>
the value to add to the
ONumber
Returns:
the Proxy of
ONumber
passed as argument- Type
- olympe.df.PONumber
-
<static> toggleSign(number)
-
Toggles the sign (invert) of a number. e.g. 1 -> -1.
Parameters:
Name Type Description number
olympe.df.PONumber | number to invert
Returns:
the result of the inversion
- Type
- olympe.df.PONumber
-
<static> toOString(number)
-
Converts a number into a
OString
.Parameters:
Name Type Description number
olympe.df.PONumber | number Returns:
- Type
- olympe.df.POString
-
abs()
-
Returns the absolute value of this number.
Returns:
the absolute value for this ONumber`
- Type
- olympe.df.PONumber
-
atan2(y)
-
Calculates the angle in the plane (in radians) between the positive x-axis and the ray from (0,0) to the point (x, y) where x is this
ONumber
andy
is the parameter.Parameters:
Name Type Description y
olympe.df.PONumber | number the y coordinate for the point.
Returns:
The angle in radians (in [-\pi, \pi])
- Type
- olympe.df.PONumber
-
ceil()
-
Rounds this
ONumber
to its closest higher integer.Returns:
the result of the rounding
- Type
- olympe.df.PONumber
-
cos()
-
Calculate the cosine of an angle given in radians. Returns a numeric value between -1 and 1.
Returns:
the cosine of this number.
- Type
- olympe.df.PONumber
-
div(divBy)
-
Divides this
ONumber
with a value and return the result in a new instance.Parameters:
Name Type Description divBy
olympe.df.PONumber | number the value to divide this
ONumber
byReturns:
the result of the division
- Type
- olympe.df.PONumber
-
equals( [otherONum])
-
Checks whether the value of this
ONumber
is equal to another number.Parameters:
Name Type Argument Description otherONum
olympe.df.ONumber | number <optional>
Returns:
true if both numbers are equals, false otherwise
- Type
- boolean
-
exp()
-
Calculates E to the power of this
ONumber
and returns the result in a new instance.Returns:
the value of E to the power of this number.
- Type
- olympe.df.PONumber
-
floor()
-
Rounds this
ONumber
to its closest lower integer.Returns:
the result of the rounding
- Type
- olympe.df.PONumber
-
getNumber()
-
- Deprecated:
-
- Use
valueOf
if you need the primitive type.
- Use
Returns:
- Type
- number
-
isBiggerThan(otherONumber)
-
Checks whether an
ONumber
is bigger than an other number.Parameters:
Name Type Description otherONumber
olympe.df.PONumber | number The value to compare with
Returns:
true if the value of this
ONumber
is bigger than the value of the parameter- Type
- olympe.df.POBoolean
-
isNaN()
-
Checks whether this ONumber represents a valid number.
Returns:
true is this is not a valid number.
- Type
- olympe.df.POBoolean
-
isSmallerThan(otherONumber)
-
Checks whether an
ONumber
is smaller than an other number.Parameters:
Name Type Description otherONumber
olympe.df.PONumber | number The value to compare with
Returns:
true if the value of this
ONumber
is smaller than the value of the parameter- Type
- olympe.df.POBoolean
-
linearInterpolate(y, ratio)
-
Calculates the point on the linear interpolate line between this number and the parameter. Formula is: (x * ratio) + (y * (1 - ratio)) where
x
is this number andy
is the parameter.Parameters:
Name Type Description y
olympe.df.PONumber | number ratio
olympe.df.PONumber | number 0..1 (a value of 0 means return y, a value of 1 means return this oNum)
Returns:
- Type
- olympe.df.PONumber
-
log()
-
Returns the natural logarithm (base E) of this
ONumber
Returns:
the natural logarithm of this
ONumber
- Type
- olympe.df.PONumber
-
minus(valueToSubtract)
-
Subtracts a value from this
ONumber
and returns the result in a new instance.Parameters:
Name Type Description valueToSubtract
olympe.df.PONumber | number the value to subtract from this
ONumber
Returns:
the result of the subtraction
- Type
- olympe.df.PONumber
-
mod(divisor)
-
Calculates the remainder after division of this
ONumber
by the specified value.Parameters:
Name Type Description divisor
olympe.df.PONumber | number the value to use as the divisor
Returns:
the result of the modulo operation
- Type
- olympe.df.PONumber
-
mul(valueToMul)
-
Multiplies this
ONumber
with a value and return the result in a new instance.Parameters:
Name Type Description valueToMul
olympe.df.PONumber | number the value to multiply this
ONumber
withReturns:
the result of the multiplication
- Type
- olympe.df.PONumber
-
oEquals(otherONum)
-
Checks whether this
ONumber
is equal to another number.Parameters:
Name Type Description otherONum
olympe.df.PONumber | number the value to compare to
Returns:
true if both numbers are equals, false otherwise
- Type
- olympe.df.POBoolean
-
plus(valueToAdd)
-
Adds a value to this
ONumber
and return the result in a new instance.Parameters:
Name Type Description valueToAdd
olympe.df.PONumber | number the value to add to this
ONumber
Returns:
the result of the addition
- Type
- olympe.df.PONumber
-
pow(power)
-
Calculates the value of this
ONumber
to the power of the specified value.Parameters:
Name Type Description power
olympe.df.PONumber | number the exponent
Returns:
- Type
- olympe.df.PONumber
-
returnsBiggest(otherOnum)
-
Gets the highest value of two numbers.
Parameters:
Name Type Description otherOnum
olympe.df.PONumber | number The value to compare with
Returns:
An
ONumber
containing the highest of the 2 values- Type
- olympe.df.PONumber
-
returnsSmallest(otherOnum)
-
Gets the smallest value of two numbers.
Parameters:
Name Type Description otherOnum
olympe.df.PONumber | number The value to compare with
Returns:
An
ONumber
containing the smallest of the 2 values- Type
- olympe.df.PONumber
-
round()
-
Rounds this
ONumber
and returns the result in a new instance.Returns:
the result of the rounding
- Type
- olympe.df.PONumber
-
sin()
-
Calculate the sine of an angle given in radians. Returns a numeric value between -1 and 1.
Returns:
the sine of this number.
- Type
- olympe.df.PONumber
-
toFixed(fixed)
-
Converts this number into a String, keeping only the specified number of decimals. If the number value is not valid, '' is returned.
Parameters:
Name Type Description fixed
number The number of decimals wanted
- See:
-
isNaN
Returns:
- Type
- string
-
toggleSign()
-
Toggles (inverts) the sign of this
ONumber
and return the result in a new instance.Returns:
the inverse of this
ONumber
- Type
- olympe.df.PONumber
-
toJSON()
-
Converts this
ONumber
into a JSON string.Returns:
- Type
- string
-
toOString()
-
Converts this number into an OString. If the number value is not valid, an empty string is returned.
- See:
Returns:
the string representation of this number.
- Type
- olympe.df.POString
-
toString( [radix] [, decimal])
-
Converts this number into a String. If the number value is not valid, an empty string is returned.
Parameters:
Name Type Argument Description radix
number <optional>
the base in which to translate the number defaults to 10
decimal
number <optional>
number of decimals. Defaults is 'all decimals'
Returns:
- Type
- string
-
trunc()
-
Returns the integer part of this
ONumber
. e.g. 8.12 truncates to 8.Returns:
the result of this truncation
- Type
- olympe.df.PONumber
-
valueOf()
-
Converts this
ONumber
into the base javascript typenumber
.Returns:
the value of this
ONumber
- Type
- number
Type Definitions
-
AnimateCallback(animateResult)
-
Parameters:
Name Type Description animateResult
number