Recommendation
More Effects...
JS
1
function $i(t) {
2
    return document.getElementById(t)
3
}
4
function $r(t, r) {
5
    document.getElementById(t).removeChild(document.getElementById(r))
6
}
7
function $t(t) {
8
    return document.getElementsByTagName(t)
9
}
10
function $c(t) {
11
    return String.fromCharCode(t)
12
}
13
function $h(t) {
14
    return ("0" + Math.max(0, Math.min(255, Math.round(t))).toString(16)).slice(-2)
15
}
16
function _i(t, r) {
17
    $t("div")[t].innerHTML += r
18
}
19
function _h(t) {
20
    return hires ? Math.round(t / 2) : t
21
}
22
function get_screen_size() {
23
    var t = document.documentElement.clientWidth,
24
        r = document.documentElement.clientHeight;
25
    return Array(t, r)
26
}
27
function init() {
28
    for (var t = 0; n > t; t++) star[t] = new Array(5), star[t][0] = Math.random() * w * 2 - 2 * x, star[t][1] = Math.random() * h * 2 - 2 * y, star[t][2] = Math.round(Math.random() * z), star[t][3] = 0, star[t][4] = 0;
29
    var r = $i("starfield");
30
    r.style.position = "absolute", r.width = w, r.height = h, context = r.getContext("2d"), context.fillStyle = "rgb(0,0,0)", context.strokeStyle = "rgb(255,255,255)"
31
}
32
function anim() {
33
    mouse_x = cursor_x - x, mouse_y = cursor_y - y, context.fillRect(0, 0, w, h);
34
    for (var t = 0; n > t; t++) test = !0, star_x_save = star[t][3], star_y_save = star[t][4], star[t][0] += mouse_x >> 4, star[t][0] > x << 1 && (star[t][0] -= w << 1, test = !1), star[t][0] < -x << 1 && (star[t][0] += w << 1, test = !1), star[t][1] += mouse_y >> 4, star[t][1] > y << 1 && (star[t][1] -= h << 1, test = !1), star[t][1] < -y << 1 && (star[t][1] += h << 1, test = !1), star[t][2] -= star_speed, star[t][2] > z && (star[t][2] -= z, test = !1), star[t][2] < 0 && (star[t][2] += z, test = !1), star[t][3] = x + star[t][0] / star[t][2] * star_ratio, star[t][4] = y + star[t][1] / star[t][2] * star_ratio, star_x_save > 0 && w > star_x_save && star_y_save > 0 && h > star_y_save && test && (context.lineWidth = 2 * (1 - star_color_ratio * star[t][2]), context.beginPath(), context.moveTo(star_x_save, star_y_save), context.lineTo(star[t][3], star[t][4]), context.stroke(), context.closePath());
35
    timeout = setTimeout("anim()", fps)
36
}
37
function start() {
38
    resize(), anim()
39
}
40
function resize() {
41
    w = parseInt(-1 != url.indexOf("w=") ? url.substring(url.indexOf("w=") + 2, -1 != url.substring(url.indexOf("w=") + 2, url.length).indexOf("&") ? url.indexOf("w=") + 2 + url.substring(url.indexOf("w=") + 2, url.length).indexOf("&") : url.length) : get_screen_size()[0]), h = parseInt(-1 != url.indexOf("h=") ? url.substring(url.indexOf("h=") + 2, -1 != url.substring(url.indexOf("h=") + 2, url.length).indexOf("&") ? url.indexOf("h=") + 2 + url.substring(url.indexOf("h=") + 2, url.length).indexOf("&") : url.length) : get_screen_size()[1]), x = Math.round(w / 2), y = Math.round(h / 2), z = (w + h) / 2, star_color_ratio = 1 / z, cursor_x = x, cursor_y = y, init()
42
}
43
var url = document.location.href,
44
    flag = !0,
45
    test = !0,
46
    n = parseInt(-1 != url.indexOf("n=") ? url.substring(url.indexOf("n=") + 2, -1 != url.substring(url.indexOf("n=") + 2, url.length).indexOf("&") ? url.indexOf("n=") + 2 + url.substring(url.indexOf("n=") + 2, url.length).indexOf("&") : url.length) : 812),
47
    w = 0,
48
    h = 0,
49
    x = 0,
50
    y = 0,
51
    z = 0,
52
    star_color_ratio = 0,
53
    star_x_save, star_y_save, star_ratio = 115,
54
    star_speed = 5,
55
    star_speed_save = 0,
56
    star = new Array(n),
57
    color, opacity = .1,
58
    cursor_x = 0,
59
    cursor_y = 0,
60
    mouse_x = 0,
61
    mouse_y = 0,
62
    canvas_x = 0,
63
    canvas_y = 0,
64
    canvas_w = 0,
65
    canvas_h = 0,
66
    context, key, ctrl, timeout, fps = 0;
67
start();
68
 
 
CSS
1
* {
2
  background:black;
3
  padding:0;
4
  margin:0;
5
}
6
 
7
canvas {
8
  padding:0;
9
  margin:0;
10
  width:100%;
11
  height:100%;
12
}
 
HTML
1
<canvas id="starfield"></canvas>
 

Join Effecthub.com

Working with Global Gaming Artists and Developers!


Or Sign Up with Your Email Address:
This field must contain a valid email
Password should be at least 1 character