-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
103 lines (90 loc) · 2.8 KB
/
main.js
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
var paper = Raphael(0, 0, "100%", "100%");
var i = 100,
triangleSize1 = 400,
triangleSize2 = 100,
xOffset = -100,
yOffset = -90,
vertices = new Array(i),
x,
y,
w = window,
d = document,
e = d.documentElement,
g = d.getElementsByTagName('body')[0],
wx = w.innerWidth || e.clientWidth || g.clientWidth,
wy = w.innerHeight|| e.clientHeight|| g.clientHeight;
//middle middle
vertices[0] = {x: wx/2 + xOffset, y: wy/2 + yOffset, type: "mm"};
//middle right
vertices[1] = {x: wx/2 + xOffset + triangleSize1, y: wy/2 + yOffset, type: "mr"};
//bottom
vertices[2] = {
x: wx/2 + xOffset + triangleSize1/2,
y: wy/2 + Math.sqrt(Math.pow(triangleSize1,2) - Math.pow(triangleSize1/2,2)) + yOffset,
type: "b"};
//middle left
vertices[3] = {
x: wx/2 + xOffset - triangleSize2,
y: wy/2 + yOffset,
type: "ml"};
//top
vertices[4] = {
x: wx/2 + xOffset - triangleSize2/2,
y: wy/2 - Math.sqrt(Math.pow(triangleSize2, 2) - Math.pow(triangleSize2/2, 2)) + yOffset,
type: "t"
};
var ty1 = triangleSize1/2 * Math.tan(Math.PI/6) + wy/2 + yOffset;
var tx1 = triangleSize1/2 + wx/2 + xOffset;
var r1 = triangleSize1/(2 * Math.cos(Math.PI/6));
var ty2 = -triangleSize2 * Math.tan(Math.PI/6)/2 + wy/2 + yOffset;
var tx2 = -triangleSize2/2 + wx/2 + xOffset;
var r2 = triangleSize2/(2 * Math.cos(Math.PI/6));
//paper.circle(tx1, ty1, r1);
//paper.circle(tx2, ty2, r2);
var distance1, distance2;
while(i > 5) {
do{
x = Math.random() - 0.03;
y = Math.random() - 0.03;
x = x * (wx + 60);
y = y * (wy + 60);
distance1 = Math.sqrt(Math.pow(tx1 - x, 2) + Math.pow(ty1 - y, 2));
distance2 = Math.sqrt(Math.pow(tx2 - x, 2) + Math.pow(ty2 - y, 2));
}while(distance1 < r1 || distance2 < r2);
vertices[--i] = {x: x, y: y};
}
//console.time("triangulate");
var triangles = triangulate(vertices);
//console.timeEnd("triangulate");
i = triangles.length;
while(i)
triangles[--i].drawRaleaph(paper);
/* jquery plugin */
$.fn.teletype = function(opts){
var $this = this,
defaults = {
animDelay: 50
},
settings = $.extend(defaults, opts);
$.each(settings.text.split(''), function(i, letter){
setTimeout(function(){
$this.html($this.html() + letter);
}, settings.animDelay * i);
});
};
$(document).ready(function(){
$("#twentyThree").css("top", ty2 - 20 + "px");
$("#twentyThree").css("left", tx2 - 20 + "px");
$("#ideas").css("top", ty1 - 80 + "px");
$("#ideas").css("left", tx1 - 110 + "px");
$("#info").teletype({
animDelay: 100, // the bigger the number the slower the typing
text: 'And More...'
});
$("#info").on('click', function(e){
$("#overLay").css("top", "0px");
});
$("#overLay").on('click', function(e){
$("#overLay").css("top", '');
})
});