forked from processing-js/processing-js.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
100 lines (88 loc) · 3.75 KB
/
Copy pathindex.html
File metadata and controls
100 lines (88 loc) · 3.75 KB
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
---
layout: default
---
<h3>Sequential</h3>
<p>by <a href="http://www.presstube.com">James Patterson</a>.
Displaying a sequence of images creates the illusion of motion.
Twelve images are loaded and each is displayed individually in a loop.</p>
<p><a href="http://processing.org/learning/topics/sequential.html"><b>Original Processing.org Example:</b> Sequential</a><br>
<div class="learning-demo"><script type="application/processing">
/* @pjs preload="data/PT_anim0000.gif, data/PT_anim0001.gif, data/PT_anim0002.gif,
data/PT_anim0003.gif, data/PT_anim0004.gif, data/PT_anim0005.gif,
data/PT_anim0006.gif, data/PT_anim0007.gif, data/PT_anim0008.gif,
data/PT_anim0009.gif, data/PT_anim0010.gif, data/PT_anim0011.gif"; */
int numFrames = 12; // The number of frames in the animation
int frame = 0;
PImage[] images = new PImage[numFrames];
void setup()
{
size(200, 200);
frameRate(30);
images[0] = loadImage("data/PT_anim0000.gif");
images[1] = loadImage("data/PT_anim0001.gif");
images[2] = loadImage("data/PT_anim0002.gif");
images[3] = loadImage("data/PT_anim0003.gif");
images[4] = loadImage("data/PT_anim0004.gif");
images[5] = loadImage("data/PT_anim0005.gif");
images[6] = loadImage("data/PT_anim0006.gif");
images[7] = loadImage("data/PT_anim0007.gif");
images[8] = loadImage("data/PT_anim0008.gif");
images[9] = loadImage("data/PT_anim0009.gif");
images[10] = loadImage("data/PT_anim0010.gif");
images[11] = loadImage("data/PT_anim0011.gif");
// If you don't want to load each image separately
// and you know how many frames you have, you
// can create the filenames as the program runs.
// The nf() command does number formatting, which will
// ensure that the number is (in this case) 4 digits.
//for(int i=0; i<numFrames; i++) {
// String imageName = "PT_anim" + nf(i, 4) + ".gif";
// images[i] = loadImage(imageName);
//}
}
void draw()
{
frame = (frame+1)%numFrames; // Use % to cycle through frames
image(images[frame], 0, 0);
}
</script><canvas width="200" height="200"></canvas></div></p>
<div class="code"><pre name="code" class="processing">// All Examples Written by Casey Reas and Ben Fry
// unless otherwise stated.
/* @pjs preload="data/PT_anim0000.gif, data/PT_anim0001.gif, data/PT_anim0002.gif,
data/PT_anim0003.gif, data/PT_anim0004.gif, data/PT_anim0005.gif,
data/PT_anim0006.gif, data/PT_anim0007.gif, data/PT_anim0008.gif,
data/PT_anim0009.gif, data/PT_anim0010.gif, data/PT_anim0011.gif"; */
int numFrames = 12; // The number of frames in the animation
int frame = 0;
PImage[] images = new PImage[numFrames];
void setup()
{
size(200, 200);
frameRate(30);
images[0] = loadImage("data/PT_anim0000.gif");
images[1] = loadImage("data/PT_anim0001.gif");
images[2] = loadImage("data/PT_anim0002.gif");
images[3] = loadImage("data/PT_anim0003.gif");
images[4] = loadImage("data/PT_anim0004.gif");
images[5] = loadImage("data/PT_anim0005.gif");
images[6] = loadImage("data/PT_anim0006.gif");
images[7] = loadImage("data/PT_anim0007.gif");
images[8] = loadImage("data/PT_anim0008.gif");
images[9] = loadImage("data/PT_anim0009.gif");
images[10] = loadImage("data/PT_anim0010.gif");
images[11] = loadImage("data/PT_anim0011.gif");
// If you don't want to load each image separately
// and you know how many frames you have, you
// can create the filenames as the program runs.
// The nf() command does number formatting, which will
// ensure that the number is (in this case) 4 digits.
//for(int i=0; i<numFrames; i++) {
// String imageName = "PT_anim" + nf(i, 4) + ".gif";
// images[i] = loadImage(imageName);
//}
}
void draw()
{
frame = (frame+1)%numFrames; // Use % to cycle through frames
image(images[frame], 0, 0);
}</pre></div>