void Particle::update( const Channel32f &channel ) { //mLoc += mDir * mVel; float gray = channel.getValue( mLoc ); mColor = Color( gray, gray, gray ); mRadius = channel.getValue( mLoc ) * mScale; //mRadius = 3.0f; }
void Particle::update(Channel32f channel) { if (age > lifespan) { alive = false; return; } loc += dir * vel; auto lifePhase = ((float)age) / lifespan; blue = channel.getValue(loc); green = (15.0f * green + blue) / 16.0f; radius = 3.0f * (1 - (abs(lifePhase - 0.5f))) * channel.getValue(loc) + 1.0f; age++; vel*=0.97f; }
void Particle::update( const Channel32f &channel, const ci::Channel32f &rChan, const ci::Channel32f &gChan, const ci::Channel32f &bChan, const ci::Vec2i &mouseLoc ) { //calculate the vector that points from the particl to the mouse. mDirToCursor = mouseLoc - mLoc; mDirToCursor.safeNormalize(); //normalize it so it gives us a unit vector. Vec2f newLoc = mLoc + mDirToCursor * 100.f; newLoc.x = constrain( newLoc.x, 0.0f, channel.getWidth() - 1.0f ); newLoc.y = constrain( newLoc.y, 0.0f, channel.getHeight() - 1.0f ); //mRadius = channel.getValue( mLoc ) * mScale; mRadius = channel.getValue( newLoc ) * mScale; Vec2i mLoci = (Vec2i) mLoc; r = rChan.getValue( newLoc ); g = gChan.getValue( newLoc ); b = bChan.getValue( newLoc ); //console() << r << ", " << g << ", " << b << std::endl; //console() << channel.getValue(mLoc) << std::endl; //console() << "hello" << std::endl; }
void Particle::update(const Channel32f &channel) { //mLoc += mDir * mVel; //float gray = channel.getValue(mLoc); mDesiredRadius = channel.getValue( mLoc ) * 7.0f; if (mDesiredRadius > mRadius) { mRadius += 0.1; } else if (mDesiredRadius < mRadius) { mRadius -= 0.1; } if (mDesiredLoc.x > mLoc.x ) { mLoc.x += (mDesiredLoc.x - mLoc.x) / 20.0 ; } if (mDesiredLoc.x < mLoc.x) { mLoc.x -= (mLoc.x - mDesiredLoc.x) / 20.0; } if (mDesiredLoc.y > mLoc.y ) { mLoc.y += (mDesiredLoc.y - mLoc.y) / 20.0; } if (mDesiredLoc.y < mLoc.y) { mLoc.y -= (mLoc.y - mDesiredLoc.y) / 20.0; } }
void Particle::update( const Channel32f &channel ) { mRadius = channel.getValue( mLoc ) * 7.0f; //float gray = channel.getValue( mLoc ); mLoc += mDir * mVel; }
void Circle::update(const Vec2i &mouseLoc, const Channel32f &channel) { mMouseLoc = mouseLoc; mDirToCursor = mMouseLoc-mLoc; float distToCursor = mDirToCursor.length(); float time = app::getElapsedSeconds(); float dist = distToCursor * 0.025f; float sinOffset = sin(dist-time)+1.0f; mDirToCursor.normalize(); mDirToCursor *= sinOffset * 100.0f; Vec2f newLoc = mLoc+mDirToCursor; newLoc.x = constrain(newLoc.x, 0.0f, channel.getWidth()-1.0f); newLoc.y = constrain(newLoc.y, 0.0f, channel.getHeight() - 1.0f); mRadius = channel.getValue(newLoc)*mScale+2.0f; float gray=channel.getValue(mLoc); mColor=Color(gray,gray,gray); }
void DirVector::update(const Channel32f &channel, const Vec2f &windDirection){ //console() << "Update1: << " << mDir << ", " << mRotationVector << endl; //mDir = Vec2f(1.0f, 0.0f); mDir = mRotationVector; //mouseLoc - mLoc; mDir.safeNormalize(); //mDir.normalize(); Vec2f newLoc = mLoc + mDir * 100.f; newLoc.x = constrain(newLoc.x, 0.f, channel.getWidth() - 1.f); newLoc.x = constrain(newLoc.x, 0.f, channel.getHeight() - 1.f); mRadius = channel.getValue(newLoc) * 7.0f; //console() << "Update2: << " << mDir << endl; }
/// This update method takes a float channel, which is our image, and /// the current mouse location. It then takes this data, based on the /// amount of time that has elapsed, and will store the new properties /// of the the Particle for drawing void Particle::update( const Channel32f &channel, const Vec2i &mouseLoc) { /// calculates the direction to the cursor, and finds /// the distance to it, myDirToCursor_ = mouseLoc - myLocation_; float dist_To_Cursor_ = myDirToCursor_.length(); /// with the time and distance change factored in, /// we can generate our sine function offset and /// apply it to the particle. float time_ = app::getElapsedSeconds()*4.0f; float dist_ = dist_To_Cursor_ * myDistChange_; float sinOffset_ = sin(dist_-time_)*2.0f; myDirToCursor_ *= sinOffset_*15.0; /// the radius of the particle is then changed based on the /// current sinOffset_ value. myRadius_ = channel.getValue(myLocation_)*sinOffset_; }
void Particle::update( const Channel32f &channel, const Vec2i &mouseLoc ) { mDirToCursor = mouseLoc - mLoc; float distToCursor = mDirToCursor.length(); float time = app::getElapsedSeconds(); float dist = distToCursor * 0.025f; float sinOffset = sin( dist - time ) + 1.0f; mDirToCursor.normalize(); mDirToCursor *= sinOffset * 100.0f; Rectf rect( mLoc.x, mLoc.y, mLoc.x + mRadius, mLoc.y + mRadius ); gl::drawSolidRect( rect ); Vec2f newLoc = mLoc + mDirToCursor; newLoc.x = constrain( newLoc.x, 0.0f, channel.getWidth() - 1.0f ); newLoc.y = constrain( newLoc.y, 0.0f, channel.getHeight() - 1.0f ); mRadius = channel.getValue( newLoc ) * mScale; }
/// This update method takes a float channel, which is our image, and /// the current mouse location. It then takes this data, based on the /// amount of time that has elapsed, and will store the new properties /// of the the Particle for drawing void Particle::update( const Channel32f &channel, const Vec2i &mouseLoc) { /// calculates the direction to the cursor, and finds /// the distance to it, myDirToCursor_ = mouseLoc - myLocation_; float dist_To_Cursor_ = myDirToCursor_.length(); /// with the time and distance change factored in, /// we can generate our sine function offset and /// apply it to the particle. float time_ = app::getElapsedSeconds()*4.0f; float dist_ = dist_To_Cursor_ * myDistChange_; float sinOffset_ = sin(dist_-time_)*2.0f; myDirToCursor_ *= sinOffset_*15.0; /// this if ... else if stack determines the /// color of the particle based on the values /// of the booleans isRed_, isGreen_, and isBlue_. if (!isRed_) { /// makes it red rand_ = randFloat(0.75f, 1.0f); myColor_ = Color(rand_, 0.0f, 0.0f); } else if (!isGreen_) { /// makes it green rand_ = randFloat(0.75f, 1.0f); myColor_ = Color(0.0f, rand_, 0.0f); } else if (!isBlue_) { /// makes it blue rand_ = randFloat(0.75f, 1.0f); myColor_ = Color(0.0f, 0.0f, rand_); } /// the radius of the particle is then changed based on the /// current sinOffset_ value. myRadius_ = channel.getValue(myLocation_)*sinOffset_; }