You can use HTML <canvas>
to generate images via JavaScript. I find it helpful to do as much of the composition beforehand in
Before using HTML Canvas, you’ll want to load both your image assets and any custom typefaces the composition might require.
Here’s a Promise function for loading images.
loadImage(url) {
return new Promise((resolve, revoke) => {
let img = new Image()
img.onload = () => {
resolve(img)
}
img.crossOrigin = 'Anonymous'
img.src = url
})
}
And another you can use for preloading fonts.
loadFont(url) {
return new Promise((resolve, revoke) => {
let font = new FontFace('SF Movie Poster, `url(${url})`)
font.load()
.then(face => {
document.fonts.add(face)
resolve()
})
.catch(revoke)
})
}
For more info on loading fonts, check out this excellent post.
#web-development #sharing #marketing #ios #programming