1- /**
2- * Created by evolution on 15-9-19.
3- */
41window . onload = function ( ) {
52 //创建canvas对象
63 var canvasObj = new Canvas ( 'div1' )
@@ -14,19 +11,36 @@ window.onload = function (){
1411 var keyNum = Math . pow ( 2 , 32 ) - 1
1512 //每个点阵的度数
1613 var oneKeyDegree = 360 / keyNum
14+ var red = 'rgba(255,0,0,0.7)'
15+ var green = 'rgba(0,255,0,0.7)'
16+ var black = 'rgba(5,5,5,0.7)'
1717
1818 //clear canvas
1919 ctx . clearRect ( 0 , 0 , canvasObj . width , canvasObj . height )
20-
2120 //画外层大圆
2221 var x = canvasObj . width / 2
2322 var y = canvasObj . height / 2
2423 var r = canvasObj . width / 2.3
2524 ctx . beginPath ( )
2625 ctx . arc ( x , y , r , utils . hd ( 0 ) , utils . hd ( 360 ) )
27- ctx . closePath ( )
2826 ctx . stroke ( )
2927
28+ function addLogo ( ) {
29+ ctx . beginPath ( )
30+ ctx . fillStyle = red
31+ ctx . arc ( 30 , 30 , 20 , utils . hd ( 0 ) , utils . hd ( 360 ) )
32+ ctx . fill ( )
33+ ctx . fillStyle = black
34+ ctx . fillText ( '服务器' , 30 , 30 )
35+
36+ ctx . beginPath ( )
37+ ctx . fillStyle = green
38+ ctx . arc ( 30 , 70 , 10 , utils . hd ( 0 ) , utils . hd ( 360 ) )
39+ ctx . fill ( )
40+ ctx . fillStyle = black
41+ ctx . fillText ( 'key' , 30 , 70 )
42+ }
43+
3044 //添加文字
3145 function addText ( ) {
3246 ctx . save ( )
@@ -55,10 +69,10 @@ window.onload = function (){
5569
5670 if ( type == 1 ) {
5771 var radius = 8
58- var cycleColor = 'rgba(255,0,0,0.7)'
72+ var cycleColor = red
5973 } else if ( type == 2 ) {
6074 var radius = 4
61- var cycleColor = 'rgba(0,255,0,0.7)'
75+ var cycleColor = green
6276 }
6377
6478 ctx . beginPath ( )
@@ -75,12 +89,8 @@ window.onload = function (){
7589
7690 //添加文字
7791 addText ( )
78- //加载缓存
79-
80- localStorage . setItem ( "key" , "value" )
81- //alert(localStorage.getItem("key"))
82- //localStorage.removeItem("key")
83- //localStorage.clear()
92+ addLogo ( )
93+ //加载缓存 todo
8494
8595 function addServer ( ) {
8696 var val = document . getElementById ( 'serverval' ) . value
@@ -101,7 +111,6 @@ window.onload = function (){
101111
102112 document . getElementById ( 'addserver' ) . onclick = addServer
103113 document . getElementById ( 'addkey' ) . onclick = addKey
104-
105114}
106115
107116
0 commit comments