(p5, fn)
| 1143 | } |
| 1144 | |
| 1145 | function xml(p5, fn){ |
| 1146 | /** |
| 1147 | * A class to describe an XML object. |
| 1148 | * |
| 1149 | * Each `p5.XML` object provides an easy way to interact with XML data. |
| 1150 | * Extensible Markup Language |
| 1151 | * (<a href="https://developer.mozilla.org/en-US/docs/Web/XML/XML_introduction" target="_blank">XML</a>) |
| 1152 | * is a standard format for sending data between applications. Like HTML, the |
| 1153 | * XML format is based on tags and attributes, as in |
| 1154 | * `<time units="s">1234</time>`. |
| 1155 | * |
| 1156 | * Note: Use <a href="#/p5/loadXML">loadXML()</a> to load external XML files. |
| 1157 | * |
| 1158 | * @class p5.XML |
| 1159 | * @example |
| 1160 | * let myXML; |
| 1161 | * |
| 1162 | * async function setup() { |
| 1163 | * // Load the XML and create a p5.XML object. |
| 1164 | * myXML = await loadXML('assets/animals.xml'); |
| 1165 | * |
| 1166 | * createCanvas(100, 100); |
| 1167 | * |
| 1168 | * background(200); |
| 1169 | * |
| 1170 | * // Get an array with all mammal tags. |
| 1171 | * let mammals = myXML.getChildren('mammal'); |
| 1172 | * |
| 1173 | * // Style the text. |
| 1174 | * textAlign(LEFT, CENTER); |
| 1175 | * textFont('Courier New'); |
| 1176 | * textSize(14); |
| 1177 | * |
| 1178 | * // Iterate over the mammals array. |
| 1179 | * for (let i = 0; i < mammals.length; i += 1) { |
| 1180 | * |
| 1181 | * // Calculate the y-coordinate. |
| 1182 | * let y = (i + 1) * 25; |
| 1183 | * |
| 1184 | * // Get the mammal's common name. |
| 1185 | * let name = mammals[i].getContent(); |
| 1186 | * |
| 1187 | * // Display the mammal's name. |
| 1188 | * text(name, 20, y); |
| 1189 | * } |
| 1190 | * |
| 1191 | * describe( |
| 1192 | * 'The words "Goat", "Leopard", and "Zebra" written on three separate lines. The text is black on a gray background.' |
| 1193 | * ); |
| 1194 | * } |
| 1195 | */ |
| 1196 | p5.XML = XML; |
| 1197 | } |
| 1198 | |
| 1199 | export default xml; |
| 1200 | export { XML }; |
no outgoing calls
no test coverage detected