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

主頁 > 知識庫 > 使用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圖的示例的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 嘉鱼县| 湘潭市| 桦甸市| 东乌珠穆沁旗| 洪洞县| 齐齐哈尔市| 香格里拉县| 禹城市| 蓬溪县| 轮台县| 沙田区| 辰溪县| 陈巴尔虎旗| 五河县| 健康| 色达县| 皮山县| 赤水市| 铜山县| 城口县| 勃利县| 绥化市| 日喀则市| 郴州市| 瓦房店市| 循化| 仪陇县| 石河子市| 宣汉县| 内乡县| 什邡市| 卫辉市| 剑阁县| 社旗县| 新和县| 丰宁| 灵山县| 西吉县| 嘉善县| 来凤县| 黎平县|