-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.html
196 lines (188 loc) · 5.79 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Welcome 2 cumsoftcumsoft</title>
<style>
#mydiv {
border-radius: 8px 8px 4px 4px;
width: 250px;
height: 250px;
z-index: 9;
position: absolute;
min-width: 200px;
min-height: 350px;
//background-color: transparent;
//resize: both;
//overflow: auto;
}
#mydivheader {
border-radius: 6px 6px 3px 3px;
border-color: #000;
border-style: solid;
border-width: 1px;
top: -619px;
left: 128px;
color: yellow;
width: calc(100% - 2px);
cursor: move;
height: 15px;
z-index: 10;
position: relative;
background-color: hotpink;
//resize: both;
// overflow: auto;
}
#content {
color:black;
border-radius: 0 0 6px 6px;
border-color: #000;
border-style: none solid solid solid;
border-width: 1px;
position: relative;
z-index: 11;
top: -619px;
left: 128px;
width: 250px;//calc(100% - 4px);
min-width: 250px;
max-width: 250px;
filter: blur(1px);
height: 350; //calc(100% - 2px);
min-height: 200px;
filter: drop-shadow(8px 14px 4px rgba(0, 0, 0, 0.4));
background-color: lightgray;
resize: both;
overflow: auto;
}</style>
<script src="index.js"></script>
<script src="https://aframe.io/releases/1.3.0/aframe.min.js"></script>
</head>
<body>
<canvas id="running-text" height=800px width=700px></canvas>
<script>
const word_color_pairs={
'cumsoft': '#ff844b',
'cumsoftgithub': '#82ff2e',
'cumsoft.wixsite.com': '#999999',
'Cumsoft': '#000000',
'cumsoftcumsoftcumsoft': '#ffffff',
'cumsoftcumsoft': '#f8008d',
'cumsoftcumsoft.github.io': '#ff30d3',
};
const getRandomKVPair=function(object)
{
const keys=Object.keys(object);
const rand_key=keys[Math.floor(Math.random()*keys.length)];
return {
'key': rand_key,
'value': object[rand_key],
};
};
const canvas=document.getElementById('running-text');
const canvas_context=canvas.getContext('2d');
let animation_id=undefined;
let word_x=0;
let word_y=10;
const stopRunning=function()
{
if(animation_id!==undefined)
window.clearInterval(animation_id);
animation_id=undefined;
};
const startRunning=function(word_color_pairs,canvas_background,interval)
{
const max_width=canvas.width;
const max_height=canvas.height;
//Blanket the canvas with the background.
canvas_context.fillStyle=canvas_background;
canvas_context.fillRect(0,0,max_width,max_height);
const run=function()
{
console.log('running');
if(word_y>max_height)
{
stopRunning();
return;
}
//Get info here.
const w_c_pair=getRandomKVPair(word_color_pairs);
//The actual width of the string measured in pixels according to the canvas.
const canvas_font_width=canvas_context.measureText(w_c_pair['key']+' ').width;
//The font color is set.
canvas_context.fillStyle=w_c_pair['value'];
//Render the random keyword.
canvas_context.fillText(w_c_pair['key']+' ',word_x,word_y);
//Update the rendering X-coordinate.
word_x+=canvas_font_width;
//If the X coordinate goes out of bounds, goto the beginning of the next line.
if(word_x>max_width)
{
word_x=1;
word_y+=10;
}
};
//Begin the animation.
animation_id=window.setInterval(run,interval);
};
startRunning(word_color_pairs,'#d9ead3',50);
</script>
<br><br><br>
<!-- Draggable DIV -->
<div id="mydiv">
<!-- Include a header DIV with the same name as the draggable DIV, followed by "header" -->
<div id="mydivheader"> <b>Menu le cumsoft</b></div>
<div id="content" style="height: 100px;">
<a-scene>
<a-box position="-1 0.5 -3" rotation="0 45 0" color="#4CC3D9"></a-box>
<a-sphere position="0 1.25 -5" radius="1.25" color="#EF2D5E"></a-sphere>
<a-cylinder position="1 0.75 -3" radius="0.5" height="1.5" color="#FFC65D"></a-cylinder>
<a-plane position="0 0 -4" rotation="-90 0 0" width="4" height="4" color="#7BC8A4"></a-plane>
<a-sky color="#ECECEC"></a-sky>
</a-scene>
</div>
</div>
<script>
// Make the DIV element draggable:
dragElement(document.getElementById("mydiv"));
function dragElement(elmnt) {
var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
if (document.getElementById(elmnt.id + "header")) {
// if present, the header is where you move the DIV from:
document.getElementById(elmnt.id + "header").onmousedown = dragMouseDown;
} else {
// otherwise, move the DIV from anywhere inside the DIV:
elmnt.onmousedown = dragMouseDown;
}
function dragMouseDown(e) {
e = e || window.event;
e.preventDefault();
// get the mouse cursor position at startup:
pos3 = e.clientX;
pos4 = e.clientY;
document.onmouseup = closeDragElement;
// call a function whenever the cursor moves:
document.onmousemove = elementDrag;
}
function elementDrag(e) {
e = e || window.event;
e.preventDefault();
// calculate the new cursor position:
pos1 = pos3 - e.clientX;
pos2 = pos4 - e.clientY;
pos3 = e.clientX;
pos4 = e.clientY;
// set the element's new position:
elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
}
function closeDragElement() {
// stop moving when mouse button is released:
document.onmouseup = null;
document.onmousemove = null;
}
}</script>
<br><br><br><br>
</body>
</html>