diff --git a/README.md b/README.md index 989bacca..198599cb 100644 --- a/README.md +++ b/README.md @@ -203,9 +203,13 @@ const myFunc = gpu.createKernel(function(image) { }) .setGraphical(true) .setOutput([100]); - -myFunc([1, 2, 3]); -// Result: colorful image + +const image = new document.createElement('img'); +image.src = 'my/image/source.png'; +image.onload = () => { + myFunc(image); + // Result: colorful image +}; ``` An Array of HTML Images: @@ -217,9 +221,25 @@ const myFunc = gpu.createKernel(function(image) { }) .setGraphical(true) .setOutput([100]); - -myFunc([1, 2, 3]); -// Result: colorful image + +const image1 = new document.createElement('img'); +image1.src = 'my/image/source1.png'; +image1.onload = onload; +const image2 = new document.createElement('img'); +image2.src = 'my/image/source2.png'; +image2.onload = onload; +const image3 = new document.createElement('img'); +image3.src = 'my/image/source3.png'; +image3.onload = onload; +const totalImages = 3; +let loadedImages = 0; +function onload() { + loadedImages++; + if (loadedImages === totalImages) { + myFunc([image1, image2, image3]); + // Result: colorful image composed of many images + } +}; ``` ## Graphical Output