函数
Text Manipulation
length(source: TEXT)
NUMBER- Calculates the number of characters in a text.
e.g.length("hello")5
left(source: TEXT, count: NUMBER)
TEXT- Extracts a number of letters from a text, starting on the left side.
e.g.left("hello", 3)"hel"
right(source: TEXT, count: NUMBER)
TEXT- Extracts a number of letters from a text, starting on the right side.
e.g.right("hello", 3)"llo"
concat(source1: TEXT, source2: TEXT)
TEXT- Joins two separate texts into one text.
e.g.concat("hello", "world")"helloworld"
replace(source: TEXT, from: TEXT, to: TEXT)
TEXT- Replaces a part of a text with another text.
e.g.replace("helloworld", "world", "protopie")"helloprotopie"
trim(source: TEXT)
TEXT- Removes whitespace on either side of a text.
e.g.trim(" helloworld ")"helloworld"
ltrim(source: TEXT)
TEXT- Removes whitespace from the left side of a text.
e.g.ltrim(" helloworld ")"helloworld "
rtrim(source: TEXT)
TEXT- Removes whitespace from the right side of a text.
e.g.rtrim(" helloworld ")" helloworld"
indexOf(source: TEXT, searchValue: TEXT)
NUMBER- Returns the position of the occurrence of the searchValue in a text. This method returns -1 if searchValue never occurs.
e.g.indexOf("hello world", "world")6
e.g.indexOf("hello world", "goodbye")-1
lowerCase(source: TEXT)
TEXT- Converts a text to lowercase.
e.g.lowerCase("Hello")"hello"
upperCase(source: TEXT)
TEXT- Converts a text to uppercase.
e.g.upperCase("Hello")"HELLO"
lpad(source: TEXT, length: NUMBER, padString: TEXT)
TEXT- Add padString on the left side of a text to match the chosen length.
e.g.lpad(5, 2, "0")"05"
rpad(source: TEXT, length: NUMBER, padString: TEXT)
TEXT- Add padString on the right side of a text to match the chosen length.
e.g.rpad(5, 2, "0")"50"
repeat(source: TEXT, count: NUMBER)
TEXT- Repeat a text at count times.
e.g.repeat("hello", 3)"hellohellohello"
Math
min(source1: NUMBER, source2: NUMBER)
NUMBER- Returns the smallest of two numbers.
e.g.min(0, 1)0
max(source1: NUMBER, source2: NUMBER)
NUMBER- Returns the largest of two numbers.
e.g.max(0, 1)1
abs(source: NUMBER)
NUMBER- Returns the absolute value of a number.
e.g.abs(-1)1
round(source: NUMBER)
NUMBER- Returns the rounded value of a number.
e.g.round(1.5)2
floor(source: NUMBER)
NUMBER- Returns the largest integer value smaller than or equal to a number.
e.g.floor(1.5)1
ceil(source: NUMBER)
NUMBER- Returns the smallest integer value larger than or equal to a number.
e.g.ceil(1.5)2
sqrt(source: NUMBER)
NUMBER- Returns the square root of a given number. If the number is negative, an error occurs.
e.g.sqrt(9)3
pow(source1: NUMBER, source2: NUMBER)
NUMBER- Calculates the first number raised to the power of the second number.
e.g.pow(2, 3)8
sin(radian: NUMBER)
NUMBER- Returns the sine of a number.
e.g.sin(90)-0.89
cos(radian: NUMBER)
NUMBER- Returns the cosine of a number.
e.g.cos(90)-0.45
tan(radian: NUMBER)
NUMBER- Returns the tangent of a number.
e.g.tan(45)1.62
asin(value: NUMBER)
NUMBER- Returns the arcsine of x, in radians.
e.g.asin(0)0
e.g.asin(1)1.5707963267948966(PI / 2, 90°)
acos(value: NUMBER)
NUMBER- Returns the arccosine of x, in radians.
e.g.acos(0)1.5707963267948966(PI / 2, 90°)
e.g.acos(1)0
atan(value: NUMBER)
NUMBER- Returns the arctangent of a number.
e.g.atan(0)0
e.g.atan(0)0.7853981633974483(PI / 4, 45°)
random()
NUMBER- Returns a random number between 0 and 1.
e.g.random()a random number between 0 and 1
random(min: NUMBER, max: NUMBER)
NUMBER- Returns a random number between two given numbers.
e.g.random(1, 5)a random number between 1 and 5
randomInt(min: NUMBER, max: NUMBER)
NUMBER- Returns a random integer value between two given numbers.
e.g.randomInt(1, 5)a random number between 1 and 5(integar)
sign(value: NUMBER)
NUMBER- Returns 1 if the number is a positive number. Returns -1 if the number is a negative number. Returns 0 if the number is 0.
atan2(x: NUMBER, y: NUMBER)
NUMBER- Returns the angle in the plane (in radians) between the positive x-axis and the ray from (0, 0) to the point (x, y).
degrees(radians: NUMBER)
NUMBER- Convert radians to degrees.
radians(degree: NUMBER)
NUMBER- Convert degrees to radians.
Color
color(red: NUMBER, green: NUMBER, blue: NUMBER)
COLOR- Returns a color value (Hex color code) based on the RGB value.
e.g.color(255, 255, 255)#FFFFFF
red(source: COLOR)
NUMBER- Returns the red RGB value of a color code.
e.g.red(#FF0000)255
green(source: COLOR)
NUMBER- Returns the green RGB value of a color value (Hex color code).
e.g.green(#FF0000)0
blue(source: COLOR)
NUMBER- Returns the blue RGB value of a color value (Hex color code).
e.g.blue(#FF0000)0
Type Conversion
text(source: NUMBER)
TEXT- Converts a number to a text.
e.g.text(1234)"1234"
number(source: TEXT)
NUMBER- Converts a text to a number. If the text is not a number, an error occurs.
e.g.number("1234")1234
color(source: TEXT)
COLOR- Converts a text to a color value. The text must be in the form of a Hex color code (#FF0000), and if it isn’t, an error occurs.
e.g.color("#FFFFFF")#FFFFFF
format(value: NUMBER, format: TEXT)
NUMBER- Converts a number into a text. The number can be split into separate texts made up of any number of digits. Furthermore, numbers with decimals can be expressed, and the number of digits following a decimal point can be designated. number: the number that is to be converted into a text. formatText: the text that will be made up of the number. # is the placeholder for integers and 0 is a placeholder for fractional numbers. Additional numbers can be inserted into the text.
e.g.format(1234.567, "#,###.00")1,234.57
e.g.format(1234567, "#,###.00")1,234.57
e.g.format(1234.567, "#.###,00")1.234,57
e.g.format(1234.567, "#,##.00")12,34.57
e.g.format(1234.567, "#,###")1,235
e.g.format(1234.567, "#")1235
layer(source: TEXT).x
TEXT or NUMBER- Refer to a layer.
e.g.layer("Rectangle 1").xGet the x value of a layer called Rectangle 1