mirror of
https://github.com/processing/processing4.git
synced 2026-02-14 10:55:38 +01:00
Re-adding Topics to SVN
This commit is contained in:
30
java/examples/Topics/File IO/LoadFile1/LoadFile1.pde
Normal file
30
java/examples/Topics/File IO/LoadFile1/LoadFile1.pde
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* LoadFile 1
|
||||
*
|
||||
* Loads a text file that contains two numbers separated by a tab ('\t').
|
||||
* A new pair of numbers is loaded each frame and used to draw a point on the screen.
|
||||
*/
|
||||
|
||||
String[] lines;
|
||||
int index = 0;
|
||||
|
||||
void setup() {
|
||||
size(200, 200);
|
||||
background(0);
|
||||
stroke(255);
|
||||
frameRate(12);
|
||||
lines = loadStrings("positions.txt");
|
||||
}
|
||||
|
||||
void draw() {
|
||||
if (index < lines.length) {
|
||||
String[] pieces = split(lines[index], '\t');
|
||||
if (pieces.length == 2) {
|
||||
int x = int(pieces[0]) * 2;
|
||||
int y = int(pieces[1]) * 2;
|
||||
point(x, y);
|
||||
}
|
||||
// Go to the next line for the next run through draw()
|
||||
index = index + 1;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user