summaryrefslogblamecommitdiff
path: root/public/playground.html
blob: 4e9e98c3014f9d834e439454fc60f83c7e92e94b (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
               
                
      



                                         



                                                      
                         
        

                                                    
                                                                          
 
                                                                      






                                                                        
       
       
<!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>
<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);
});
</script>
</body>
</html>