void HodginDidItApp::processDepth()
{
	mPoints.clear();
	Surface::Iter sit = mSurfDepth.getIter(Area(0,0,mDepthW,mDepthH));
	while(sit.line())
	{
		while(sit.pixel())
		{
			float cDepth = (float)mDepthBuffer[sit.y()*mDepthW+sit.x()];
			sit.r() = 0;
			sit.g() = 0;
			sit.b() = 0;
			sit.a() = 0;
			if(cDepth<32000)
			{
				float cScaled = cDepth/1000.0f;
				if(cDepth<300)
				{
					uint8_t v = (uint8_t)lmap<float>(cDepth,0,300,0,255);
					sit.r() = v;
					sit.a() = v;
				}
				if(sit.x()%2==0&&sit.y()%2==0)
					mPoints.push_back(niDepthToWorld(Vec3f(sit.x(),sit.y(),1.0f*cScaled)));

			}
		}
	}
}
void FrownLogoParticlesApp::setup()
{
    mKeyPressed = false;
    // Lets load a font from the the installed fonts of the OS
    // and set its size to 90

    mFont = Font("Arial",90 );
    
    //Clear the layout to black
    
    mLayout.clear(Color::black() );
    //Set the text color of the layout
    mLayout.setColor(Color(1,1,1));
    
    //Set the font of the layout
    mLayout.setFont(mFont);
    
    //Add the following line to the layout
    mLayout.addLine("FROWN");
    
    //Render the layout into a cinder Surface
    mSurface = mLayout.render();

    //We will now iterate through every pixel in the surface:
    //First get the iterator
    Surface::Iter iter = mSurface.getIter();
    // For every line in the surface
    //
    while ( iter.line() )
    {
        // For every pixel in the line
        while (iter.pixel()) {
            //Check if the color of the current pixel is not black
            if ( ( iter.r() != 0.0f ) && ( iter.g() != 0.0f ) && ( iter.b() != 0.0f ) )
            {
                //If its not black, push the position of the pixel into
                // the initial positions
                mInitialPositions.push_back(ci::Vec2f(iter.x(), iter.y()));
                // Also, lets make the current positions equal to the initial
                // ones
                mCurrentPositions.push_back(ci::Vec2f(iter.x(), iter.y()));
                //lets also keep the color of every pixel
                mPixelColors.push_back(Colorf(iter.r(), iter.g(), iter.b()));
            }
        }
    }
    //Print the size of non-black pixels found in the surface
    console() << "We found " << mInitialPositions.size() <<
    " non black pixels" << endl;
    
    console() << "Spacebar changes: explode /move back" << endl;
    console() << "P or p changes: whether the particles are paused or not" << endl;
}
void BuddhabrotApp::update()
{
	runBrot();
	
	Surface::Iter iter = mSurface.getIter();
	
	int x = 0;
	int y = 0;
	int index;
	
	while( iter.line() ) {
		y = iter.y();
		
		while( iter.pixel() ) {
			x = iter.x();
			index = y * TEXTURE_WIDTH + x;
			
			double r = 0;
			double g = 0;
			double b = 0;
			
			int rMax = mVMaxR;
			while( rMax > 0 && mRedHistory[ rMax ] <= 4 ){
				rMax --;
			}
			
			int gMax = mVMaxG;
			while( gMax > 0 && mGreenHistory[ gMax ] <= 4 ){
				gMax --;
			}
			
			int bMax = mVMaxB;
			while( bMax > 0 && mBlueHistory[ bMax ] <= 4 ){
				bMax --;
			}
			
			if( rMax > 0 ){
				r = (double)mRedBuffer[index]/(double)rMax;
				if( r > 1 ) r = 1;
			}
			
			if( gMax > 0 ){
				g = (double)mGreenBuffer[index]/(double)gMax;
				if( g > 1 ) g = 1;
			}
			
			if( bMax > 0 ){
				b = (double)mBlueBuffer[index]/(double)bMax;
				if( b > 1 ) b = 1;
			}
			
			iter.r() = (int)( r * 255 );
			iter.g() = (int)( g * 255 );
			iter.b() = (int)( b * 255 );
		}
	}
	mTexture = gl::Texture( mSurface );
}
Exemple #4
0
void Item::setColors()
{
	Surface::Iter iter = mPalette.getIter();
	while( iter.line() ) {
		while( iter.pixel() ) {
			int index = iter.x();
			Color col( iter.r()/255.0f, iter.g()/255.0f, iter.b()/255.0f );
			vec2 pos = vec2( index%4, floor(index/4.0f) ) * 5.0f - vec2( 12.0f, 8.0f );
			Rectf rect( -2.0f, -2.0f, 2.0f, 2.0f );
			Swatch swatch( col, mTitleStart + pos + vec2( -10.0f, 10.0f ), rect );
			mSwatches.push_back( swatch );
		}
	}
}
Exemple #5
0
 void PerlinContent::generateNoiseForPosition(const ci::Vec2f & position)
 {
     Surface::Iter iter = mNoiseSurface.getIter();
     while( iter.line() )
     {
         while( iter.pixel() )
         {
             //float v = mPerlin.noise(((iter.x() + position.x) * mFrequency),
                                     //((iter.y() + position.y) * mFrequency));
             //float val = 0.5 + v;
             float val = getValueAtPosition(Vec2f(iter.x() + position.x,
                                                  iter.y() + position.y));
             iter.r() = iter.g() = iter.b() = ci::math<int>::clamp(val * 255, 0, 255);
         }
     }
 }