Skip to content

Commit 8ece3f8

Browse files
author
Lauren McCarthy
committed
Merge pull request #633 from workergnome/imagePixels_doc_fix
Better documentation of the pixels array.
2 parents 2151481 + 2590fa8 commit 8ece3f8

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

src/image/pixels.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,18 @@ define(function (require) {
1313
require('p5.Color');
1414

1515
/**
16-
* Array containing the values for all the pixels in the display window.
17-
* These values are numbers. This array is the size of the display window x4,
18-
* representing the R, G, B, A values in order for each pixel, moving from
19-
* left to right across each row, then down each column. For example,
20-
* if the image is 100x100 pixels, there will be 40000. The first four values
21-
* (indices 0-3) in the array will be the R, G, B, A values of the pixel at
22-
* (0, 0). The second four values (indices 4-7) will contain the R, G, B, A
23-
* values of the pixel at (1, 0). More generally, to set values for a pixel
24-
* at (x, y):
16+
* <a href='https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference
17+
* /Global_Objects/Uint8ClampedArray' target='_blank'>Uint8ClampedArray</a>
18+
* containing the values for all the pixels in the display
19+
* window. These values are numbers. This array is the size of the display
20+
* window x4, representing the R, G, B, A values in order for each pixel,
21+
* moving from left to right across each row, then down each column. For
22+
* example, if the image is 100x100 pixels, there will be 40000. The
23+
* first four values (indices 0-3) in the array will be the R, G, B, A
24+
* values of the pixel at (0, 0). The second four values (indices 4-7) will
25+
* contain the R, G, B, A values of the pixel at (1, 0). More generally, to
26+
* set values for a pixel at (x, y):
27+
* <br>
2528
* <code>pixels[y*width+x] = r;
2629
* pixels[y*width+x+1] = g;
2730
* pixels[y*width+x+2] = b;
@@ -30,6 +33,11 @@ define(function (require) {
3033
* Before accessing this array, the data must loaded with the loadPixels()
3134
* function. After the array data has been modified, the updatePixels()
3235
* function must be run to update the changes.
36+
* <br><br>
37+
* Note that this is not a standard javascript array. This means that
38+
* standard javascript functions such as <code>slice()</code> or
39+
* <code>arrayCopy()</code> do not
40+
* work.
3341
*
3442
* @property pixels[]
3543
* @example

0 commit comments

Comments
 (0)