-
Notifications
You must be signed in to change notification settings - Fork 1
/
testCanvas.html
executable file
·228 lines (215 loc) · 4.53 KB
/
testCanvas.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<html>
<head>
<script src="ThirdLibrary/jquery-1.7.2.min.js"></script>
<script src="Animation/Canvas.js"></script>
<script src="Animation/ShapeObject.js"></script>
<script src="Animation/AnimateArguments.js"></script>
<script src="Animation/Rectangle.js"></script>
<script src="Animation/Label.js"></script>
<script src="Animation/Line.js"></script>
<script type="text/javascript">
/*
this.arr = new Array();
this.arr.push(4);
this.arr = [];
alert(this.arr.length);
*/
function randomColor()
{
var rand = Math.floor(Math.random( ) * 0xFFFFFF).toString(16);
if(rand.length == 6)
{
return rand;
}
else
{
return randomColor();
}
}
function init()
{
var myCanvas = new KJcanvas();
var shape = new Array();
myCanvas.cmd("Setup");
for(var i=0;i<100;i++)
{
var x = Math.floor(Math.random()*800);
var y = Math.floor(Math.random()*500);
var aim_x = Math.floor(Math.random()*800);
var aim_y = Math.floor(Math.random()*500);
var width = Math.floor(Math.random()*100);
var height = Math.floor(Math.random()*100);
var backColor = randomColor();
var edgeColor = randomColor();
var end_x = Math.floor(Math.random()*800);
var end_y = Math.floor(Math.random()*500);
var moveSpeed = Math.floor(Math.random()*5)+1;
shape[i] = new Rectangle
({
Canvas : myCanvas,
x : x,
y : y,
aim_x : aim_x,
aim_y : aim_y,
width : width,
height : height,
backColor : backColor,
edgeColor : edgeColor,
end_x : end_x,
end_y : end_y,
moveSpeed : 1
});
}
alert("fd");
myCanvas.cmd("StartParallel");
for(var i=0;i<100;i++)
{
// myCanvas.cmd("Draw",shape[i]);
myCanvas.cmd("Move",shape[i]);
}
myCanvas.cmd("EndParallel");
myCanvas.cmd("End");
}
</script>
</head>
<body onload="init();">
<!--<body>-->
<h3 id="AlgorithmName"></h3>
<div id="AlgorithmControlBar"></div>
<canvas id="canvas" width="960" height="600" style="border:1px solid #000000;"></canvas>
<script type="text/javascript">
/* uio = function()
{
return "r43r";
}
qwe = function ()
{
return uio();
}
hj = qwe();
alert(hj);
/*
father = function()
{
this.y = "yyyy";
}
father.prototype.abc = function()
{
alert(this.x);
}
child = function()
{
this.x = "323";
}
child.prototype = new father;
child.prototype.abc = function()
{
alert(this.y);
this.y = "fhewjf";
alert(this.y);
}
var vv = new child;
var bb = new child;
bb.abc();
/*
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');
ctx.fillStyle = "f00";
ctx.fillRect(10,20,300,400); //画一个实体矩形
ctx.strokeStyle = "00f"
ctx.lineWidth = 1;
ctx.lineCap = 'round';
ctx.strokeRect(10,20,300,400); //勾画出矩形边框
ctx.fillStyle = "black";
ctx.textAlign = "center";
ctx.fillText("好好学习",10,20);
ctx.beginPath();
ctx.lineWidth = 10;
ctx.moveTo(10,10);
ctx.lineTo(50,10);
ctx.strokeStyle = "000";
ctx.stroke();
ctx.fillText("324234",400,400);
ctx.lineTo(100,25);
ctx.closePath();*/
/*
father = function()
{
this.info = "I am a good father";
}
child = function(cfg)
{
for(var x in cfg)
this[x] = cfg[x];
}
var simplefather = new father();
var c = new child({
age : 18,
father : simplefather
});
alert(c.father.info);
alert(c.age);
father = function()
{
}
father.prototype.tt = function()
{
}
var tmp = new father();
tmp.x = 123;
for(var ele in tmp)
{
alert(ele + typeof(ele));
}
var meme = tmp;
tmp.x = 456;
tmp = meme;
abc = new Array();
abc[hh]="123";
alert(abc[hh]);
*/
/* simple = function()
{
this.x = 123;
this.y = 456;
this.z = 789;
this.argument = new Array();
}
simple.prototype.test = function()
{
alert(this.x);
}
simple.prototype.saveArgument = function()
{
for(var ele in this)
if(ele != 'argument')
this.argument[ele] = this[ele];
}
simple.prototype.restoreArgument = function()
{
for(var ele in this)
if(ele != 'argument')
this[ele] = this.argument[ele];
}
var abc = new simple();
alert(abc.y); //显示456
abc.saveArgument();
abc.y = "xxxx";
alert(abc.y); //显示xxxx
abc.restoreArgument();
alert(abc.y); //显示456
*/
/*var x = "1243";
function change(y)
{
y.set(456);
}
change(
{
set : function(v){ x = v},
get : function(){return x}
});
alert(x);*/
</script>
</body>
</html>