Skip to content

Commit

Permalink
add loadBytes() support
Browse files Browse the repository at this point in the history
patinthehat committed Mar 15, 2023

Verified

This commit was signed with the committer’s verified signature.
patinthehat Patrick Organ
1 parent f8b404b commit 51afab3
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/Assets.ts
Original file line number Diff line number Diff line change
@@ -110,6 +110,25 @@ export class Assets {
return {};
}

/**
* Loads a file from a script asset URL using `p5.loadBytes()`, and returns an object with a `bytes` property.
* @param {string} path
* @returns {object} an object whose 'bytes' property will be the loaded buffer
*/
public async loadBytes(path: string) {
path = getMerakiScriptFileAssetsUrl() + this.sanitizeUrl(path);

try {
// @ts-ignore
// eslint-disable-next-line no-undef
return loadBytes(path);
} catch (e) {
//
}

return { bytes: [] };
}

/**
* Loads an image from the `path` script asset URL and creates a `p5.Image` from it.
* @param {string} path

0 comments on commit 51afab3

Please sign in to comment.