I’m writing a code to make a wordcloud using a couple of libraries. I need to redraw the (updated) cloud after I receive a vocal input. I’m doing that by calling the function Background(); that should draw a background over the old one. I’m placing the background outside the draw function because there doesn’t work properly.
I would appreciate a suggestion on how to solve the problem or a potential workaround.
Thanks all for the help!!!
If the websocket listener is running on its own thread then I think you shouldn’t draw anything inside webSocketServerEvent, but instead set variables that are later used inside the draw() function, which runs in the graphics thread. I believe there are similar issues in other libraries that receive external events out of the main graphics thread.
As an example, you could have a global boolean dataReceived = false; which you toggle when you receive data, and the draw function checks this boolean to know if something should be updated.
It draw a new background for each word he write meaning i don’t see anything. I cant understand where i should make a new background() so that:
Program start: draw background > draw the cloud > new Vocal input> draw (new) background > draw cloud