Not a problem use str()
give me hint how to use str()
look what i want this array contains few elements i text all of them but if the more than screen width they out of boarder i want to text the elements as the are in the array
void setup () {
size ( 800 , 800 );
}
void draw () {
fill(0);
int[] x = {
50, 61, 83, 69, 71, 50,
};
fill(0);
for (int i = 0; i < x.length; i++) {
textSize(20);
text(x[i],i*44,55);
}
}
didnt understand much of that. Can you clarify please.
what are you trying to achieve your code already displays the values in the array.
if(i*44<width)text(x[i],i*44,55);
this will limit the displayed number to only those that fit in the window, note the array values are still being iterated though.
what i need incited of printing array elements on consuls
this is just 6 elements texting them no issue but what if the array contains lets say 200 elements how to text them
void setup () {
size ( 800 , 800 );
}
void draw () {
fill(0);
int[][] x = {
{50, 61, 83, 69, 71, 50, 29, 31, 17, 39},
{50, 61, 83, 69, 71, 50, 29, 31, 17, 39},
{50, 61, 83, 69, 71, 50, 29, 31, 17, 39},
{50, 61, 83, 69, 71, 50, 29, 31, 17, 39},
{50, 61, 83, 69, 71, 50, 29, 31, 17, 39},
{50, 61, 83, 69, 71, 50, 29, 31, 17, 39},
{50, 61, 83, 69, 71, 50, 29, 31, 17, 39},
{676, 61, 83, 69, 71, 50, 29, 31, 17, 39}
};
fill(0);
for (int i = 0; i < x.length; i++) {
for (int j = 0; j < x[0].length; j++) {
textSize(20);
text(x[i][j],50*j,i*20);
}
}}
void setup () {
size ( 800 , 800 );
}
void draw () {
fill(0);
int[] x = {
50, 61, 83, 69, 71, 50, 29, 31, 17, 39,
50, 61, 83, 69, 71, 50, 29, 31, 17, 39,
50, 61, 83, 69, 71, 50, 29, 31, 17, 39,
50, 61, 83, 69, 71, 50, 29, 31, 17, 39,
50, 61, 83, 69, 71, 50, 29, 31, 17, 39,
50, 61, 83, 69, 71, 50, 29, 31, 17, 39,
50, 61, 83, 69, 71, 50, 29, 31, 17, 39,
676, 61, 83, 69, 71, 50, 29, 31, 17, 39
};
fill(0);
int row = 0;
float spacing = 25;
float xx = 0;
for (int i = 0; i < x.length; i++) {
xx += spacing;
textSize(20);
if(xx>width){
xx = 0;
row++;
}
println(row);
text(x[i],xx,50+row*20);
}
}
thanks a a lot that is what i want but i do have other question but let my prepare how to ask it thanks again for the second way
@paulgoux
thanks for you the code is part of timing measurement like this but may i ask some other thing when i apply my all stuff
Sure what do you need?
i am not sure yet did not fished and i am not stuck for now
Your iterating through a double array so you need the length of the internal array.
The code however is assuming that all internal arrays are the same size, else use x[i].length
Using @paulgoux suggestion for using String, I wonder if this too is of use to your question. Then you don’t need to use the array and for loop…
//////////////////////////////////////////////
void setup () {
size (800, 800);
}
void draw () {
fill(0);
String strg1 = "50, 61, 83, 69, 71, 50, 29, 31, 17, 39, 50, 61, 83, 69, 71, 50, 29, 31, 17, 39, 50, 61, 83, 69, 71, 50, 29, 31, 17, 39, 50, 61, 83, 69, 71, 50, 29, 31, 17, 39"; // I did not include all of your numbers, this is just a text to see if solves the question
textSize(20);
text(strg1, 20, 40, 750, 750);
}
this might be interesting Data \ Processing.org
it shows how to load and display Tabular Data