Skip to content

abcd2310/p5.js-compatibility

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

All of the above usages in p5.js 1.x remain available with the preload.js compatibility add-on library.

…using registerPreloadMethod in an add-on libraries

Under to hood, returns a Promise from each loadImage, loadSound, and similar functions. Promises are widely used in JavaScript, .js 1.x (preload) and p5.js 2.0 (promises)**, this this line can be removed (the method loadSound, in this example, does not need to be registered) and the method can be updated as follows:

function loadSound (path) {
   if(self._incrementPreload && self._decrementPreload){
     // tTis is the check to determine if preload() is being used, as with
     // p5.js 1.x or with the preload compatibility add-on library. The function
     // returns the soundfile.
 
     self._incrementPreload();
 
     let player = new p5.SoundFile(
       path,
       function () {
         // The callback indicates to preload() that the file is done loading
         self._decrementPreload();
       }
     );
     return player;
 
   }else{
     // Otherwise, async/await is being used, so the function returns a ts below, depending on p5.js version

  describe("A white star 
All of the above usages in p5.js 1.x remain available with the [data.js](https://github.com/processing/p5.js-compatibility/blob/main/src/data.js) compatibility add-on library.

About

Add-on libraries that add p5.js 1.x features to p5.js 2.x for backwards compatibility

Resources

License

Stars

Watchers

Forks

Languages

  • JavaScript 100.0%