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.
|
: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) {
|
graphics.texture = function texture(path) {
|
||||||
if (typeof path !== 'string') {
|
if (typeof path !== 'string') {
|
||||||
return path // fallback if already an image object
|
return path // fallback if already an image object
|
||||||
|
|||||||
@@ -77,9 +77,8 @@ function is_url(str)
|
|||||||
|
|
||||||
function parse_data(res)
|
function parse_data(res)
|
||||||
{
|
{
|
||||||
var data = res.data
|
if (!res.type.startsWith('image')) return
|
||||||
console.log("DOWNLOAD DONE! size was " + data.byteLength)
|
img = graphics.texture_from_data(res.data)
|
||||||
console.log(res.type)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$_.receiver(e => {
|
$_.receiver(e => {
|
||||||
|
|||||||
Reference in New Issue
Block a user