-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstarry-night.html
41 lines (32 loc) · 1.04 KB
/
starry-night.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<html>
<head></head>
<body>
<div id="main"></div>
<script src="starry-night.js"></script>
<script>
var node = document.getElementById("main");
var app = Elm.VanGogh.embed(node);
app.ports.checkImageData.subscribe( function(imageName){
var imageData = getImageData(imageName);
// this was the typo: app.ports.getImageData,send(imageData);
app.ports.getImageData.send(imageData);
});
function getImageData( imageName ) {
// have a real implementation!
var canvas = document.createElement("canvas")
canvas.setAttribute("width", 500)
canvas.setAttribute("height", 300);
ctx = canvas.getContext("2d");
var image = new Image();
image.src = "starry-night.jpg";
ctx.drawImage( image, 0, 0, 500, 300 );
// javascript "types" LOL
w = Array()
ctx.getImageData(0,0,500,300).data.forEach(function(t) { w.push(t);} );
//node.appendChild( canvas );
//node.removeChild( canvas );
return w;
}
</script>
</body>
</html>