@@ -2135,7 +2135,11 @@ if (navigator.mediaDevices.getUserMedia === undefined) {
21352135 * W3C documentation</a> for possible properties. Different browsers support different
21362136 * properties.
21372137 *
2138- * The second parameter, `callback`, is optional. It's a function to call once
2138+ * The 'flipped' property is an optional property which can be set to `{flipped:true}`
2139+ * to mirror the video output.If it is true then it means that video will be mirrored
2140+ * or flipped and if nothing is mentioned then by default it will be `false`.
2141+ *
2142+ * The second parameter,`callback`, is optional. It's a function to call once
21392143 * the capture is ready for use. The callback function should have one
21402144 * parameter, `stream`, that's a
21412145 * <a href="https://developer.mozilla.org/en-US/docs/Web/API/MediaStream" target="_blank">MediaStream</a> object.
@@ -2148,6 +2152,8 @@ if (navigator.mediaDevices.getUserMedia === undefined) {
21482152 * @param {String|Constant|Object } [type] type of capture, either AUDIO or VIDEO,
21492153 * or a constraints object. Both video and audio
21502154 * audio streams are captured by default.
2155+ * @param {Object } [flipped] flip the capturing video and mirror the output with `{flipped:true}`. By
2156+ * default it is false.
21512157 * @param {Function } [callback] function to call once the stream
21522158 * has loaded.
21532159 * @return {p5.Element } new <a href="#/p5.Element">p5.Element</a> object.
@@ -2183,6 +2189,19 @@ if (navigator.mediaDevices.getUserMedia === undefined) {
21832189 * }
21842190 * </code>
21852191 * </div>
2192+ * <div class='notest'>
2193+ * <code>
2194+ * let capture;
2195+ *
2196+ * function setup() {
2197+ * // Create the video capture with mirrored output.
2198+ * capture = createCapture(VIDEO,{ flipped:true });
2199+ * capture.size(100,100);
2200+ * describe('A video stream from the webcam with flipped or mirrored output.');
2201+ * }
2202+ *
2203+ * </code>
2204+ * </div>
21862205 *
21872206 * <div class='notest norender'>
21882207 * <code>
@@ -2227,11 +2246,12 @@ p5.prototype.createCapture = function(...args) {
22272246 if ( arg === p5 . prototype . VIDEO ) useAudio = false ;
22282247 else if ( arg === p5 . prototype . AUDIO ) useVideo = false ;
22292248 else if ( typeof arg === 'object' ) {
2230- constraints = arg ;
2231- flipped = constraints . flipped || false ;
2232- }
2233- else if ( typeof arg === 'boolean' ) {
2234- flipped = arg ;
2249+ // Check if the argument is an object with a 'flipped' property
2250+ if ( arg . flipped !== undefined ) {
2251+ flipped = arg . flipped ;
2252+ } else {
2253+ constraints = arg ;
2254+ }
22352255 }
22362256 else if ( typeof arg === 'function' ) {
22372257 callback = arg ;
0 commit comments