| 558 | }; |
| 559 | |
| 560 | function parseFilterArgs(...args) { |
| 561 | // args could be: |
| 562 | // - operation, value, [useWebGL] |
| 563 | // - operation, [useWebGL] |
| 564 | // - shader |
| 565 | |
| 566 | let result = { |
| 567 | shader: undefined, |
| 568 | operation: undefined, |
| 569 | value: undefined, |
| 570 | useWebGL: true |
| 571 | }; |
| 572 | |
| 573 | if (args[0] instanceof p5.Shader) { |
| 574 | result.shader = args[0]; |
| 575 | return result; |
| 576 | } |
| 577 | else { |
| 578 | result.operation = args[0]; |
| 579 | } |
| 580 | |
| 581 | if (args.length > 1 && typeof args[1] === 'number') { |
| 582 | result.value = args[1]; |
| 583 | } |
| 584 | |
| 585 | if (args[args.length-1] === false) { |
| 586 | result.useWebGL = false; |
| 587 | } |
| 588 | return result; |
| 589 | } |
| 590 | |
| 591 | /** |
| 592 | * Gets a pixel or a region of pixels from the canvas. |