Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
h5
/
glsk-data-view-scene
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 0e77af3e
authored
Jul 11, 2024
by
李伟康
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
commit 修改
1 parent
4ee5646a
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
158 additions
and
2 deletions
src/views/energyCar/CharacterRain.vue
src/views/energyCar/index.vue
src/views/energyCar/CharacterRain.vue
0 → 100644
View file @
0e77af3
<
template
>
<div
class=
"main"
ref=
"main"
>
</div>
</
template
>
<
script
type=
'text/ecmascript-6'
>
export
default
{
name
:
''
,
data
()
{
return
{
}
},
mounted
()
{
function
r
(
from
,
to
)
{
return
~~
(
Math
.
random
()
*
(
to
-
from
+
1
)
+
from
);
}
function
getChar
()
{
return
r
(
0
,
1
)
}
function
loop
(
fn
,
delay
)
{
let
stamp
=
Date
.
now
();
function
_loop
()
{
if
(
Date
.
now
()
-
stamp
>=
delay
)
{
fn
();
stamp
=
Date
.
now
();
}
requestAnimationFrame
(
_loop
);
}
requestAnimationFrame
(
_loop
);
}
class
Char
{
constructor
()
{
this
.
element
=
document
.
createElement
(
'span'
);
this
.
element
.
className
=
'character'
this
.
mutate
();
}
mutate
()
{
this
.
element
.
textContent
=
getChar
();
}
}
class
Trail
{
constructor
(
list
=
[],
options
)
{
this
.
list
=
list
;
this
.
options
=
Object
.
assign
(
{
size
:
10
,
offset
:
0
},
options
);
this
.
body
=
[];
this
.
move
();
}
traverse
(
fn
)
{
this
.
body
.
forEach
((
n
,
i
)
=>
{
let
last
=
(
i
==
this
.
body
.
length
-
1
);
if
(
n
)
fn
(
n
,
i
,
last
);
});
}
move
()
{
this
.
body
=
[];
let
{
offset
,
size
}
=
this
.
options
;
for
(
let
i
=
0
;
i
<
size
;
++
i
)
{
let
item
=
this
.
list
[
offset
+
i
-
size
+
1
];
this
.
body
.
push
(
item
);
}
this
.
options
.
offset
=
(
offset
+
1
)
%
(
this
.
list
.
length
+
size
-
1
);
}
}
class
Rain
{
constructor
({
target
,
row
})
{
this
.
element
=
document
.
createElement
(
'p'
);
this
.
element
.
className
=
'rain-item'
this
.
build
(
row
);
if
(
target
)
{
target
.
appendChild
(
this
.
element
);
}
this
.
drop
();
}
build
(
row
=
20
)
{
let
root
=
document
.
createDocumentFragment
();
let
chars
=
[];
for
(
let
i
=
0
;
i
<
row
;
++
i
)
{
let
c
=
new
Char
();
root
.
appendChild
(
c
.
element
);
chars
.
push
(
c
);
if
(
Math
.
random
()
<
.
5
)
{
loop
(()
=>
c
.
mutate
(),
r
(
1
e3
,
5
e3
));
}
}
this
.
trail
=
new
Trail
(
chars
,
{
size
:
r
(
10
,
30
),
offset
:
r
(
0
,
100
)
});
this
.
element
.
appendChild
(
root
);
}
drop
()
{
let
trail
=
this
.
trail
;
let
len
=
trail
.
body
.
length
;
let
delay
=
r
(
10
,
100
);
loop
(()
=>
{
trail
.
move
();
trail
.
traverse
((
c
,
i
,
last
)
=>
{
c
.
element
.
style
=
`
color: hsl(182, 92%,
${
85
/
len
*
(
i
+
1
)}
%)
`
;
if
(
last
)
{
c
.
mutate
();
c
.
element
.
style
=
`
color: hsl(182, 92%, 85%);
text-shadow:
0 0 .5em #fff,
0 0 .5em currentColor;
`
;
}
});
},
delay
);
}
}
const
main
=
this
.
$refs
.
main
for
(
let
i
=
0
;
i
<
20
;
++
i
)
{
new
Rain
({
target
:
main
,
row
:
20
});
}
},
methods
:
{
}
}
</
script
>
<
style
scoped
lang=
'scss'
>
.main
{
width
:
100vw
;
height
:
100vh
;
position
:
fixed
;
top
:
0
;
left
:
0
;
display
:
flex
;
transform
:
rotate
(
180deg
);
animation
:
show-rain
1s
3s
forwards
;
opacity
:
0
;
/deep/.rain-item
{
line-height
:
1
;
}
/
deep
/
.character
{
display
:
block
;
width
:
6vmax
;
height
:
2vmax
;
font-size
:
1vmax
;
color
:
#6df5f9
;
text-align
:
center
;
transform
:
rotate
(
180deg
);
}
}
@keyframes
show-rain
{
100
%
{
opacity
:
.5
;
}
}
</
style
>
\ No newline at end of file
\ No newline at end of file
src/views/energyCar/index.vue
View file @
0e77af3
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
<left-model
/>
<left-model
/>
<center-model
/>
<center-model
/>
<right-model
/>
<right-model
/>
<character-rain
/>
</div>
</div>
</
template
>
</
template
>
...
@@ -17,13 +18,14 @@
...
@@ -17,13 +18,14 @@
import
LeftModel
from
'./LeftModel'
import
LeftModel
from
'./LeftModel'
import
CenterModel
from
'./CenterModel.vue'
import
CenterModel
from
'./CenterModel.vue'
import
RightModel
from
'./RightModel'
import
RightModel
from
'./RightModel'
import
CharacterRain
from
'./CharacterRain.vue'
export
default
{
export
default
{
name
:
'EnergyCar'
,
name
:
'EnergyCar'
,
components
:
{
components
:
{
LeftModel
,
LeftModel
,
CenterModel
,
CenterModel
,
RightModel
RightModel
,
CharacterRain
},
},
data
()
{
data
()
{
return
{}
return
{}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment