|
|
|
@ -214,27 +214,23 @@ function handle_event(state, context, event, relax = false) {
@@ -214,27 +214,23 @@ function handle_event(state, context, event, relax = false) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
case EVENT.IMAGE: { |
|
|
|
|
need_draw = true; |
|
|
|
|
console.error('todo'); |
|
|
|
|
// const url = config.image_url + event.image_id;
|
|
|
|
|
// const item = document.createElement('img');
|
|
|
|
|
|
|
|
|
|
// item.classList.add('floating-image');
|
|
|
|
|
// item.style['z-index'] = state.events.length;
|
|
|
|
|
// item.setAttribute('data-image-id', event.image_id);
|
|
|
|
|
// item.setAttribute('src', url);
|
|
|
|
|
// item.style.transform = `translate(${event.x}px, ${event.y}px)`;
|
|
|
|
|
|
|
|
|
|
// elements.images.appendChild(item);
|
|
|
|
|
// state.images[event.image_id] = {
|
|
|
|
|
// 'x': event.x, 'y': event.y
|
|
|
|
|
// };
|
|
|
|
|
// const r = await fetch(config.image_url + event.image_id);
|
|
|
|
|
// const blob = await r.blob();
|
|
|
|
|
// const bitmap = await createImageBitmap(blob);
|
|
|
|
|
// event.bitmap = bitmap;
|
|
|
|
|
// const bbox = bitmap_bbox(event);
|
|
|
|
|
// state.ctx0.drawImage(bitmap, bbox.xmin, bbox.ymin);
|
|
|
|
|
try { |
|
|
|
|
(async () => { |
|
|
|
|
const url = config.image_url + event.image_id; |
|
|
|
|
const r = await fetch(config.image_url + event.image_id); |
|
|
|
|
const blob = await r.blob(); |
|
|
|
|
const bitmap = await createImageBitmap(blob); |
|
|
|
|
const p = {'x': event.x, 'y': event.y}; |
|
|
|
|
|
|
|
|
|
add_image(context, bitmap, p); |
|
|
|
|
|
|
|
|
|
// God knows when this will actually complete (it loads the image from the server)
|
|
|
|
|
// so do not set need_draw. Instead just schedule the draw ourselves when done
|
|
|
|
|
schedule_draw(state, context); |
|
|
|
|
})(); |
|
|
|
|
} catch (e) { |
|
|
|
|
console.log('Could not load image bitmap:', e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|