Created
May 24, 2019 06:02
-
-
Save khoparzi/ad2f3b8dd88f4a72a6bd9d2d598ec8d2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Importing GIPHY gifs in Hydra | |
// NPM install https://github.com/Giphy/giphy-js-sdk-core | |
var GphApiClient = require('giphy-js-sdk-core') | |
giffer = GphApiClient(<YourGiphyApiKey>) | |
// With p5 | |
p = new P5() | |
s0.init({src: p.canvas}) | |
p.hide() | |
let img; | |
// Remove old image element before making a new one | |
if (img.elt != null) { img.remove() } | |
giffer.search('gifs', {"q": "hydra", "limit": 1, "offset": 5}) | |
.then((response) => { | |
response.data.forEach((gifObject) => { | |
img = p.createImg(gifObject.images.original.url) | |
img.elt.style.zIndex = -10 // Push back the image element | |
// Connect the canvas to buffer after loading image | |
img.elt.onload = () => { | |
s0.init({src: img.elt}) | |
} | |
}) | |
}) | |
p.draw = () => { | |
img.position(100,0) | |
} | |
src(s0).scale(1,1.7,1) | |
.repeat(5) | |
.out() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment