Skip to content

Commit 3b396a1

Browse files
committed
Revise p5.Image references
1 parent 119e9de commit 3b396a1

File tree

1 file changed

+44
-34
lines changed

1 file changed

+44
-34
lines changed

src/image/p5.Image.js

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ p5.Image = class {
118118
* @property {Number} width
119119
* @name width
120120
* @readOnly
121+
*
121122
* @example
122123
* <div>
123124
* <code>
@@ -154,6 +155,7 @@ p5.Image = class {
154155
* @property height
155156
* @name height
156157
* @readOnly
158+
*
157159
* @example
158160
* <div>
159161
* <code>
@@ -197,7 +199,8 @@ p5.Image = class {
197199
* An array containing the color of each pixel in the image.
198200
*
199201
* Colors are stored as numbers representing red, green, blue, and alpha
200-
* (RGBA) values. `img.pixels` is a one-dimensional array for performance reasons.
202+
* (RGBA) values. `img.pixels` is a one-dimensional array for performance
203+
* reasons.
201204
*
202205
* Each pixel occupies four elements in the pixels array, one for each
203206
* RGBA value. For example, the pixel at coordinates (0, 0) stores its
@@ -208,15 +211,16 @@ p5.Image = class {
208211
* for a 100×100 <a href="#/p5.Image">p5.Image</a> object has
209212
* 100 × 100 × 4 = 40,000 elements.
210213
*
211-
* Accessing the RGBA values for a pixel in the
212-
* <a href="#/p5.Image">p5.Image</a> object requires a little math as
213-
* shown below. The <a href="#/p5.Image/loadPixels">img.loadPixels()</a>
214+
* Accessing the RGBA values for a pixel in the image requires a little
215+
* math as shown in the examples below. The
216+
* <a href="#/p5.Image/loadPixels">img.loadPixels()</a>
214217
* method must be called before accessing the `img.pixels` array. The
215218
* <a href="#/p5.Image/updatePixels">img.updatePixels()</a> method must be
216219
* called after any changes are made.
217220
*
218221
* @property {Number[]} pixels
219222
* @name pixels
223+
*
220224
* @example
221225
* <div>
222226
* <code>
@@ -382,6 +386,7 @@ p5.Image = class {
382386
* values.
383387
*
384388
* @method loadPixels
389+
*
385390
* @example
386391
* <div>
387392
* <code>
@@ -465,12 +470,11 @@ p5.Image = class {
465470
* <a href="#/p5.Image/set">img.set()</a>.
466471
*
467472
* The optional parameters `x`, `y`, `width`, and `height` define a
468-
* subsection of the <a href="#/p5.Image">p5.Image</a> object to update.
469-
* Doing so can improve performance in some cases.
473+
* subsection of the image to update. Doing so can improve performance in
474+
* some cases.
470475
*
471-
* If the <a href="#/p5.Image">p5.Image</a> object was loaded from a GIF,
472-
* then calling `img.updatePixels()` will update the pixels in current
473-
* frame.
476+
* If the image was loaded from a GIF, then calling `img.updatePixels()`
477+
* will update the pixels in current frame.
474478
*
475479
* @method updatePixels
476480
* @param {Integer} x x-coordinate of the upper-left corner
@@ -479,6 +483,7 @@ p5.Image = class {
479483
* of the subsection to update.
480484
* @param {Integer} w width of the subsection to update.
481485
* @param {Integer} h height of the subsection to update.
486+
*
482487
* @example
483488
* <div>
484489
* <code>
@@ -556,34 +561,35 @@ p5.Image = class {
556561
}
557562

558563
/**
559-
* Gets a pixel or a region of pixels from a
560-
* <a href="#/p5.Image">p5.Image</a> object.
564+
* Gets a pixel or a region of pixels from the image.
561565
*
562566
* `img.get()` is easy to use but it's not as fast as
563567
* <a href="#/p5.Image/pixels">img.pixels</a>. Use
564568
* <a href="#/p5.Image/pixels">img.pixels</a> to read many pixel values.
565569
*
566570
* The version of `img.get()` with no parameters returns the entire image.
567571
*
568-
* The version of `img.get()` with two parameters interprets them as
569-
* coordinates. It returns an array with the `[R, G, B, A]` values of the
570-
* pixel at the given point.
572+
* The version of `img.get()` with two parameters, as in `img.get(10, 20)`,
573+
* interprets them as coordinates. It returns an array with the
574+
* `[R, G, B, A]` values of the pixel at the given point.
571575
*
572-
* The version of `img.get()` with four parameters interprets them as
573-
* coordinates and dimensions. It returns a subsection of the canvas as a
574-
* <a href="#/p5.Image">p5.Image</a> object. The first two parameters are
575-
* the coordinates for the upper-left corner of the subsection. The last two
576-
* parameters are the width and height of the subsection.
576+
* The version of `img.get()` with four parameters, as in
577+
* `img,get(10, 20, 50, 90)`, interprets them as
578+
* coordinates and dimensions. The first two parameters are the coordinates
579+
* of the upper-left corner of the subsection. The last two parameters are
580+
* the width and height of the subsection. It returns a subsection of the
581+
* canvas in a new <a href="#/p5.Image">p5.Image</a> object.
577582
*
578-
* Use <a href="#/p5.Image/get">img.get()</a> to work directly with
579-
* <a href="#/p5.Image">p5.Image</a> objects.
583+
* Use `img.get()` instead of <a href="#/p5/get">get()</a> to work directly
584+
* with images.
580585
*
581586
* @method get
582587
* @param {Number} x x-coordinate of the pixel.
583588
* @param {Number} y y-coordinate of the pixel.
584589
* @param {Number} w width of the subsection to be returned.
585590
* @param {Number} h height of the subsection to be returned.
586591
* @return {p5.Image} subsection as a <a href="#/p5.Image">p5.Image</a> object.
592+
*
587593
* @example
588594
* <div>
589595
* <code>
@@ -662,7 +668,7 @@ p5.Image = class {
662668
* let img2 = img.get(0, 0, img.width / 2, img.height / 2);
663669
*
664670
* // Display half of the image.
665-
* image(img2, width / 2, height / 2);
671+
* image(img2, 50, 50);
666672
*
667673
* describe('A mountain landscape drawn on top of another mountain landscape.');
668674
* }
@@ -709,6 +715,7 @@ p5.Image = class {
709715
* @param {Number|Number[]|Object} a grayscale value | pixel array |
710716
* <a href="#/p5.Color">p5.Color</a> object |
711717
* <a href="#/p5.Image">p5.Image</a> to copy.
718+
*
712719
* @example
713720
* <div>
714721
* <code>
@@ -837,6 +844,7 @@ p5.Image = class {
837844
* @method resize
838845
* @param {Number} width resized image width.
839846
* @param {Number} height resized image height.
847+
*
840848
* @example
841849
* <div>
842850
* <code>
@@ -996,8 +1004,7 @@ p5.Image = class {
9961004
}
9971005

9981006
/**
999-
* Copies pixels from a source <a href="#/p5.Image">p5.Image</a>
1000-
* to this image.
1007+
* Copies pixels from a source image to this image.
10011008
*
10021009
* The first parameter, `srcImage`, is an optional
10031010
* <a href="#/p5.Image">p5.Image</a> object to copy. If a source image isn't
@@ -1100,13 +1107,11 @@ p5.Image = class {
11001107
}
11011108

11021109
/**
1103-
* Masks part of an image with another.
1110+
* Masks part of the image with another.
11041111
*
11051112
* `img.mask()` uses another <a href="#/p5.Image">p5.Image</a> object's
1106-
* alpha channel as the alpha channel for this image.
1107-
*
1108-
* Masks are cumulative. Once a mask has been applied to a
1109-
* <a href="#/p5.Image">p5.Image</a> object, it can't be removed.
1113+
* alpha channel as the alpha channel for this image. Masks are cumulative
1114+
* and can't be removed once applied.
11101115
*
11111116
* @method mask
11121117
* @param {p5.Image} srcImage source image.
@@ -1229,6 +1234,7 @@ p5.Image = class {
12291234
* @param {Constant} filterType either THRESHOLD, GRAY, OPAQUE, INVERT,
12301235
* POSTERIZE, ERODE, DILATE or BLUR.
12311236
* @param {Number} [filterParam] parameter unique to each filter.
1237+
*
12321238
* @example
12331239
* <div>
12341240
* <code>
@@ -1420,8 +1426,7 @@ p5.Image = class {
14201426
}
14211427

14221428
/**
1423-
* Copies a region of pixels from another
1424-
* <a href="#/p5.Image">p5.Image</a> object into this one.
1429+
* Copies a region of pixels from another image into this one.
14251430
*
14261431
* The first parameter, `srcImage`, is the
14271432
* <a href="#/p5.Image">p5.Image</a> object to blend.
@@ -1460,6 +1465,7 @@ p5.Image = class {
14601465
* color | luminosity
14611466
*
14621467
* http://blogs.adobe.com/webplatform/2013/01/28/blending-features-in-canvas/
1468+
*
14631469
* @example
14641470
* <div>
14651471
* <code>
@@ -1607,14 +1613,15 @@ p5.Image = class {
16071613
* Note: The browser will either save the file immediately or prompt the user
16081614
* with a dialogue window.
16091615
*
1610-
* The image will only be downloaded as an animated GIF if the
1611-
* <a href="#/p5.Image">p5.Image</a> object was loaded from a GIF file.
1612-
* See <a href="#/p5/saveGif">saveGif()</a> to create new GIFs.
1616+
* The image will only be downloaded as an animated GIF if it was loaded
1617+
* from a GIF file. See <a href="#/p5/saveGif">saveGif()</a> to create new
1618+
* GIFs.
16131619
*
16141620
* @method save
16151621
* @param {String} filename filename. Defaults to 'untitled'.
16161622
* @param {String} [extension] file extension, either 'png' or 'jpg'.
16171623
* Defaults to 'png'.
1624+
*
16181625
* @example
16191626
* <div>
16201627
* <code>
@@ -1660,6 +1667,7 @@ p5.Image = class {
16601667
* Restarts an animated GIF at its first frame.
16611668
*
16621669
* @method reset
1670+
*
16631671
* @example
16641672
* <div>
16651673
* <code>
@@ -1708,6 +1716,7 @@ p5.Image = class {
17081716
*
17091717
* @method getCurrentFrame
17101718
* @return {Number} index of the GIF's current frame.
1719+
*
17111720
* @example
17121721
* <div>
17131722
* <code>
@@ -1749,6 +1758,7 @@ p5.Image = class {
17491758
*
17501759
* @method setFrame
17511760
* @param {Number} index index of the frame to display.
1761+
*
17521762
* @example
17531763
* <div>
17541764
* <code>

0 commit comments

Comments
 (0)