欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

HTML5 代码系列:画布动画 - 碰碰球

最编程 2024-07-12 10:27:46
...
<!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title>canvas动画--碰碰球</title> <style type="text/css"> canvas { border-top:2px solid #f00; border-right:2px solid #f90; border-left:2px solid blue; border-bottom:2px solid green; } </style> <script type="text/javascript"> // 定义一个动画对象 var animation={ }; // 为该对象添加属性 // 添加定时器 animation.interval=null; // 移动变换x方向的偏移量 animation.x=100; // 移动变换y方向的偏移量 animation.y=50; // x方向的移动步长 animation.xstep=2; // y方向的移动步长 animation.ystep=2; // 圆形半径 animation.radius=<