To stop part of drawings from being removed at update

I’m trying to simulate DDMR (Differential Drive Mobile Robot)
However, draw() method makes update to all the shape and erase the previous frame
I need to draw a specific shape and prevent it from being updated or removed at next frame, in the same time the rest of shapes normally updated and erased.

Don’t rely on what was drawn in the previous frame.

Redraw everything you want to see every single frame.

Then, if you don’t want something to be drawn, just don’t draw it!

I was using MATLAB there was a function called hold();
I’m searching for something like this in processing.
Why shall i save all points in an Array and reshape it every loop !!!

I tried to make a loop and draw every loop everything … it makes the executing process too slow, I don’t think this is effective way.

not clear we talk same thing, but where you loose the speed?
do you use shapes?

PShape head, body, arm;
float ang,speed=0.2;

void setup() {
  size(200, 200);
  frameRate(120);
  // Make shapes
  ellipseMode(CORNER);
  head = createShape(ELLIPSE, -25, 0, 50, 50);
  head.setFill(color(0,0,200));
  body = createShape(RECT, -25, 45, 50, 40);
  body.setFill(color(0,200,0));
  arm = createShape(ELLIPSE, -5, 0, 50, 5);
  arm.setFill(color(200,0,0));
  println("use: mouseX for speed");
}

void draw() {
  background(200,200,0);
  push();
  translate(width/2,50);
  shape(head);
  shape(body);
  translate(20,50);
  ang += speed;
  rotate(ang);
  shape(arm);
  pop();
  text(nf(frameRate,1,1)+" FPS; speed "+nf(speed,1,1),20,height-10);
}

void mouseMoved() {
 speed = map(mouseX,0,width,0,PI); 
}
1 Like