Skip to content

Commit 5077a33

Browse files
author
lauren mccarthy
committed
minor formatting changes to save method
1 parent ab11cbe commit 5077a33

File tree

3 files changed

+83
-27
lines changed

3 files changed

+83
-27
lines changed

docs/img/p5js-beta.svg

Lines changed: 54 additions & 0 deletions
Loading

src/output/files.js

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -107,34 +107,40 @@ define(function (require) {
107107
// filename, [extension] [canvas] --> saveImage
108108

109109
/**
110-
* Save an image, text, json, csv, wav, or html. Prompts download to
111-
* the client's computer.<br/>
112-
* <br/>
113-
* The default behavior is to save an image from the canvas. For example:
114-
* <br/><br/>
115-
* <code>save()</code><br/>
116-
* <code>save('myFile.jpg')</code><br/><br/>
110+
* <p>Save an image, text, json, csv, wav, or html. Prompts download to
111+
* the client's computer. <b>Note that it is not recommended to call save()
112+
* within draw if it's looping, as the save() function will open a new save
113+
* dialog every frame.</b></p>
114+
* <p>The default behavior is to save the canvas as an image.
115+
* For example:</p>
116+
* <pre class='language-javascript'><code>
117+
* save();
118+
* save('myFile.jpg');
119+
* </code></pre>
117120
*
118-
* Alternately, the first parameter can be an Array of Strings,
121+
* <p>Alternately, the first parameter can be an Array of Strings,
119122
* an Array of JSON, a JSON object, a p5.Table, a p5.Image, or a
120123
* p5.SoundFile (requires p5.sound). The second parameter is a filename
121124
* (including extension). The third parameter is for options specific
122125
* to this type of object. This method will save a file that fits the
123-
* given paramaters. For example: <br/><br/>
124-
* <code>save(myTable, 'myTable.html')</code> Saves table as html file<br/>
125-
* <code>save(myTable, 'myTable.csv',)</code> Comma Separated Values<br/>
126-
* <code>save(myTable, 'myTable.tsv')</code> Tab Separated Values<br/>
127-
* <br/>
128-
* <code>save(myJSON, 'my.json')</code> Saves pretty JSON<br/>
129-
* <code>save(myJSON, 'my.json', true)</code> Optimizes JSON filesize<br/>
130-
* <br/>
131-
* <code>save(img, 'my.png')</code> Saves pImage as a png image<br/>
132-
* <br/>
133-
* <code>save(arrayOfStrings, 'my.txt')</code> Saves strings to a
134-
* text file with line breaks after each item in the array<br/>
126+
* given paramaters. For example:</p>
127+
*
128+
* <pre class='language-javascript'><code>
129+
* save(myTable, 'myTable.html'); // Saves table as html file
130+
* save(myTable, 'myTable.csv',); // Comma Separated Values
131+
* save(myTable, 'myTable.tsv'); // Tab Separated Values
132+
*
133+
* save(myJSON, 'my.json'); // Saves pretty JSON
134+
* save(myJSON, 'my.json', true); // Optimizes JSON filesize
135+
*
136+
* save(img, 'my.png'); // Saves pImage as a png image
135137
*
136-
* @method save
137-
* @param {[Object/String]} object/filename If filename is provided, will
138+
* save(arrayOfStrings, 'my.txt'); // Saves strings to a text file with line
139+
* // breaks after each item in the array
140+
* </code></pre>
141+
*
142+
* @method save
143+
* @param {[Object|String]} objectOrFilename If filename is provided, will
138144
* save canvas as an image with
139145
* either png or jpg extension
140146
* depending on the filename.
@@ -223,7 +229,6 @@ define(function (require) {
223229
* The file saving process and location of the saved file will
224230
* vary between web browsers.
225231
*
226-
* @method saveJSON
227232
* @param {Array|Object} json
228233
* @param {String} filename
229234
* @param {Boolean} [optimize] If true, removes line breaks
@@ -278,7 +283,6 @@ define(function (require) {
278283
* The file saving process and location of the saved file will
279284
* vary between web browsers.
280285
*
281-
* @method saveStrings
282286
* @param {Array} list string array to be written
283287
* @param {String} filename filename for output
284288
* @example
@@ -332,7 +336,6 @@ define(function (require) {
332336
* The file saving process and location of the saved file will
333337
* vary between web browsers.
334338
*
335-
* @method saveTable
336339
* @param {p5.Table} Table the Table object to save to a file
337340
* @param {String} filename the filename to which the Table should be saved
338341
* @param {[String]} options can be one of "tsv", "csv", or "html"

src/output/image.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ define(function (require) {
1010
* image in the window and the user must provide their own
1111
* filename on save-as. Other browsers will either save the
1212
* file immediately, or prompt the user with a dialogue window.
13-
*
14-
* @method saveCanvas
13+
*
1514
* @param {[String]} filename
1615
* @param {[String]} extension 'jpg' or 'png'
1716
* @param {[Canvas]} canvas a variable representing a

0 commit comments

Comments
 (0)