Strange behavoure with text(..)

edited April 2017 in Questions about Code


i'm new here, but i cannot find the answer about my question.

I've writen a program with some text-entries. The coordinates of the text are calculated by a for-loop

for (i=0;i<14;i++){
     text(StrStart+" t/m "+StrStop+" u",(i*85)+10,215+yTranspose);
     WeatherPicture = loadImage("http://" + "" + code[i] + ".png");
     text("vocht: "+vochtigheid[i]+"%",(i*85)+10,270+yTranspose);


The first time the program runs, everything is at the right place, but after a minute, the program gets an update from and prints the info again.

The info is now placed to the left.. Everything is out of order...

1st picture is the right alignment, second picture is after 1 minute....

I hope you can give me some answer what to do.



  • edited April 2017

    @dreezy --

    The bug is probably fully apparent in your complete code.

    You might be incrementing a translate variable such as xTranspose incorrectly -- or using translate() without pushMatrix()/popMatrix() -- or translating within a PShape, where such things are retained rather than reset. This could be happening inside separate PGraphics or at the main canvas level. You could also be adding an offset to (almost) 0 in a way that you would assume is equivalent to 0 but that is constantly accumulating floating point error. Does the text slowly drift, or does it suddenly shift after exactly 1 minute?

    I notice that your upper example has black lines and borders, but in your lower example they have disappeared.

  • Hi,

    Thanx for the reaction.

    This 1 minuten is a timer who refeshed the info from

    It had borging to do without the yTranspose. It drifts verticale. The x-axis

  • You should load the image inside setup and not where you do it now! It's always the same image so it costs processer time

    For your problem: do you use textAlign center? That could be causing it

  • The loadimage i've placed info this function is fot testing every minute, but in the future it needs to be every 15 minutes

    No i do not user textAlignments.

    I found the text in the border is not change position at all.

  • You should at least takte the image outside for loop and then think about a better way

    IntstrTemp Is defined only after you use it that could be causing the x glitch

  • Thanx for help.. You all have me put in the right direction ;)

    After a lot of struggling and trying the problem is partly solved. I added a textAlign(LEFT); and everything seems OK.

    But i used lines (see picture 1) and they disappear.... Do i need to put these in the draw function or what?

  • edited May 2017

    draw() seems a good place

    make sure

    • you say stroke(0); (this is for the color black) before it and

    • also strokeWeight(1); etc.

  • @Chrisir,

    Perfect, everything is working..... Thanx a lot ^:)^

  • Cool.


Sign In or Register to comment.