MCPcopy Index your code
hub / github.com/processing/p5.js / parseCreateArgs

Function parseCreateArgs

src/type/p5.Font.js:1229–1260  ·  view source on GitHub ↗
(...args/*path, name, onSuccess, onError*/)

Source from the content-addressed store, hash-verified

1227}
1228
1229function parseCreateArgs(...args/*path, name, onSuccess, onError*/) {
1230
1231 // parse the path
1232 let path = args.shift();
1233 if (typeof path !== 'string' || path.length === 0) {
1234 p5._friendlyError(invalidFontError, 'p5.loadFont'); // ?
1235 }
1236
1237 // parse the name
1238 let name;
1239 if (typeof args[0] === 'string') {
1240 name = args.shift();
1241 }
1242
1243 // get the callbacks/descriptors if any
1244 let success, error, options;
1245 for (let i = 0; i < args.length; i++) {
1246 const arg = args[i];
1247 if (typeof arg === 'function') {
1248 if (!success) {
1249 success = arg;
1250 } else {
1251 error = arg;
1252 }
1253 }
1254 else if (typeof arg === 'object') {
1255 options = arg;
1256 }
1257 }
1258
1259 return { path, name, success, error, options };
1260}
1261
1262function font(p5, fn) {
1263

Callers 1

fontFunction · 0.85

Calls 1

_friendlyErrorMethod · 0.45

Tested by

no test coverage detected