How to call a PVector from an ArrayList and use the coordinates to plot a point?
in
Programming Questions
•
7 months ago
I'm pretty new to programming and I feel like there's something obvious that I'm missing. I have an ArrayList filled with PVectors, and I'd like to use use those coordinates to draw a point for each PVector. How do I translate the coordinates stored in the PVectors to the parameters of a point? Or in other words, how do I display my ArrayList of PVectors as a series of points?
Here's my code:
Any help is greatly appreciated~
Here's my code:
- PVector myPos;
ArrayList myPoints = new ArrayList();
void setup() {
size(300, 300,P3D);
background(255);
byte b[] = loadBytes("portcus.txt");
// Print each value, from 0 to 255
for (int i = 0; i < b.length; i++) {
// Every tenth number, start a new line
if ((i % 10) == 0) {
println();
}
if ((i % 2) == 0) {
// bytes are from -128 to 127, this converts to 0 to 255
int x_ = b[i] & 0xff;
int y_ = b[i+1] & 0xff;
myPos = new PVector(x_, y_);
myPoints.add(myPos);
println(myPos.x + ", " + myPos.y);
}
}
// Print a blank line at the end
println();
}
void draw(){
for(int i = 0; i< myPoints.size(); i++){
//println(myPoints.get(i));
//this for loop is where I was intending to draw the points
}
}
Any help is greatly appreciated~
1