(input)
| 1808 | * creating this texture is somewhat expensive. |
| 1809 | */ |
| 1810 | makeDiffusedTexture(input) { |
| 1811 | // if one already exists for a given input image |
| 1812 | if (this.diffusedTextures.get(input) != null) { |
| 1813 | return this.diffusedTextures.get(input); |
| 1814 | } |
| 1815 | // if not, only then create one |
| 1816 | let newFramebuffer; |
| 1817 | // hardcoded to 200px, because it's going to be blurry and smooth |
| 1818 | let smallWidth = 200; |
| 1819 | let width = smallWidth; |
| 1820 | let height = Math.floor(smallWidth * (input.height / input.width)); |
| 1821 | newFramebuffer = new Framebuffer(this, { |
| 1822 | width, |
| 1823 | height, |
| 1824 | density: 1, |
| 1825 | }); |
| 1826 | // create framebuffer is like making a new sketch, all functions on main |
| 1827 | // sketch it would be available on framebuffer |
| 1828 | if (!this.diffusedShader) { |
| 1829 | this.diffusedShader = this._createImageLightShader("diffused"); |
| 1830 | } |
| 1831 | newFramebuffer.draw(() => { |
| 1832 | this.shader(this.diffusedShader); |
| 1833 | this._setImageLightShaderUniforms(this.diffusedShader, input); |
| 1834 | this.states.setValue("strokeColor", null); |
| 1835 | this.noLights(); |
| 1836 | this.plane(width, height); |
| 1837 | }); |
| 1838 | this.diffusedTextures.set(input, newFramebuffer); |
| 1839 | return newFramebuffer; |
| 1840 | } |
| 1841 | getDiffusedTexture(input) { |
| 1842 | return this.diffusedTextures.get(input); |
| 1843 | } |
no test coverage detected