Skip to content

Commit eaa1ba8

Browse files
committed
Revise docs for pixels
1 parent 8c6b844 commit eaa1ba8

File tree

1 file changed

+35
-30
lines changed

1 file changed

+35
-30
lines changed

src/image/pixels.js

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,16 @@ p5.prototype.pixels = [];
106106

107107
/**
108108
* Copies a region of pixels from one image to another. The `blendMode`
109-
* paramter blends the images' colors to create different effects.
109+
* parameter blends the images' colors to create different effects.
110110
*
111111
* @method blend
112112
* @param {p5.Image} srcImage source image.
113-
* @param {Integer} sx x-coordinate of the source's upper left corner.
114-
* @param {Integer} sy y-coordinate of the source's upper left corner.
113+
* @param {Integer} sx x-coordinate of the source's upper-left corner.
114+
* @param {Integer} sy y-coordinate of the source's upper-left corner.
115115
* @param {Integer} sw source image width.
116116
* @param {Integer} sh source image height.
117-
* @param {Integer} dx x-coordinate of the destination's upper left corner.
118-
* @param {Integer} dy y-coordinate of the destination's upper left corner.
117+
* @param {Integer} dx x-coordinate of the destination's upper-left corner.
118+
* @param {Integer} dy y-coordinate of the destination's upper-left corner.
119119
* @param {Integer} dw destination image width.
120120
* @param {Integer} dh destination image height.
121121
* @param {Constant} blendMode the blend mode. either
@@ -213,12 +213,12 @@ p5.prototype.blend = function(...args) {
213213
*
214214
* @method copy
215215
* @param {p5.Image|p5.Element} srcImage source image.
216-
* @param {Integer} sx x-coordinate of the source's upper left corner.
217-
* @param {Integer} sy y-coordinate of the source's upper left corner.
216+
* @param {Integer} sx x-coordinate of the source's upper-left corner.
217+
* @param {Integer} sy y-coordinate of the source's upper-left corner.
218218
* @param {Integer} sw source image width.
219219
* @param {Integer} sh source image height.
220-
* @param {Integer} dx x-coordinate of the destination's upper left corner.
221-
* @param {Integer} dy y-coordinate of the destination's upper left corner.
220+
* @param {Integer} dx x-coordinate of the destination's upper-left corner.
221+
* @param {Integer} dy y-coordinate of the destination's upper-left corner.
222222
* @param {Integer} dw destination image width.
223223
* @param {Integer} dh destination image height.
224224
*
@@ -383,11 +383,10 @@ p5.prototype._copyHelper = (
383383
* @method filter
384384
* @param {Constant} filterType either THRESHOLD, GRAY, OPAQUE, INVERT,
385385
* POSTERIZE, BLUR, ERODE, DILATE or BLUR.
386-
* @param {Number} filterParam an optional parameter unique
387-
* to each filter, see above.
388-
* @param {Boolean} [useWebGL] a flag to control whether to use fast
386+
* @param {Number} [filterParam] parameter unique to each filter.
387+
* @param {Boolean} [useWebGL] flag to control whether to use fast
389388
* WebGL filters (GPU) or original image
390-
* filters (CPU); defaults to true.
389+
* filters (CPU); defaults to `true`.
391390
*
392391
* @example
393392
* <div>
@@ -552,7 +551,7 @@ p5.prototype._copyHelper = (
552551
*/
553552
/**
554553
* @method filter
555-
* @param {p5.Shader} shaderFilter a shader that's been loaded, with the
554+
* @param {p5.Shader} shaderFilter shader that's been loaded, with the
556555
* frag shader using a `tex0` uniform.
557556
*/
558557
p5.prototype.filter = function(...args) {
@@ -657,8 +656,11 @@ function parseFilterArgs(...args) {
657656
}
658657

659658
/**
660-
* Gets a pixel or a region of pixels from the canvas. `get()` is easy to use
661-
* but it's not as fast as <a href="#/p5/pixels">pixels</a>.
659+
* Gets a pixel or a region of pixels from the canvas.
660+
*
661+
* `get()` is easy to use but it's not as fast as
662+
* <a href="#/p5/pixels">pixels</a>. Use <a href="#/p5/pixels">pixels</a>
663+
* to read many pixel values.
662664
*
663665
* The version of `get()` with no parameters returns the entire canvas.
664666
*
@@ -667,20 +669,20 @@ function parseFilterArgs(...args) {
667669
* pixel at the given point.
668670
*
669671
* The version of `get()` with four parameters interprets them as coordinates
670-
* and dimensions. The first two parameters are the coordinates for the
671-
* upper-left corner of the image, regardless of the current
672-
* <a href="#/p5/imageMode">imageMode()</a>. The last two parameters are the
673-
* width and height of the image section.
672+
* and dimensions. It returns a subsection of the canvas as a
673+
* <a href="#/p5.Image">p5.Image</a> object. The first two parameters are the
674+
* coordinates for the upper-left corner of the subsection. The last two
675+
* parameters are the width and height of the subsection.
674676
*
675677
* Use <a href="#/p5.Image/get">p5.Image.get()</a> to work directly with
676678
* <a href="#/p5.Image">p5.Image</a> objects.
677679
*
678680
* @method get
679681
* @param {Number} x x-coordinate of the pixel.
680682
* @param {Number} y y-coordinate of the pixel.
681-
* @param {Number} w width of the section to be returned.
682-
* @param {Number} h height of the section to be returned.
683-
* @return {p5.Image} the rectangle <a href="#/p5.Image">p5.Image</a>.
683+
* @param {Number} w width of the subsection to be returned.
684+
* @param {Number} h height of the subsection to be returned.
685+
* @return {p5.Image} subsection as a <a href="#/p5.Image">p5.Image</a> object.
684686
* @example
685687
* <div>
686688
* <code>
@@ -740,13 +742,13 @@ function parseFilterArgs(...args) {
740742
*/
741743
/**
742744
* @method get
743-
* @return {p5.Image} the whole <a href="#/p5.Image">p5.Image</a>
745+
* @return {p5.Image} whole canvas as a <a href="#/p5.Image">p5.Image</a>.
744746
*/
745747
/**
746748
* @method get
747749
* @param {Number} x
748750
* @param {Number} y
749-
* @return {Number[]} color of pixel at x,y in array format [R, G, B, A]
751+
* @return {Number[]} color of the pixel at (x, y) in array format `[R, G, B, A]`.
750752
*/
751753
p5.prototype.get = function(x, y, w, h) {
752754
p5._validateParameters('get', arguments);
@@ -790,14 +792,17 @@ p5.prototype.loadPixels = function(...args) {
790792
};
791793

792794
/**
793-
* Sets the color of a pixel or draws an image to the canvas. `set()` is easy
794-
* to use but it's not as fast as <a href="#/p5/pixels">pixels</a>.
795+
* Sets the color of a pixel or draws an image to the canvas.
796+
*
797+
* `set()` is easy to use but it's not as fast as
798+
* <a href="#/p5/pixels">pixels</a>. Use <a href="#/p5/pixels">pixels</a>
799+
* to set many pixel values.
795800
*
796801
* `set()` interprets the first two parameters as x- and y-coordinates. It
797802
* interprets the last parameter as a grayscale value, a `[R, G, B, A]` pixel
798803
* array, a <a href="#/p5.Color">p5.Color</a> object, or a
799804
* <a href="#/p5.Image">p5.Image</a> object. If an image is passed, the first
800-
* two parameters set the coordinates for the image's upper left corner,
805+
* two parameters set the coordinates for the image's upper-left corner,
801806
* regardless of the current <a href="#/p5/imageMode">imageMode()</a>.
802807
*
803808
* <a href="#/p5/updatePixels">updatePixels()</a> must be called after using
@@ -806,8 +811,8 @@ p5.prototype.loadPixels = function(...args) {
806811
* @method set
807812
* @param {Number} x x-coordinate of the pixel.
808813
* @param {Number} y y-coordinate of the pixel.
809-
* @param {Number|Number[]|Object} c a grayscale value | a pixel array |
810-
* a <a href="#/p5.Color">p5.Color</a> object | a <a href="#/p5.Image">p5.Image</a> to copy.
814+
* @param {Number|Number[]|Object} c grayscale value | pixel array |
815+
* <a href="#/p5.Color">p5.Color</a> object | <a href="#/p5.Image">p5.Image</a> to copy.
811816
* @example
812817
* <div>
813818
* <code>

0 commit comments

Comments
 (0)