Skip to content

Commit 063f93a

Browse files
committed
Fix p5.Graphics not having .elt and registerAddon not being in types
1 parent 729fd1b commit 063f93a

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

docs/parameterData.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,13 @@
398398
[]
399399
]
400400
},
401+
"registerAddon": {
402+
"overloads": [
403+
[
404+
"Function"
405+
]
406+
]
407+
},
401408
"createCanvas": {
402409
"overloads": [
403410
[

src/core/main.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,7 @@ export default p5;
751751
* which takes time to process. Disabling the FES can significantly improve
752752
* performance by turning off these checks.
753753
*
754+
* @static
754755
* @property {Boolean} disableFriendlyErrors
755756
*
756757
* @example
@@ -775,3 +776,39 @@ export default p5;
775776
* </code>
776777
* </div>
777778
*/
779+
780+
/**
781+
* Loads a p5.js library.
782+
*
783+
* A library is a function that adds functionality to p5.js by adding methods
784+
* and properties for sketches to use, or for automatically running code at
785+
* different stages of the p5.js lifecycle. Take a look at the
786+
* <a href="/contribute/creating_libraries/">contributor docs for creating libraries</a>
787+
* to learn more about creating libraries.
788+
*
789+
* @static
790+
* @method registerAddon
791+
* @param {Function} library The library function to register
792+
*
793+
* @example
794+
* <div>
795+
* <code>
796+
* function myAddon(p5, fn, lifecycles) {
797+
* fn.sayHello = function() {
798+
* this.textAlign(this.CENTER, this.CENTER);
799+
* this.text('Hello!', this.width / 2, this.height / 2);
800+
* };
801+
* }
802+
* p5.registerAddon(myAddon);
803+
*
804+
* function setup() {
805+
* createCanvas(100, 100);
806+
*
807+
* background(200);
808+
* sayHello(); // The sayHello method is now available!
809+
*
810+
* describe('The text "Hello!"');
811+
* }
812+
* </code>
813+
* </div>
814+
*/

src/core/p5.Graphics.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ class Graphics {
3737
return this;
3838
}
3939

40+
// This is to correctly extend the p5.Element interface
41+
get elt() {
42+
return this.canvas;
43+
}
44+
4045
get deltaTime(){
4146
return this._pInst.deltaTime;
4247
}

0 commit comments

Comments
 (0)