From bf7606c3e7675ac630c7b3c4b4fd90567cc2d20c Mon Sep 17 00:00:00 2001 From: Patrick Organ Date: Wed, 15 Mar 2023 09:16:52 -0400 Subject: [PATCH] update docs --- README.md | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5e35426..b8dfc50 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,8 @@ - [`hash`](#hash) - [`chunkify()`](#chunkify) - [`assets`](#assets) + - [Examples](#examples) + - [Complete Example with `loadFont()`](#complete-example-with-loadfont) - [`random`](#random) - [`window`](#window) - [Methods](#methods) @@ -195,13 +197,20 @@ The functions for loading data files from the Meraki CDN are: - `Meraki.assets.loadJSON()` - `Meraki.assets.loadXML()` -Additionally, the following functions are provided for loading font, image and shader assets from the Meraki CDN: +Additionally, the following functions are provided for loading font, image, shader and other assets from the Meraki CDN: +- `Meraki.assets.loadBytes()` - `Meraki.assets.loadFont()` - `Meraki.assets.loadImage()` - `Meraki.assets.loadShader()` -These functions are used to load assets from the Meraki CDN. For example, to load a JSON file from the CDN: +These functions are used to load assets from the Meraki CDN, and MUST be used in place of the original p5 functions. + +For information on how to use the functions, see the [p5.js documentation](https://p5js.org/reference/#/p5/). + +###### Examples + +To load a JSON file from the CDN: ```js const data = await Meraki.assets.loadJSON('your-project-identifier/data.json'); @@ -228,6 +237,8 @@ const data = await Meraki.assets.loadJSON(`${Meraki.project.identifier}/data.jso Note the use of `await` in the example above. The above functions are asynchronous and must be used with `await` or `then()` and should be placed in the `initialization` method of the `MerakiScript` class. +###### Complete Example with `loadFont()` + Complete example using `Meraki.assets.loadFont()`: ```js @@ -275,6 +286,9 @@ class Script extends MerakiScript { } ``` +> When using `Meraki.assets.loadFont()`, `Meraki.assets.loadImage()`, or `Meraki.assets.loadShader()`, access the correct filename +> for the asset from the "Digital Assets" tab in the Meraki Artist dashboard. + ##### `random` The `Meraki.random` property provides access to random value generation functions using a `Random` class.