void PinballWarpingApp::draw()
{
	// clear the window and set the drawing color to white
	gl::clear(Color(0, 0, 0));
	gl::enableAlphaBlending( false );
    gl::color(1, 1, 1);
    
	if (mDrawImage)
        mPinball.drawImage();
    
    // iterate over the warps and draw their content
    for( auto &warp : mWarps ) {
        warp->begin();
        gl::clear(ColorA(0, 0, 0, 0));
        mPinball.draw();
        warp->end();
    }
    
    if(mParams->isVisible()) mParams->draw();
    
    gl::drawString(mLastString, vec2(1600, 150), ColorA(1, 1, 1, 1));
}
void PinballWarpingApp::keyDown( KeyEvent event )
{
	// pass this key event to the warp editor first
	if( !Warp::handleKeyDown( mWarps, event ) ) {
		// warp editor did not handle the key, so handle it here
		switch( event.getCode() ) {
            case KeyEvent::KEY_ESCAPE:
                // quit the application
                quit();
                break;
            
            case KeyEvent::KEY_f:
                // toggle full screen
                setFullScreen( !isFullScreen() );
                break;
            
            case KeyEvent::KEY_w:
                // toggle warp edit mode
                Warp::enableEditMode( !Warp::isEditModeEnabled() );
                break;
                
            case KeyEvent::KEY_p:
                if(mParams->isVisible()){
                    mParams->hide();
                }else{
                    mParams->show();
                }
    
            //nudging locations when not in warp mode
            case KeyEvent::KEY_UP:
                // nudge up     pixels
                mPinball.keyShiftLoc(debugLoc, 0);;
                break;
                
            case KeyEvent::KEY_DOWN:
                // nudge down pixels
                mPinball.keyShiftLoc(debugLoc, 1);
                break;
            
            case KeyEvent::KEY_LEFT:
                // nudge left pixels
                mPinball.keyShiftLoc(debugLoc, 2);
                break;

            case KeyEvent::KEY_RIGHT:
                // nudge right pixels
                mPinball.keyShiftLoc(debugLoc, 3);
                break;

            case KeyEvent::KEY_TAB:
                // select which point we are nudging
                debugLoc = mPinball.selectedLoc();
                break;
             
            //changing the threshold values
            case KeyEvent::KEY_9:
                // select which point we are nudging
                mThreshSend = mPinball.changeThreshold(debugLoc, 0);
                break;
            
            case KeyEvent::KEY_0:
                // select which point we are nudging
                mThreshSend = mPinball.changeThreshold(debugLoc, 1);
                break;
		}
	}
}