校园春色亚洲色图_亚洲视频分类_中文字幕精品一区二区精品_麻豆一区区三区四区产品精品蜜桃

主頁 > 知識庫 > 使用html5制作loading圖的示例

使用html5制作loading圖的示例

熱門標簽:地圖標注柱狀圖 怎么做百度地圖標注 智能芯電話機器人 臨海地圖標注app 小朱地圖標注 咸陽穩定外呼系統軟件 百度地圖標注為什么總是封號 四川移動電銷外呼客戶管理系統 400開頭的電話好申請不


復制代碼
代碼如下:

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<canvas id = "canvas"></canvas></p> <p> <script>
var Loading = function (canvas, options) {
this.canvas = document.getElementById(canvas);
this.options = options;
};</p> <p> Loading.prototype = {
constructor: Loading,
show: function () {
var canvas = this.canvas,
begin = this.options.begin,
old = this.options.old,
lineWidth = this.options.lineWidth,
canvasCenter = {x: canvas.width / 2, y: canvas.height / 2},
ctx = canvas.getContext("2d"),
color = this.options.color,
num = this.options.num,
angle = 0,
lineCap = this.options.lineCap,
CONST_PI = Math.PI * (360 / num) / 180;
window.timer = setInterval(function () {
ctx.clearRect(0, 0, canvas.width, canvas.height);
for (var i = 0; i < num; i += 1) {
ctx.beginPath();
ctx.strokeStyle = color[num - 1 - i];
ctx.lineWidth = lineWidth;
ctx.lineCap= lineCap;
ctx.moveTo(canvasCenter.x + Math.cos(CONST_PI * i + angle) * begin, canvasCenter.y + Math.sin(CONST_PI * i + angle) * begin);
ctx.lineTo(canvasCenter.x + Math.cos(CONST_PI * i + angle) * old, canvasCenter.y + Math.sin(CONST_PI * i + angle) * old);
ctx.stroke();
ctx.closePath();
}
angle += CONST_PI;
console.log(angle)
},50);
},
hide: function () {
clearInterval(window.timer);
}
};</p> <p> (function () {
var options = {
num : 8,
begin: 20,
old: 40,
lineWidth: 10,
lineCap: "round",
color: ["rgb(0, 0, 0)", "rgb(20, 20, 20)","rgb(40, 40, 40)", "rgb(60, 60, 60)","rgb(80, 80, 80)", "rgb(100, 100, 100)", "rgb(120, 120, 120)", "rgb(140, 140, 140)"]
};
var loading = new Loading("canvas", options);
loading.show();
}());
</script>
</body>
</html>


效果圖:

標簽:陜西 平頂山 山南 黃石 南平 公主嶺 黃石 平涼

巨人網絡通訊聲明:本文標題《使用html5制作loading圖的示例》,本文關鍵詞  使用,html5,制作,loading,圖,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《使用html5制作loading圖的示例》相關的同類信息!
  • 本頁收集關于使用html5制作loading圖的示例的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 昌平区| 阳新县| 宁德市| 翼城县| 兴国县| 区。| 定安县| 铁岭县| 临泉县| 来宾市| 陆河县| 聊城市| 西平县| 怀安县| 萍乡市| 中西区| 张北县| 新泰市| 旺苍县| 揭阳市| 洱源县| 苏州市| 宁远县| 德清县| 监利县| 佳木斯市| 抚顺市| 堆龙德庆县| 太谷县| 刚察县| 雅安市| 桐庐县| 剑河县| 克东县| 光泽县| 夏津县| 宁陵县| 桦甸市| 菏泽市| 徐汇区| 酒泉市|