相思资源网 Design By www.200059.com

复制代码 代码如下:
<html>
    <body>
        <canvas id="canvas" width="100" height="100" style="background-color: #000;"/>

        <script>
            function position  (x,y){
                this.x = x;
                this.y = y;
            }

            var canvas = document.getElementById('canvas'),
                ctx = canvas.getContext('2d');
                width = canvas.width,
                height = canvas.height;
            ctx.fillStyle = "#FF0000";
            ctx.font = "20px Arial";
            ctx.fillText("妈妈",10,50);

            var pixs = ctx.getImageData(0,0,width,height).data;
            var Pixels = new Array();

            for(var i=0;i<pixs.length;i+= 4)
            {
                var r = pixs[i],
                    g = pixs[i+1],
                    b = pixs[i+2],
                    a = pixs[i+3];

                if(r != 0 || g != 0 || b != 0 ){
                    var x = i%400;
                    var y = i/400;
                    Pixels.push(new position(x,y));
                }
            }

        </script>
    </body>
</html>

标签:
javascript,像素点

相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com

评论“javascript根据像素点取位置示例”

暂无javascript根据像素点取位置示例的评论...