Home Heaps.io - Javascript js.html.File to h2d.Tile Get js.html.File: ⎗ ✓ 1 2 3 4 5 6 7 8 9item.ondrop = function(event: DragEvent) { event.preventDefault(); var files = event.dataTransfer.files; if (files.length > 0) { for (file in files) { //... } } }; Read file into base64 and use as Tile: ⎗ ✓ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15var reader = new FileReader(); reader.onload = function(event) { var image = new Image(); image.onload = function(_) { var canvas: CanvasElement = cast Browser.document.createElement("canvas"); canvas.width = image.width; canvas.height = image.height; var context = canvas.getContext("2d"); context.drawImage(image, 0, 0); var tile = HeapsUtil.base64StringToTile(canvas.toDataURL("image/png")); //... }; image.src = cast event.target.result; }; reader.readAsDataURL(file);
Warning LINK You are about to visit a link which has been flagged with the above content warnings. Do you wish to continue? Continue Cancel