Functions Index :: A :: ArrayOpValue
Module:
Definition:
ArrayOpValue(string array, val scalar, string operation, bool "array_first")
Description:
Performs an operation of a value with all elements of an array (ie value op array[i] or array[i] op value) and returns the resulting array.
Arguments:
array: The array who's elements will be the one (defaults to left) operand of the operation.
scalar: The single value which will be the other (defaults to right) operand of the operation.
operation: The string representation of the operation to be performed between each array element and scalar. All Avisynth operations that are valid for the specific types of operands are supported ("+", "-", "*", "/", "%", "==", "!=", ">=", "<=", "<", ">", "&&", "||", etc.)
"array_first" (Optional, defaults to true): Bool flag that controls the order of the operands of the operation.
When true or ommited, the array element will be the left operand and the scalar the right one. When false, the order is reversed.
This is of importance for operations that are not symmetrical, such as for example division ("/"), modulo ("%"), certain comparison operations (">", "<", ">=", "<="), etc.
Notes and conditions on arguments relations:
1] The type of array elements and of scalar must be compatible with respect to the chosen operation.
2] When performing division with ints Avisynth truncates the result to an int. If you want float results, make either array elements or scalar a float.
Examples:
a1 = "3.2, 4.1, 3.3, -0.23"
a2 = a1.ArrayOpValue(0.4, "+") # a2 == "3.6,4.5,3.7,0.17"
a3 = a1.ArrayOpValue(4, "<=") # a3 == "true,false,true,true"
# now we will invert the order of operands
# which is the same as changing the operation to ">="
a3 = a1.ArrayOpValue(4, "<=", false) # a3 == "false,true,false,false"
# clips can also be added
ac1 = ArrayCreate(AVISource(.1.), AVISource(.2.), ...)
clp = AVISource(...)
# add clp in front of every clip contained in ac1
ac2 = ac1.ArrayOpValue(clp, false)
# add clp both in front and at end of every clip contained in ac1
ac3 = ac1.ArrayOpValue(clp, false).ArrayOpValue(clp)
More examples and in-depth explanation of operator functions can be found at the "Container operators" tutorial.