新建测试代码
parent
97df82124b
commit
46bda38c1c
@ -0,0 +1,127 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=yes">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<title>测试</title>
|
||||||
|
</head>
|
||||||
|
<style>
|
||||||
|
</style>
|
||||||
|
<style>
|
||||||
|
.rotated {
|
||||||
|
transform: rotate(0deg);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<canvas class="rotated" id="stage" width="2000" height="2000"> </canvas>
|
||||||
|
<script>
|
||||||
|
var db1 = [];
|
||||||
|
var db2 = [];
|
||||||
|
var line = function (x, y, x1, y1, w, color) {
|
||||||
|
var c = document.getElementById("stage");
|
||||||
|
var ctx = c.getContext("2d");
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.lineWidth = w;
|
||||||
|
ctx.moveTo(x, y);
|
||||||
|
ctx.lineTo(x1, y1);
|
||||||
|
ctx.fillStyle = color;
|
||||||
|
ctx.strokeStyle = color;
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
var wtext = function (x, y, t, color) {
|
||||||
|
var c = document.getElementById("stage");
|
||||||
|
var ctx = c.getContext("2d");
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(x, y);
|
||||||
|
ctx.fillStyle = color; //设置填充颜色为紫色
|
||||||
|
ctx.font = '28px "黑体"'; //设置字体
|
||||||
|
ctx.textBaseline = "bottom"; //设置字体底线对齐绘制基线
|
||||||
|
ctx.textAlign = "left"; //设置字体对齐的方式
|
||||||
|
ctx.fillText(t, x, y);
|
||||||
|
}
|
||||||
|
function getTrueRandomNumber(min, max) {
|
||||||
|
var randomBytes = new Uint8Array(4);
|
||||||
|
if (window.crypto && window.crypto.getRandomValues) {
|
||||||
|
window.crypto.getRandomValues(randomBytes);
|
||||||
|
} else {
|
||||||
|
for (var i = 0; i < randomBytes.length; ++i) {
|
||||||
|
randomBytes[i] = Math.floor(Math.random() * 256);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var randomValue = ((randomBytes[0] << 24) | (randomBytes[1] << 16) | (randomBytes[2] << 8) | randomBytes[3]) / (Math.pow(2, 32));
|
||||||
|
return min + (max - min) * randomValue;
|
||||||
|
}
|
||||||
|
var get = function (x, y, x1, y1, l, w, k, levea) {
|
||||||
|
return {
|
||||||
|
x: x, y: y, x1: x1, y1: y1, l: l, w: w, k: k, levea: levea
|
||||||
|
};
|
||||||
|
}
|
||||||
|
var colors = ["#990000", "#EE0000", "#CC3399", "#CC33FF", "#CC00FF", "#FF00FF"];
|
||||||
|
//var colors = ["#CC33FF","#DD44FF","#EE55FF","#FF66FF","#CC0099","#CC33FF"];
|
||||||
|
//var colors = ["#CC6600", "#CCCC00", "#996600", "#FF9966", "#FF9900", "#CCFF66"];
|
||||||
|
// var colors = ["#FF3399", "#FF6666", "#CC3399", "#CC99CC", "#CCCCCC", "#FFCCFF"];
|
||||||
|
var play = function (is, dbs) {
|
||||||
|
var obj = dbs.shift();
|
||||||
|
if (obj != null && (obj.l >= 21 || obj.levea != 0) && obj.levea < 7) {
|
||||||
|
var x = obj.x, y = obj.y, x1 = obj.x1, y1 = obj.y1, w = obj.w, color = obj.color, l = obj.l, k = obj.k, levea = obj.levea;
|
||||||
|
line(x, y, x1, y1, w, colors[obj.levea]);
|
||||||
|
l *= 0.890;
|
||||||
|
k -= 0.256;
|
||||||
|
w *= 0.818;
|
||||||
|
if (dbs.length < 100000) {
|
||||||
|
x = x1;
|
||||||
|
y = y1;
|
||||||
|
if (is) {
|
||||||
|
x1 = x - Math.cos(k) * l;
|
||||||
|
} else {
|
||||||
|
x1 = x + Math.cos(k) * l;
|
||||||
|
}
|
||||||
|
y1 = y + Math.sin(k) * l;
|
||||||
|
if (levea == 0) {
|
||||||
|
dbs.push(get(x, y, x1, y1, l, w, k, levea));
|
||||||
|
for (i = 0; i < 3; i++) {
|
||||||
|
rand = getTrueRandomNumber(-180, 180);
|
||||||
|
var len = 10 + l * 0.5;
|
||||||
|
x1 = x + Math.cos(k + rand) * len;
|
||||||
|
y1 = y - Math.sin(k + rand) * len;
|
||||||
|
l *= 0.618; w = 0.618 * w + 0.038;
|
||||||
|
dbs.push(get(x, y, x1, y1, len, w, k + rand, levea + 1));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
l *= 0.618; w = 0.618 * w + 0.038;
|
||||||
|
for (i = 0; i < 4; i++) {
|
||||||
|
rand = getTrueRandomNumber(-180, 180);
|
||||||
|
x1 = x + Math.cos(k + rand) * l;
|
||||||
|
y1 = y - Math.sin(k + rand) * l;
|
||||||
|
dbs.push(get(x, y, x1, y1, l, w, k + rand, levea + 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
db1.push(get(1000, 1000, 1000, 1000, 180, 10, 270, 0));
|
||||||
|
db2.push(get(1000, 1000, 1000, 1000, 180, 10, 270, 0));
|
||||||
|
var peed = 1800;
|
||||||
|
var ti = 0;
|
||||||
|
var test = " 冥冥之中注定要遇见你,看那纷纷落落灯火辉煌,是我对你的迷离痴心,只有一生一世歇斯底里。 在那韶华流芳,我为你梳妆可好,琴弦拨心弦扣动深情,劲风鼓动翻滚沁浪白。皎洁月光洒满在断桥,映入眼帘是我的热泪。";
|
||||||
|
var wx = 0, wy = 0;
|
||||||
|
setInterval(function () {
|
||||||
|
if (ti < test.length) wtext(690 + wy * 30, 450 + wx * 30, test[ti], colors[ti % colors.length]);
|
||||||
|
if (wy % (20 - wx) == 0) {
|
||||||
|
wy = wx;
|
||||||
|
wx += 1
|
||||||
|
}
|
||||||
|
wy += 1;
|
||||||
|
ti += 1;
|
||||||
|
for (e = 0; e < peed; e++) {
|
||||||
|
play(false, db1);
|
||||||
|
play(true, db2);
|
||||||
|
}
|
||||||
|
}, 200)
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
@ -0,0 +1,127 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=yes">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
|
<title>测试</title>
|
||||||
|
</head>
|
||||||
|
<style>
|
||||||
|
</style>
|
||||||
|
<style>
|
||||||
|
.rotated {
|
||||||
|
transform: rotate(0deg);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<canvas class="rotated" id="stage" width="2000" height="2000"> </canvas>
|
||||||
|
<script>
|
||||||
|
var db1 = [];
|
||||||
|
var db2 = [];
|
||||||
|
var line = function (x, y, x1, y1, w, color) {
|
||||||
|
var c = document.getElementById("stage");
|
||||||
|
var ctx = c.getContext("2d");
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.lineWidth = w;
|
||||||
|
ctx.moveTo(x, y);
|
||||||
|
ctx.lineTo(x1, y1);
|
||||||
|
ctx.fillStyle = color;
|
||||||
|
ctx.strokeStyle = color;
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
var wtext = function (x, y, t, color) {
|
||||||
|
var c = document.getElementById("stage");
|
||||||
|
var ctx = c.getContext("2d");
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(x, y);
|
||||||
|
ctx.fillStyle = color; //设置填充颜色为紫色
|
||||||
|
ctx.font = '28px "黑体"'; //设置字体
|
||||||
|
ctx.textBaseline = "bottom"; //设置字体底线对齐绘制基线
|
||||||
|
ctx.textAlign = "left"; //设置字体对齐的方式
|
||||||
|
ctx.fillText(t, x, y);
|
||||||
|
}
|
||||||
|
function getTrueRandomNumber(min, max) {
|
||||||
|
var randomBytes = new Uint8Array(4);
|
||||||
|
if (window.crypto && window.crypto.getRandomValues) {
|
||||||
|
window.crypto.getRandomValues(randomBytes);
|
||||||
|
} else {
|
||||||
|
for (var i = 0; i < randomBytes.length; ++i) {
|
||||||
|
randomBytes[i] = Math.floor(Math.random() * 256);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var randomValue = ((randomBytes[0] << 24) | (randomBytes[1] << 16) | (randomBytes[2] << 8) | randomBytes[3]) / (Math.pow(2, 32));
|
||||||
|
return min + (max - min) * randomValue;
|
||||||
|
}
|
||||||
|
var get = function (x, y, x1, y1, l, w, k, levea) {
|
||||||
|
return {
|
||||||
|
x: x, y: y, x1: x1, y1: y1, l: l, w: w, k: k, levea: levea
|
||||||
|
};
|
||||||
|
}
|
||||||
|
var colors = ["#990000", "#EE0000", "#CC3399", "#CC33FF", "#CC00FF", "#FF00FF"];
|
||||||
|
//var colors = ["#CC33FF","#DD44FF","#EE55FF","#FF66FF","#CC0099","#CC33FF"];
|
||||||
|
//var colors = ["#CC6600", "#CCCC00", "#996600", "#FF9966", "#FF9900", "#CCFF66"];
|
||||||
|
// var colors = ["#FF3399", "#FF6666", "#CC3399", "#CC99CC", "#CCCCCC", "#FFCCFF"];
|
||||||
|
var play = function (is, dbs) {
|
||||||
|
var obj = dbs.shift();
|
||||||
|
if (obj != null && (obj.l >= 21 || obj.levea != 0) && obj.levea < 7) {
|
||||||
|
var x = obj.x, y = obj.y, x1 = obj.x1, y1 = obj.y1, w = obj.w, color = obj.color, l = obj.l, k = obj.k, levea = obj.levea;
|
||||||
|
line(x, y, x1, y1, w, colors[obj.levea]);
|
||||||
|
l *= 0.890;
|
||||||
|
k -= 0.256;
|
||||||
|
w *= 0.818;
|
||||||
|
if (dbs.length < 100000) {
|
||||||
|
x = x1;
|
||||||
|
y = y1;
|
||||||
|
if (is) {
|
||||||
|
x1 = x - Math.cos(k) * l;
|
||||||
|
} else {
|
||||||
|
x1 = x + Math.cos(k) * l;
|
||||||
|
}
|
||||||
|
y1 = y + Math.sin(k) * l;
|
||||||
|
if (levea == 0) {
|
||||||
|
dbs.push(get(x, y, x1, y1, l, w, k, levea));
|
||||||
|
for (i = 0; i < 3; i++) {
|
||||||
|
rand = getTrueRandomNumber(-180, 180);
|
||||||
|
var len = 10 + l * 0.5;
|
||||||
|
x1 = x + Math.cos(k + rand) * len;
|
||||||
|
y1 = y - Math.sin(k + rand) * len;
|
||||||
|
l *= 0.618; w = 0.618 * w + 0.038;
|
||||||
|
dbs.push(get(x, y, x1, y1, len, w, k + rand, levea + 1));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
l *= 0.618; w = 0.618 * w + 0.038;
|
||||||
|
for (i = 0; i < 4; i++) {
|
||||||
|
rand = getTrueRandomNumber(-180, 180);
|
||||||
|
x1 = x + Math.cos(k + rand) * l;
|
||||||
|
y1 = y - Math.sin(k + rand) * l;
|
||||||
|
dbs.push(get(x, y, x1, y1, l, w, k + rand, levea + 1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
db1.push(get(1000, 1000, 1000, 1000, 180, 10, 270, 0));
|
||||||
|
db2.push(get(1000, 1000, 1000, 1000, 180, 10, 270, 0));
|
||||||
|
var peed = 1800;
|
||||||
|
var ti = 0;
|
||||||
|
var test = " 冥冥之中注定要遇见你,看那纷纷落落灯火辉煌,是我对你的迷离痴心,只有一生一世歇斯底里。 在那韶华流芳,我为你梳妆可好,琴弦拨心弦扣动深情,劲风鼓动翻滚沁浪白。皎洁月光洒满在断桥,映入眼帘是我的热泪。";
|
||||||
|
var wx = 0, wy = 0;
|
||||||
|
setInterval(function () {
|
||||||
|
if (ti < test.length) wtext(690 + wy * 30, 450 + wx * 30, test[ti], colors[ti % colors.length]);
|
||||||
|
if (wy % (20 - wx) == 0) {
|
||||||
|
wy = wx;
|
||||||
|
wx += 1
|
||||||
|
}
|
||||||
|
wy += 1;
|
||||||
|
ti += 1;
|
||||||
|
for (e = 0; e < peed; e++) {
|
||||||
|
play(false, db1);
|
||||||
|
play(true, db2);
|
||||||
|
}
|
||||||
|
}, 200)
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
Loading…
Reference in New Issue