summaryrefslogtreecommitdiff
path: root/public/playground.html
blob: 0fd1b6f737a1fb2cc1ede51c4dfe4c4ea40bc5b7 (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
26
27
28
29
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Mana Portal Playground</title>
<script src="js/mp/dye.js"></script>
<script src="js/mp/resource.js"></script>
</head>
<body>
<canvas id="original" width="32" height="32"></canvas>
<canvas id="dyed" width="32" height="32"></canvas>
<span id="dyeOut"></span>
<img id="out"/>
<script>
var dyeString = "R:#ede5b2,fff7bf|G:#cccccc,ffffff";
var dyeData = mp.dye.parseDyeString(dyeString);
document.getElementById("dyeOut").innerText = mp.dye.asDyeString(dyeData);

mp.resource.loadImage("images/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);
    document.getElementById("out").src = document.getElementById("dyed").toDataURL("image/png");
});
</script>
</body>
</html>