load image/texture from arraybuffer
Some checks failed
Build and Deploy / build-macos (push) Failing after 3s
Build and Deploy / build-windows (CLANG64) (push) Has been cancelled
Build and Deploy / package-dist (push) Has been cancelled
Build and Deploy / deploy-itch (push) Has been cancelled
Build and Deploy / deploy-gitea (push) Has been cancelled
Build and Deploy / build-linux (push) Has been cancelled
Some checks failed
Build and Deploy / build-macos (push) Failing after 3s
Build and Deploy / build-windows (CLANG64) (push) Has been cancelled
Build and Deploy / package-dist (push) Has been cancelled
Build and Deploy / deploy-itch (push) Has been cancelled
Build and Deploy / deploy-gitea (push) Has been cancelled
Build and Deploy / build-linux (push) Has been cancelled
This commit is contained in:
@@ -127,6 +127,19 @@ graphics.is_image[prosperon.DOC] = `
|
||||
:return: True if 'obj' has a .texture and a .rect property, indicating it's an image object.
|
||||
`
|
||||
|
||||
graphics.texture_from_data = function(data)
|
||||
{
|
||||
if (!(data instanceof ArrayBuffer)) return undefined
|
||||
|
||||
var img = {
|
||||
surface: graphics.make_texture(data)
|
||||
}
|
||||
render.load_texture(img)
|
||||
decorate_rect_px(img)
|
||||
|
||||
return img
|
||||
}
|
||||
|
||||
graphics.texture = function texture(path) {
|
||||
if (typeof path !== 'string') {
|
||||
return path // fallback if already an image object
|
||||
|
||||
@@ -77,9 +77,8 @@ function is_url(str)
|
||||
|
||||
function parse_data(res)
|
||||
{
|
||||
var data = res.data
|
||||
console.log("DOWNLOAD DONE! size was " + data.byteLength)
|
||||
console.log(res.type)
|
||||
if (!res.type.startsWith('image')) return
|
||||
img = graphics.texture_from_data(res.data)
|
||||
}
|
||||
|
||||
$_.receiver(e => {
|
||||
|
||||
Reference in New Issue
Block a user