Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

Equivalent of Processing’s loadPixels, pixels[] not using ofImage

$
0
0

@kotaonaga wrote:

Hi!

I am trying to create Metaballs like this tutorial.
I tried to write the equivalent of this Processing’s code in oF.
I tried to use ofImage, but it was too heavy for the animation.
Are there any ways to do this not using ofImage?

Processing code that I want to use:

color pink = color(255, 102, 204);
loadPixels();
for (int i = 0; i < (width*height/2)-width/2; i++) {
  pixels[i] = pink;
}
updatePixels();

My oF code:

void ofApp::draw(){
    ofColor pink = ofColor(255, 102, 204);
    
    ofImage img;
    img.allocate(300, 300, OF_IMAGE_COLOR);
    for(int width = 0; width < ofGetWidth(); width++){
        for(int height = 0; height < ofGetHeight(); height++){
            img.setColor(width, height, ofColor(pink));
        }
    }
    
    img.update();
    img.draw(0, 0);
}

Thank you!

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles