Hi Hennio,
Thnaks for your reply,
now I have no error in my code and i make multi replicate image.This is my code below,
#include “ofApp.h”
//--------------------------------------------------------------
void ofApp::setup(){
img1.load(“3.png”);
leaf.load(“1.png”);
leaf1.load(“2.png”);
leaf2.load(“ninjatune.jpg”);
leaf3.load(“3.png”);
leaf4.load(“3.png”);
numPixels = leaf2.getWidth() * leaf2.getHeight();
widthSmall = leaf2.getWidth()/NTHPIXEL;
heightSmall = leaf2.getHeight()/NTHPIXEL;
numPixelsSmall = (widthSmall) * (heightSmall);
physics = *new ParticleSystem(0, 0.05);
p_mouse = physics.makeParticle();
p_mouse->makeFixed();
particles.resize(numPixelsSmall);
particles1.resize(numPixelsSmall);
particles2.resize(numPixelsSmall);
orgParticles.resize(numPixelsSmall);
colors[numPixelsSmall];
int a, z;
for (int x=0; x<widthSmall; x++) { // go through all rows
for (int y=0; y<heightSmall; y++) { // go through all columns
a = y*widthSmall+x;
// colors[a] = img.pixels[y*NTHPIXEL*img.width+x*NTHPIXEL];
particles[a] = physics.makeParticle(ofRandom(MIN_MASS, MAX_MASS), x*NTHPIXEL, y*NTHPIXEL, 0);
orgParticles[a] = physics.makeParticle( x*NTHPIXEL, y*NTHPIXEL, 0, ofRandom(MIN_MASS, MAX_MASS));
orgParticles[a]->makeFixed();
physics.makeSpring(particles[a], orgParticles[a], 0.002, 0.001, ofRandom(30) );
// make the moving particles get away from the mouse
physics.makeAttraction(particles[a], p_mouse, -500, 0.01 );
}
}
}
//--------------------------------------------------------------
void ofApp::update(){
p_mouse->position.set(mouseX, mouseY, 0);
physics.tick();
for (int x=0; x<widthSmall; x++) {
for (int y=0; y<heightSmall; y++) {
unsigned a = y*widthSmall+x;
posx1 = particles[a]->position.x/10;
posy1 = particles[a]->position.y/10;
cout << "in if";
leaf1.draw( posx1*(9*10), posy1*(9*10), 90, 90);
}
}
}
//--------------------------------------------------------------
void ofApp::draw(){
ofBackground(100);
ofNoFill();
p_mouse->position.set(mouseX, mouseY, 0);
for (int x=0; x<widthSmall; x++) {
for (int y=0; y<heightSmall; y++) {
unsigned a = y*widthSmall+x;
posx1 = particles[a]->position.x/10;
posy1 = particles[a]->position.y/10;
cout << "in if";
leaf1.draw( posx1*(9*10), posy1*(9*10), 90, 90);
}
}
}
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
}
//--------------------------------------------------------------
void ofApp::keyReleased(int key){
}
//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){
}
//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){
}
//--------------------------------------------------------------
void ofApp::mouseEntered(int x, int y){
}
//--------------------------------------------------------------
void ofApp::mouseExited(int x, int y){
}
//--------------------------------------------------------------
void ofApp::windowResized(int w, int h){
}
//--------------------------------------------------------------
void ofApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
void ofApp::dragEvent(ofDragInfo dragInfo){
}
Now this works great but leaf not move when i move my mouse position.
So what I am missing here.
Thanks.