FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
processing/java/examples/Basics/Arrays/Array/Array.pde at master · kaiquewdev/processing · GitHub
kaiquewdev
processing
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
processing
/
java
/
examples
/
Basics
/
Arrays
/
Array
/
Array.pde
Copy path
More file actions
More file actions
Latest commit
History
History
History
51 lines (42 loc) · 1.06 KB
Breadcrumbs
processing
/
java
/
examples
/
Basics
/
Arrays
/
Array
/
Array.pde
Copy path
File metadata and controls
51 lines (42 loc) · 1.06 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* Array.
*
* An array is a list of data. Each piece of data in an array
* is identified by an index number representing its position in
* the array. Arrays are zero based, which means that the first
* element in the array is [0], the second element is [1], and so on.
* In this example, an array named "coswav" is created and
* filled with the cosine values. This data is displayed three
* separate ways on the screen.
*/
float
[] coswave;
void
setup
() {
size
(
640
,
360
);
coswave
=
new
float
[
width
];
for
(
int
i
=
0
; i
<
width
; i
++
) {
float
amount
=
map
(i,
0
,
width
,
0
,
PI
);
coswave[i]
=
abs
(
cos
(amount));
}
background
(
255
);
noLoop
();
}
void
draw
() {
int
y1
=
0
;
int
y2
=
height
/
3
;
for
(
int
i
=
0
; i
<
width
; i
+=
2
) {
stroke
(coswave[i]
*
255
);
line
(i, y1, i, y2);
}
y1
=
y2;
y2
=
y1
+
y1;
for
(
int
i
=
0
; i
<
width
; i
+=
2
) {
stroke
(coswave[i]
*
255
/
4
);
line
(i, y1, i, y2);
}
y1
=
y2;
y2
=
height
;
for
(
int
i
=
0
; i
<
width
; i
+=
2
) {
stroke
(
255
-
coswave[i]
*
255
);
line
(i, y1, i, y2);
}
}
Back
|
FazBrowse Home
|
New Git URL