开发者

html5 canvas scroll

i have a requirement that I need to create a canvas and draw inside it programattically and put it inside a marquee, all these through javascript. Is it possible ? a few pointers please

As a follow-up: i wrote the following, it creates the canvas but does not scrolll it, but the hard coded marquee works !

<html>
<head>
<meta http-equiv="Content-Script-Type" content="text/javascript">
</head>
<body>
<marquee>you are welcome</marquee>

<input type="button" value="click" name="btn" onClick="btnClicked();"/>



<script>
function btnClicked()
{
alert('here');
var canvas = document.createElement('canvas'开发者_如何学JAVA);
      context = canvas.getContext('2d');      
// Draw whatever on your canvas  
context.beginPath();
context.moveTo(70, 140);
context.lineTo(140, 70);
context.stroke();
var div = document.createElement('div');
div.appendChild(canvas);
var marquee = document.createElement('marquee');  
marquee.appendChild(div);  
document.body.appendChild(marquee);
}
</script>
</body>
</html>


It is possible, though probably ugly.

I'll take your question literally...

var canvas = document.createElement('canvas'),

    context = canvas.getContext('2d');

    // Draw whatever on your canvas

var marquee = document.createElement('marquee');

marquee.appendChild(canvas);

document.body.appendChild(marquee);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜