import("@silvia-odwyer/photon").then(photon=>{// Module has now been imported. // All image processing logic w/ Photon goes here.// See sample code below.}
functionfilterImage(){// Create a canvas and get a 2D context from the canvasvarcanvas=document.getElementById("canvas");varctx=canvas.getContext("2d");// Draw the image element onto the canvasctx.drawImage(newimg,0,0);// Convert the ImageData found in the canvas to a PhotonImage (so that it can communicate with the core Rust library)letimage=photon.open_image(canvas,ctx);// Filter the image, the PhotonImage's raw pixels are modifiedphoton.filter(image,"radio");// Place the modified image back on the canvasphoton.putImageData(canvas,ctx,image);}
functionfilterImage(){// Create a canvas and get a 2D context from the canvasvarcanvas=document.getElementById("canvas");varctx=canvas.getContext("2d");// Draw the image element onto the canvasctx.drawImage(newimg,0,0);// Convert the ImageData found in the canvas to a PhotonImage (so that it can communicate with the core Rust library)letimage=photon.open_image(canvas,ctx);// Filter the image, the PhotonImage's raw pixels are modifiedphoton.filter(image,"radio");photon.grayscale(image);photon.alter_red_channel(image,20);// Place the pixels back on the canvasphoton.putImageData(canvas,ctx,image);}