File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -281,9 +281,10 @@ p5.prototype.radians = angle => angle * constants.DEG_TO_RAD;
281281/**
282282 * Sets the current mode of p5 to the given mode. Default mode is RADIANS.
283283 *
284+ * Calling <a href="#/p5/angleMode">angleMode()</a> with no arguments returns current anglemode.
284285 * @method angleMode
285286 * @param {Constant } mode either RADIANS or DEGREES
286- *
287+ * @chainable
287288 * @example
288289 * <div>
289290 * <code>
@@ -306,10 +307,18 @@ p5.prototype.radians = angle => angle * constants.DEG_TO_RAD;
306307 * </div>
307308 *
308309 */
310+ /**
311+ * @method angleMode
312+ * @return {Constant } mode either RADIANS or DEGREES
313+ */
309314p5 . prototype . angleMode = function ( mode ) {
310- if ( mode === constants . DEGREES || mode === constants . RADIANS ) {
315+ p5 . _validateParameters ( 'angleMode' , arguments ) ;
316+ if ( typeof mode === 'undefined' ) {
317+ return this . _angleMode ;
318+ } else if ( mode === constants . DEGREES || mode === constants . RADIANS ) {
311319 this . _angleMode = mode ;
312320 }
321+ return this ;
313322} ;
314323
315324/**
Original file line number Diff line number Diff line change @@ -60,6 +60,16 @@ suite('Trigonometry', function() {
6060 myp5 . angleMode ( 'wtflolzkk' ) ;
6161 assert . equal ( myp5 . _angleMode , 'radians' ) ;
6262 } ) ;
63+
64+ test ( 'should return radians' , function ( ) {
65+ myp5 . angleMode ( RADIANS ) ;
66+ assert . equal ( myp5 . angleMode ( ) , 'radians' ) ;
67+ } ) ;
68+
69+ test ( 'should return degrees' , function ( ) {
70+ myp5 . angleMode ( DEGREES ) ;
71+ assert . equal ( myp5 . angleMode ( ) , 'degrees' ) ;
72+ } ) ;
6373 } ) ;
6474
6575 suite ( 'p5.prototype.degrees' , function ( ) {
You can’t perform that action at this time.
0 commit comments