![]() Synopsis: outalpha = util.interpolate_alpha(t, alpha1, alpha2) Interpolate between color1 and color2 with t as time variable in range 0.1.Ĭolor1, color2 and outcolor are colour strings, and outcolour will be in colour override format. Synopsis: outcolor = util.interpolate_color(t, color1, color2) Synopsis: outval = util.interpolate(t, a, b) Synopsis: outval = util.clamp(inval, min, max)Ĭlamps inval to be in range min. Numeric functions #įunctions to handle various operations on numbers. Returns an iterator function for use in a for loop, to loop over all the words in the string using string.headtail semantics. Synopsis: for word in util.words(instring) do. If instring does not contain any space characters it returns instring, "". Splits a string by first space-sequence into a “head” and a “tail”, similar to the handling of linked lists in several functional languages. Synopsis: head, tail = util.headtail(instring) It uses the Lua regex %s class to match spaces, which in some legacy encodings will result in it also matching some prefix bytes in UTF-8 encoded text. Warning: This function is not UTF-8 safe. Removes all space characters at the start and end of the input string, and returns the transformed string. String functions #īecause the Lua standard string library is fairly limited, a few additional helper functions are provided. The nominal range is 0.359 values outside this range will be translated into it. Transforms a colour given in Hue, Saturation, Value space into Red, Green, Blue space. Synopsis: r, g, b = util.HSV_to_RGB(h, s, v) This function is a composition of extract_color and ass_color. Returns the colour part of a colour string, as a colour override string, i.e. Synopsis: colorstring = lor_from_style(coloralphastring) This function is a composition of extract_color and ass_alpha. Returns the alpha part of a colour string, as an alpha override string, i.e. Synopsis: alphastring = util.alpha_from_style(coloralphastring) If an unrecognised colour string is passed, nil is returned. ![]() Unused values (depends on the format of the colour string) are assigned 0 (zero). Note that this function always returns four numbers when passed a valid colour string. Several formats of colour strings are recognised: ![]() Synopsis: r, g, b, a = util.extract_color(colorstring)Įxtracts colour components from a colour string. in format &HAABBGGRR.ĭoes not check input range. Makes an ASS colour string suitable for use in Style definitions, i.e. Synopsis: colorstring = util.ass_style_color(r, g, b, a) Makes an ASS alpha string in the form &HAA& from the given a argument.ĭoes not check input range. Synopsis: alphastring = util.ass_alpha(a) Values outside the 0.255 range will produce garbage output. Warning: The arguments are not checked for range. Makes an ASS colour string in the form &HBBGGRR from the given r, g and b arguments. Synopsis: colorstring = util.ass_color(r, g, b) It is often useful to do various transformations on colour data. If you think you need to do a deep copy, consider your task an extra time. You will rarely need to use this function. While this function attempts to handle circular references and not do infinite recursion on them, it might not work in all cases. Makes a deep copy of the table passed as parameter. Shallow here means that it does not dive into contained tables and copy those as well.įor example, if oldtable.st refers to a table, newtable.st will refer to the same table, and changes made to newtable.st will also be reflected in oldtable.st and vice versa. Makes a shallow copy of the table passed as parameter. Util provides some functions to handle the most common cases. Import this module with util = require 'aegisub.util' Table functions #ĭuplicating tables in various ways is a common task. The Automation 4 Lua include file a contains various support functions to aid writing Lua scripts.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |