2.4_颜色与透明度

来源:互联网 发布:图像分类算法 简单 编辑:程序博客网 时间:2024/06/05 16:21

2.4_颜色与透明度

<!DOCTYPE html><html>    <head>        <meta charset="UTF-8">        <title>颜色与透明度</title>        <style>            body{                background: #000;            }            #canvas{                background: #fff;            }        </style>    </head>    <body>        <canvas id="canvas" width="1000" height="600"></canvas>    </body>    <script>        var canvas = document.getElementById('canvas'),            context = canvas.getContext('2d');            context.lineJoin = 'round';            context.lineWidth = 30;            context.font = '24px Helvetica';            context.fillText('Click anywhere to erase', 175,200);            context.strokeStyle = 'goldenrod';            context.fillStyle = 'rgba(0,0,255,0.5)';            context.strokeRect(75,100,200,200);            context.fillRect(325,100,200,200);            context.canvas.onmousedown = function(e){                context.clearRect(0,0,canvas.width,canvas.height);            }    </script></html>
0 0
原创粉丝点击