1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| function draw() { //join函数 let array = ['Hello', 'world!']; let separator = ' '; let message = join(array, separator); text(message, 5, 10);
//match函数 let string = 'Hello p5js*!'; let regexp = 'p5js\\*'; let m = match(string, regexp); text(m, 5, 25);
//nf函数 let num1 = 321.123; text(nf(num1, 4, 2), 5, 40);
//split let names = 'Pat,Xio,Alex'; let splitString = split(names, ','); text(splitString[0], 5, 55); text(splitString[1], 5, 70); text(splitString[2], 5, 85);
//trim let stringTrim = trim(' No new lines\n '); text(stringTrim + ' here', 5, 100);
}
|