void BloomingNeonApp::drawStrokedRect( const Rectf &rect )
{
	// we don't want any texture on our lines
	glDisable(GL_TEXTURE_2D);

	gl::drawLine(rect.getUpperLeft(), rect.getUpperRight());
	gl::drawLine(rect.getUpperRight(), rect.getLowerRight());
	gl::drawLine(rect.getLowerRight(), rect.getLowerLeft());
	gl::drawLine(rect.getLowerLeft(), rect.getUpperLeft());
}
예제 #2
0
void RenderMesh2D::setAsBox( const Rectf &bounds )
{
  if( vertices.size() != 4 ){ vertices.assign( 4, Vertex() ); }
  vertices[0].position = bounds.getUpperRight();
  vertices[1].position = bounds.getUpperLeft();
  vertices[2].position = bounds.getLowerRight();
  vertices[3].position = bounds.getLowerLeft();
}
void SmilesApp::mouseDown( MouseEvent event ){
    
    if(mSmileRect.getUpperLeft().distance(event.getPos())<10){mSmileRectDraggingCorner=0;}
    if(mSmileRect.getUpperRight().distance(event.getPos())<10){mSmileRectDraggingCorner=1;}
    if(mSmileRect.getLowerLeft().distance(event.getPos())<10){mSmileRectDraggingCorner=2;}
    if(mSmileRect.getLowerRight().distance(event.getPos())<10){mSmileRectDraggingCorner=3;}
    
}
예제 #4
0
void TouchUi::setMask( const Rectf& bounds )
{
	mMask.clear();
	mMask.moveTo( bounds.getUpperLeft() );
	mMask.lineTo( bounds.getUpperRight() );
	mMask.lineTo( bounds.getLowerRight() );
	mMask.lineTo( bounds.getLowerLeft() );
	mMask.close();
}
 void ShapeTesselator::add(const Rectf &rect)
 {
     vector<Vec2f> polygon;
     polygon.emplace_back(rect.getUpperLeft());
     polygon.emplace_back(rect.getUpperRight());
     polygon.emplace_back(rect.getLowerRight());
     polygon.emplace_back(rect.getLowerLeft());
     
     add(polygon);
 }
예제 #6
0
void TextLabels::renderString( const std::u16string &str, vec2 *cursor, float stretch )
{
	std::u16string::const_iterator itr;
	for( itr = str.begin(); itr != str.end(); ++itr ) {
		// retrieve character code
		uint16_t id = (uint16_t)*itr;

		if( mFont->contains( id ) ) {
			// get metrics for this character to speed up measurements
			Font::Metrics m = mFont->getMetrics( id );

			// skip whitespace characters
			if( !isWhitespaceUtf16( id ) ) {
				size_t index = mVertices.size();

				Rectf bounds = mFont->getBounds( m, mFontSize );
				mVertices.push_back( vec3( *cursor + bounds.getUpperLeft(), 0 ) );
				mVertices.push_back( vec3( *cursor + bounds.getUpperRight(), 0 ) );
				mVertices.push_back( vec3( *cursor + bounds.getLowerRight(), 0 ) );
				mVertices.push_back( vec3( *cursor + bounds.getLowerLeft(), 0 ) );

				bounds = mFont->getTexCoords( m );
				mTexcoords.push_back( bounds.getUpperLeft() );
				mTexcoords.push_back( bounds.getUpperRight() );
				mTexcoords.push_back( bounds.getLowerRight() );
				mTexcoords.push_back( bounds.getLowerLeft() );

				mIndices.push_back( index + 0 ); mIndices.push_back( index + 3 ); mIndices.push_back( index + 1 );
				mIndices.push_back( index + 1 ); mIndices.push_back( index + 3 ); mIndices.push_back( index + 2 );

				mOffsets.insert( mOffsets.end(), 4, mOffset );
			}

			if( id == 32 )
				cursor->x += stretch * mFont->getAdvance( m, mFontSize );
			else
				cursor->x += mFont->getAdvance( m, mFontSize );
		}
	}

	//
	mBoundsInvalid = true;
}
void SmilesApp::draw()
{
	gl::enableAlphaBlending();
	gl::clear( Color::black() );
    gl::color(1.0f, 1.0f, 1.0f);
    
    // draw webcam capture
	if( !mCapture || !mSurface )
		return;
    gl::draw( gl::Texture(mSurface) );
    
    if(mGreyChannel){
    gl::pushMatrices();{
        gl::translate(mSmileRect.getUpperLeft());
        gl::draw( gl::Texture(mGreyChannel) );
    }gl::popMatrices();
    }
    
    // draw rect that actually gets analysed:
    gl::color(ColorA(0.0f, 1.0f, 0.0f, 1.0f));
    gl::drawStrokedRect(mSmileRect);
    gl::drawStrokedCircle(mSmileRect.getUpperLeft(), 10);
    gl::drawStrokedCircle(mSmileRect.getUpperRight(), 10);
    gl::drawStrokedCircle(mSmileRect.getLowerLeft(), 10);
    gl::drawStrokedCircle(mSmileRect.getLowerRight(), 10);
    
    
    //draw mSmileThreshold
    gl::pushMatrices();{
        gl::color(ColorA(1.0f, 0.0f, 0.0f, 0.3f));
        gl::drawSolidRect(Rectf( 0, (1-mSmileThreshold)*getWindowHeight(), getWindowWidth(), getWindowHeight() ) );
        gl::drawStrokedRect( Rectf(0, 0, getWindowWidth(), getWindowHeight() ) );
    }gl::popMatrices();
    
    //draw faces
    if(!mFaces.empty()){
        gl::pushMatrices();{
            gl::translate(mSmileRect.getUpperLeft());
            gl::color(1.0f, 1.0f, 1.0f);
            for(list<VisualObject *>::iterator it = mFaces.begin(); it != mFaces.end(); ++it) {
                mFace = static_cast<FaceObject*>(*it);
                gl::drawStrokedRect(Rectf(mFace->x, mFace->y, mFace->x+mFace->xSize, mFace->y+mFace->ySize ));
            }
        }gl::popMatrices();
    }
    
    mParams.draw();
}