Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
php
/
pingan-maruko
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
c4287214
authored
Jun 15, 2020
by
doszhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dos
parent
1f2f8095
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
10 deletions
+19
-10
Public/static/js/common.js
+19
-10
No files found.
Public/static/js/common.js
View file @
c4287214
...
...
@@ -99,32 +99,39 @@ function updateWorld() {
}
function
update
()
{
if
(
particles
.
length
<
5
00
&&
Math
.
random
()
<
probability
)
{
if
(
particles
.
length
<
2
00
&&
Math
.
random
()
<
probability
)
{
createFirework
();
}
var
alive
=
[];
for
(
var
i
=
0
;
i
<
particles
.
length
;
i
++
)
{
oldParticle
=
deepClone
(
particles
[
i
])
if
(
particles
[
i
].
move
())
{
alive
.
push
(
particles
[
i
]);
particles
[
i
].
children
.
push
(
oldParticle
)
if
(
particles
[
i
].
children
.
length
>
5
)
{
particles
[
i
].
children
.
splice
(
0
,
1
)
}
}
}
particles
=
alive
;
}
function
paint
()
{
// ctx.globalCompositeOperation = 'source-over';
// // ctx.fillStyle = "rgba(0,0,0,0.1)";
// ctx.fillRect(0, 0, w, h);
ctx
.
globalCompositeOperation
=
'lighter'
;
for
(
var
i
=
0
;
i
<
particles
.
length
;
i
++
)
{
particles
[
i
].
draw
(
ctx
);
for
(
k
in
particles
[
i
].
children
)
{
particles
[
i
].
children
[
k
].
w
-=
0.205
particles
[
i
].
children
[
k
].
draw
(
ctx
)
}
}
}
function
createFirework
()
{
xPoint
=
Math
.
random
()
*
(
w
-
200
)
+
100
;
yPoint
=
Math
.
random
()
*
(
h
-
5
00
)
+
100
;
yPoint
=
Math
.
random
()
*
(
h
-
2
00
)
+
100
;
var
nFire
=
Math
.
random
()
*
50
+
100
;
// var nFire = 1;
var
c
=
"rgb("
+
(
~~
(
Math
.
random
()
*
200
+
55
))
+
","
+
(
~~
(
Math
.
random
()
*
200
+
55
))
+
","
+
(
~~
(
Math
.
random
()
*
200
+
55
))
+
")"
;
for
(
var
i
=
0
;
i
<
nFire
;
i
++
)
{
...
...
@@ -139,7 +146,7 @@ function createFirework() {
}
function
Particle
()
{
this
.
w
=
this
.
h
=
Math
.
random
()
*
4
+
1
;
this
.
w
=
this
.
h
=
2
;
this
.
x
=
xPoint
-
this
.
w
/
2
;
this
.
y
=
yPoint
-
this
.
h
/
2
;
...
...
@@ -150,18 +157,20 @@ function Particle() {
this
.
alpha
=
Math
.
random
()
*
.
5
+
.
5
;
this
.
color
;
this
.
children
=
[];
}
Particle
.
prototype
=
{
gravity
:
0.0
1
,
gravity
:
0.0
5
,
move
:
function
()
{
this
.
x
+=
this
.
vx
;
this
.
vy
+=
this
.
gravity
;
this
.
y
+=
this
.
vy
;
this
.
alpha
-=
0.01
;
if
(
this
.
x
<=
-
this
.
w
||
this
.
x
>=
canvas
.
width
||
this
.
y
>=
canvas
.
height
||
if
(
this
.
x
<=
-
this
.
w
||
this
.
x
>=
screen
.
width
||
this
.
y
>=
screen
.
height
||
this
.
alpha
<=
0
)
{
this
.
alpha
=
0
return
false
;
}
return
true
;
...
...
@@ -169,7 +178,7 @@ Particle.prototype = {
draw
:
function
(
c
)
{
c
.
save
();
c
.
beginPath
();
this
.
w
=
this
.
w
>=
0
?
this
.
w
:
0.09
c
.
translate
(
this
.
x
+
this
.
w
/
2
,
this
.
y
+
this
.
h
/
2
);
c
.
arc
(
0
,
0
,
this
.
w
,
0
,
Math
.
PI
*
2
);
c
.
fillStyle
=
this
.
color
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment