Skip to content

Commit 26cea01

Browse files
author
Derek Kinsman
committed
Adding transform reference examples.
1 parent 6eee434 commit 26cea01

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

src/transform/transform.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ define(function (require) {
3030
* @param {Number} n11 numbers which define the 3x2 matrix to be multiplied
3131
* @param {Number} n12 numbers which define the 3x2 matrix to be multiplied
3232
* @return {p5} the p5 object
33+
* @example
34+
* <div>
35+
* <code>
36+
* // Example in the works.
37+
* </code>
38+
* </div>
3339
*/
3440
p5.prototype.applyMatrix = function(n00, n01, n02, n10, n11, n12) {
3541
this.canvas.getContext('2d').transform(n00, n01, n02, n10, n11, n12);
@@ -48,6 +54,12 @@ define(function (require) {
4854
*
4955
* @method printMatrix
5056
* @return {p5} the p5 object
57+
* @example
58+
* <div>
59+
* <code>
60+
* // Example in the works.
61+
* </code>
62+
* </div>
5163
*/
5264
p5.prototype.printMatrix = function() {
5365
throw new Error('printMatrix() not implemented');
@@ -62,6 +74,12 @@ define(function (require) {
6274
*
6375
* @method resetMatrix
6476
* @return {p5} the p5 object
77+
* @example
78+
* <div>
79+
* <code>
80+
* // Example in the works.
81+
* </code>
82+
* </div>
6583
*/
6684
p5.prototype.resetMatrix = function() {
6785
this.canvas.getContext('2d').setTransform();
@@ -90,6 +108,14 @@ define(function (require) {
90108
* @param {Number} angle the angle of rotation, specified in radians
91109
* or degrees, depending on current angleMode
92110
* @return {p5} the p5 object
111+
* @example
112+
* <div>
113+
* <code>
114+
* translate(width/2, height/2);
115+
* rotate(PI/3.0);
116+
* rect(-26, -26, 52, 52);
117+
* </code>
118+
* </div>
93119
*/
94120
p5.prototype.rotate = function(r) {
95121
if (this._angleMode === constants.DEGREES) {
@@ -143,6 +169,22 @@ define(function (require) {
143169
* are given
144170
* @param {Number} [y] percentage to scale the object in the y-axis
145171
* @return {p5} the p5 object
172+
* @example
173+
* <div>
174+
* <code>
175+
* translate(width/2, height/2);
176+
* rotate(PI/3.0);
177+
* rect(-26, -26, 52, 52);
178+
* </code>
179+
* </div>
180+
*
181+
* <div>
182+
* <code>
183+
* rect(30, 20, 50, 50);
184+
* scale(0.5, 1.3);
185+
* rect(30, 20, 50, 50);
186+
* </code>
187+
* </div>
146188
*/
147189
p5.prototype.scale = function() {
148190
var x = 1.0, y = 1.0;
@@ -182,6 +224,14 @@ define(function (require) {
182224
* @param {Number} angle angle of shear specified in radians or degrees,
183225
* depending on current angleMode
184226
* @return {p5} the p5 object
227+
* @example
228+
* <div>
229+
* <code>
230+
* translate(width/4, height/4);
231+
* shearX(PI/4.0);
232+
* rect(0, 0, 30, 30);
233+
* </code>
234+
* </div>
185235
*/
186236
p5.prototype.shearX = function(angle) {
187237
if (this._angleMode === constants.DEGREES) {
@@ -214,6 +264,14 @@ define(function (require) {
214264
* @param {Number} angle angle of shear specified in radians or degrees,
215265
* depending on current angleMode
216266
* @return {p5} the p5 object
267+
* @example
268+
* <div>
269+
* <code>
270+
* translate(width/4, height/4);
271+
* shearY(PI/4.0);
272+
* rect(0, 0, 30, 30);
273+
* </code>
274+
* </div>
217275
*/
218276
p5.prototype.shearY = function(angle) {
219277
if (this._angleMode === constants.DEGREES) {
@@ -242,6 +300,23 @@ define(function (require) {
242300
* @param {Number} x left/right translation
243301
* @param {Number} y up/down translation
244302
* @return {p5} the p5 object
303+
* @example
304+
* <div>
305+
* <code>
306+
* translate(30, 20);
307+
* rect(0, 0, 55, 55);
308+
* </code>
309+
* </div>
310+
*
311+
* <div>
312+
* <code>
313+
* rect(0, 0, 55, 55); // Draw rect at original 0,0
314+
* translate(30, 20);
315+
* rect(0, 0, 55, 55); // Draw rect at new 0,0
316+
* translate(14, 14);
317+
* rect(0, 0, 55, 55); // Draw rect at new 0,0
318+
* </code>
319+
* </div>
245320
*/
246321
p5.prototype.translate = function(x, y) {
247322
this.canvas.getContext('2d').translate(x, y);

0 commit comments

Comments
 (0)