Internal functions/Conversion functions: Difference between revisions

From Avisynth wiki
Jump to navigationJump to search
corrected example for Hex ( Hex ("A52A2A") = 10824234 => Hex (10824234) = "A52A2A" )
 
Raffriff42 (talk | contribs)
make redirect
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Conversion functions ==
#REDIRECT [[Internal_functions#Conversion_functions]]


These functions convert between different types. There are also some [[Internal_functions/Numeric_functions|numeric functions]] that can be classified in this category, namely: <tt>Ceil, Floor, Float, Int</tt> and <tt>Round</tt>.
* {{ScriptFunction|Value|v2.07|Value(string)}}
: Converts a decimal string to its associated numeric value.
: ''Examples:''
Value ("-2.7") = -2.7
* {{ScriptFunction|HexValue|v2.07|HexValue(string)}}
: Converts a hexadecimal string to its associated numeric value.
: ''Examples:''
HexValue ("FF00") = 65280
* {{ScriptFunction|Hex|v2.60|Hex(int)}}
: Converts a numerical value to its hexadecimal value. See [[Colors]] for more information on specifying colors.
: ''Examples:''
Hex (10824234) = "A52A2A"
* {{ScriptFunction|String|v2.07|String(float / int [, string format_string])}}
: Converts a variable to a string.
: If the variable is float or integer, it first converts it to a float and then uses format_string to convert the float to a string. The syntax of format_string is as follows:
: <tt>%[flags][width][.precision]f</tt>
: ''width'': the minimum width (the string is never truncated)
: ''precision'': the number of digits printed
: ''flags'':
:: <tt>-  </tt> left align (instead right align)
:: <tt>+  </tt> always print the +/- sign
:: <tt>0  </tt> padding with leading zeros
:: <tt>' '</tt> print a blank instead of a "+"
:: <tt>#  </tt> always print the decimal point
: You can also put arbitrary text around the format_string as defined above, similar to the C-language ''printf'' function.
: ''Examples:''
[[Subtitle]]( "Clip height is " + String(last.height) )
[[Subtitle]]( String(x, "Value of x is %.3f after AR calc") )
[[Subtitle]]( "Value of x is " + String(x, "%.3f") + " after AR calc") ) # same as above
String(1.23, "%f") = '1.23'
String(1.23, "%5.1f") = ' 1.2'
String(1.23, "%1.3f") = '1.230'
String(24, "%05.0f") = '00024'
----
Back to [[Internal functions]].


[[Category:AviSynth_Syntax]]
[[Category:AviSynth_Syntax]]
[[Category:Scripting_Basics]]
[[Category:Scripting_Basics]]

Latest revision as of 03:55, 17 September 2014