日期:2014-05-16  浏览次数:20336 次

canvas 改变图片颜色
 
<!DOCTYPE html>
<!--    to moving elements in a straight line   -->
    <html>
        <head>
            <meta charset='utf-8'/>
            <script type="text/javascript"> 
                
                
                window.addEventListener('load',canvasApp, false);
                
                function canvasApp(args) {
                    var canvas = document.getElementById("MyCanvas");
                    var context = canvas.getContext("2d");
                    
                    var logoL = new Image();
                        logoL.src= "../img/csrLeft.png";
                    var widthL = 88;
                    var logoR = new Image();
                        logoR.src = "../img/csrRight.png";
                    var widthR = 286;
                    var height = 31;
                    context.drawImage(logoL,0,0);
                    
                    var dataL = context.getImageData(0,0,widthL,height);
                    
                    for (var i=0; i<dataL.data.length; i+=4 ) {
                        
                        dataL.data[i] = 29;