summaryrefslogtreecommitdiff
path: root/public/playground.html
blob: 10ac6c232afb62815423a0aa38e44b9b26139029 (plain) (blame)
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
<!DOCTYPE html>
<meta charset="utf-8">
<html>
<head>
</head>
<body>
<canvas id="original" width="32" height="32"></canvas>
<canvas id="dyed" width="32" height="32"></canvas>
</body>

<script src="js/mp/dye.js"></script>
<script src="js/mp/resource.js"></script>
<script>
var dyeString = "R:#ede5b2,fff7bf|G:#cccccc,ffffff";
var dyeData = mp.dye.parseDyeString(dyeString);

mp.resource.loadImage("bigcake.png", function(err, imageData) {
    var oContext = document.getElementById("original").getContext("2d");
    var dContext = document.getElementById("dyed").getContext("2d");
    oContext.putImageData(imageData, 0, 0);
    mp.dye.dyeImage(imageData.data, dyeData);
    dContext.putImageData(imageData, 0, 0);
});
</script>
</html>