The background seems like its redrawing

Hello I have below code that I would expect it to draw a circle however, what I am seeing is a sphere going around in circle which I would expect if I had put ofSetBackgroundColor(0, 0, 0); inside the Draw function, but I m only setting it in Setup.

void ofApp::setup(){

    ofSetWindowShape(500, 500);
    ofSetBackgroundColor(0, 0, 0);
}

//--------------------------------------------------------------
void ofApp::update(){

}

//--------------------------------------------------------------
void ofApp::draw(){
    
    float deg = glm::radians(float(ofGetFrameNum()));
    float waveX = sin(deg) * ofGetHeight() * 0.4;
    float waveY = cos(deg) * ofGetHeight() * 0.4;
    
    ofTranslate(ofGetWidth()/2, ofGetHeight()/2);
    ofSetColor(255, 255, 255);
    
    ofDrawEllipse(waveX, waveY, 50, 50);
}

What I want >

Apr-22-2022 11-03-18

Hi @Yooniverse , shapes are filled by default. Just call ofNoFill() (in setup) to draw without filling; calling ofFill() will draw filled shapes.

1 Like

hey Tim! I think i didn’t ask the question correctly esp with the static image.
I have attached an GIF of the result that I want

notwhatiwant

this is the result I get with my code its not what I want but I want it to “draw” circle

Ah OK yes that is more clear now (I think)! So, the background will clear each cycle (update and draw) unless you tell it not to with ofSetBackgroundAuto(false), which you can call once in ofApp::setup().

Another way to do something very similar is draw the ellipse into an ofFbo in ofApp::update(), and then draw that ofFbo in ofApp::draw(). The ofFbo will retain everything that you’ve previously drawn unless you specifically ofClear(ofColor(0)) before drawing something new.

1 Like

both suggested solutions worked for me. Thank you so much @TimChi