FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
processing/java/examples/Basics/Input/Easing/Easing.pde at master · Hmaal/processing · GitHub
Hmaal
processing
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
processing
/
java
/
examples
/
Basics
/
Input
/
Easing
/
Easing.pde
Copy path
More file actions
More file actions
Latest commit
History
History
History
37 lines (31 loc) · 731 Bytes
Breadcrumbs
processing
/
java
/
examples
/
Basics
/
Input
/
Easing
/
Easing.pde
Copy path
File metadata and controls
37 lines (31 loc) · 731 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
/**
* Easing.
*
* Move the mouse across the screen and the symbol will follow.
* Between drawing each frame of the animation, the program
* calculates the difference between the position of the
* symbol and the cursor. If the distance is larger than
* 1 pixel, the symbol moves part of the distance (0.05) from its
* current position toward the cursor.
*/
float
x;
float
y;
float
easing
=
0.05
;
void
setup
() {
size
(
640
,
360
);
noStroke
();
}
void
draw
() {
background
(
51
);
float
targetX
=
mouseX
;
float
dx
=
targetX
-
x;
if
(
abs
(dx)
>
1
) {
x
+=
dx
*
easing;
}
float
targetY
=
mouseY
;
float
dy
=
targetY
-
y;
if
(
abs
(dy)
>
1
) {
y
+=
dy
*
easing;
}
ellipse
(x, y,
66
,
66
);
}
Back
|
FazBrowse Home
|
New Git URL