Example #1
0
void testApp::draw(){
	if(drawFluid) {
        ofClear(0);
		glColor3f(1, 1, 1);
		fluidDrawer.draw(0, 0, ofGetWidth(), ofGetHeight());
	} else {
//		if(ofGetFrameNum()%5==0)
            fadeToColor(0, 0, 0, 0.01);
	}
	if(drawParticles)
		particleSystem.updateAndDraw(fluidSolver, ofGetWindowSize(), drawFluid);
	
	ofDrawBitmapString(sz, 50, 50);

#ifdef USE_GUI 
	gui.draw();
#endif
}
void smokeScene::draw(float x, float y, float scale){
    
    //moved this from update as the easiest wy to get mapping vars
    for (int i = 0; i < flow->current.size(); i++) {
        if (flow->motion[i + flow->motion.size()/2].lengthSquared() > threshold) {
            
            ofVec2f featNorm;
            featNorm.x = ((flow->features[i].x - 160) * scale + 160 + x)  / ofGetWidth();
            featNorm.y = ((flow->features[i].y - 120) * scale + 120 + y)  / ofGetHeight();
            
            ofVec2f featVel;
            featVel.x = flow->motion[i + flow->motion.size()/2].x * scale / ofGetWidth();
            featVel.y = flow->motion[i + flow->motion.size()/2].y * scale / ofGetHeight();
            
            addToFluid(featNorm, featVel, true, true);
        }
    }
    
	fluidSolver.update();
    //end update
    
    
    ofPushStyle();
    ofSetBackgroundAuto(false);
//    ofEnableAlphaBlending();
    
    if(drawFluid) {
        ofClear(0);
		glColor3f(1, 1, 1);
		fluidDrawer.draw(0, 0, ofGetWidth(), ofGetHeight());
	} else {
        //		if(ofGetFrameNum()%5==0)
        fadeToColor(0,0,0, 0.01);
	}
	if(drawParticles) {
        ofSetColor(particleColor);
		particleSystem.updateAndDraw(fluidSolver, ofGetWindowSize(), drawFluid, particleColor);
    }
	
    ofSetBackgroundAuto(true);
    ofPopStyle();
}
Example #3
0
void FluidParticles::addToFluidWithColor( Vec2f pos, Vec2f vel, Color drawColor, bool addForce )
{
    float speed = vel.x * vel.x  + vel.y * vel.y * aspectRatio * aspectRatio;    // balance the x and y components of speed with the screen aspect ratio
    if( speed > 0 ) {
		pos.x = constrain( pos.x, 0.0f, 1.0f );
		pos.y = constrain( pos.y, 0.0f, 1.0f );
		
        const float colorMult = 10;
        const float velocityMult = 30;
		
		fluidSolver.addColorAtPos( pos, drawColor * colorMult );
		
		if( drawParticles )
			particleSystem.addParticles( pos * Vec2f( surfaceSize ), 4 );
		
		if( addForce )
			fluidSolver.addForceAtPos( pos, vel * velocityMult );
		
		if( ! drawFluid && elapsedFrames%5==0 )
			fadeToColor( 0, 0, 0, 0.1f );
    }
}
Example #4
0
void BaseRenderOSystem::fade(uint16 alpha) {
	byte dwAlpha = (byte)(255 - alpha);
	return fadeToColor(0, 0, 0, dwAlpha);
}
void LEDStrip::fadeToColor(Color color) {
	fadeToColor(color, FADE_SPEED_NORMAL);
}