Skip to content

Commit a7a89b2

Browse files
author
Lauren McCarthy
committed
fixes #1376 adding documentation to draw
1 parent 16f2d3f commit a7a89b2

File tree

2 files changed

+50
-1
lines changed

2 files changed

+50
-1
lines changed

src/core/core.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ var p5 = function(sketch, node, sync) {
121121
* exist if you want the code to run continuously, or to process events such
122122
* as mousePressed(). Sometimes, you might have an empty call to draw() in
123123
* your program, as shown in the above example.
124+
* <br><br>
125+
* It is important to note that the drawing coordinate system will be reset
126+
* at the beginning of each draw() call. If any transformations are performed
127+
* within draw() (ex: scale, rotate, translate, their effects will be
128+
* undone at the beginning of draw(), so transformations will not accumulate
129+
* over time. On the other hand, styling applied (ex: fill, stroke, etc) will
130+
* remain in effect.
124131
*
125132
* @method draw
126133
* @example

src/io/p5.XML.js

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,48 @@
88

99
var p5 = require('../core/core');
1010

11-
11+
/**
12+
* XML is a representation of an XML object, able to parse XML code. Use
13+
* loadXML() to load external XML files and create XML objects.
14+
*
15+
* @class p5.XML
16+
* @constructor
17+
* @return {p5.XML} p5.XML object generated
18+
* @example
19+
* <div class='norender'><code>
20+
* // The following short XML file called "mammals.xml" is parsed
21+
* // in the code below.
22+
* //
23+
* // <?xml version="1.0"?>
24+
* // &lt;mammals&gt;
25+
* // &lt;animal id="0" species="Capra hircus">Goat&lt;/animal&gt;
26+
* // &lt;animal id="1" species="Panthera pardus">Leopard&lt;/animal&gt;
27+
* // &lt;animal id="2" species="Equus zebra">Zebra&lt;/animal&gt;
28+
* // &lt;/mammals&gt;
29+
*
30+
* var xml;
31+
*
32+
* function preload() {
33+
* xml = loadXML("assets/mammals.xml");
34+
* }
35+
*
36+
* function setup() {
37+
* var children = xml.getChildren("animal");
38+
*
39+
* for (var i = 0; i < children.length; i++) {
40+
* var id = children[i].getNumber("id");
41+
* var coloring = children[i].getString("species");
42+
* var name = children[i].getContent();
43+
* print(id + ", " + coloring + ", " + name);
44+
* }
45+
* }
46+
*
47+
* // Sketch prints:
48+
* // 0, Capra hircus, Goat
49+
* // 1, Panthera pardus, Leopard
50+
* // 2, Equus zebra, Zebra
51+
* </code></div>
52+
*/
1253
p5.XML = function () {
1354
this.name = null; //done
1455
this.attributes = {}; //done
@@ -750,3 +791,4 @@ p5.XML.prototype._setAttributes = function(node) {
750791
this.attributes = att;
751792
};
752793

794+
module.exports = p5.XML;

0 commit comments

Comments
 (0)