void ofxTLDepthImageSequence::draw(){
	if(!isLoaded()){
		ofPushStyle();
		ofSetColor(timeline->getColors().disabledColor);
		ofRect(getDrawRect());
		ofPopStyle();
		return;
	}
	
	//clip hanging frames off the sides
	glEnable(GL_SCISSOR_TEST);
	glScissor(bounds.x, 0, bounds.width, ofGetHeight());
	
	if(thumbsEnabled && getDrawRect().height > 10){
		ofPushStyle();
		ofSetColor(255);
		
		lock();
		for(int i = 0; i < videoThumbs.size(); i++){
			if(videoThumbs[i].thumb != NULL){
				if(videoThumbs[i].loaded &&!videoThumbs[i].thumb->isUsingTexture()){
					videoThumbs[i].thumb->setUseTexture(true);
					videoThumbs[i].thumb->update();
				}
				
				videoThumbs[i].thumb->draw(videoThumbs[i].displayRect);
				
				ofNoFill();
				ofSetColor(timeline->getColors().textColor);
				timeline->getFont().drawString(ofToString(videoThumbs[i].framenum), videoThumbs[i].displayRect.x+5, videoThumbs[i].displayRect.y+15);
				ofRect(videoThumbs[i].displayRect);
			}
			else{
				ofPushStyle();
				ofSetColor(0);
				ofRect(videoThumbs[i].displayRect);
				ofPopStyle();
			}
		}
		unlock();
		ofPopStyle();
	}

	ofPushStyle();
	string frameString = "F# " + ofToString(depthImageSequence->getCurrentFrame());
	string timecodeString = ofxTimecode::timecodeForMillis(timeOffsetInMillis+depthImageSequence->getCurrentMilliseconds());
	int selectedFrameX = ofClamp(timeline->millisToScreenX(getSelectedTimeInMillis()), bounds.getMinX(), bounds.getMaxX());
	ofSetColor(timeline->getColors().backgroundColor, 175);
	ofRect(selectedFrameX, bounds.y, timeline->getFont().getStringBoundingBox("00:00:00:000",0,0).width+20, bounds.height);
	
	ofSetColor(timeline->getColors().textColor);
	ofLine(selectedFrameX, bounds.y, selectedFrameX, bounds.y+bounds.height);

	timeline->getFont().drawString(timecodeString, selectedFrameX + 10,  bounds.y+timeline->getFont().getLineHeight()+3);
	timeline->getFont().drawString(frameString, selectedFrameX + 10, bounds.y+(timeline->getFont().getLineHeight()+3)*2);

	glDisable(GL_SCISSOR_TEST);
	
	ofPopStyle();
}
Beispiel #2
0
//--------------------------------------------------------------
void mui::Image::autoHeight(){
	ofRectangle rect = getDrawRect();
	if( rect.width < width ){
		height = rect.height*width/rect.width;
	}
    //	height = -rect.y + rect.height;
}
Beispiel #3
0
bool World::persent(HWND hWnd)
{
	//デバイスがロストしていないかチェック
	if(Device::isLost())
	{
		//ロストデバイスの修復
		if(!Device::resetDevice())
			return false;
	}
	//デバイスの状況チェック
//	if(!isDeviceActive())
//		return false;
	IDirect3DDevice9* pd3dDevice = Device::getInterface();

	if(Device::getParams()->SwapEffect & D3DSWAPEFFECT_COPY)
	{
		//アスペクト比を保って描画
		AFL::WINDOWS::Rect3D rect;
		getDrawRect(hWnd,&rect);

		//描画済みサーフェイスを表示
		//pd3dDevice->Present( NULL, rect, hWnd, NULL );
		m_screen.present(hWnd);
	}
	else
	{
		//描画済みサーフェイスを表示
		//pd3dDevice->Present( NULL, NULL, hWnd, NULL );
		m_screen.present(hWnd);
	}
	//領域を更新済みに設定
	ValidateRect(hWnd,NULL);
	return true;
}
void ofxTLVideoPlayer::draw(){
	
	if(player == NULL){
		return;
	}
	
	if( autoUpdateTimelineOnDraw )
	{
		updateTimeline();
	}

	
//	cout << "in out is " << inFrame << " " << outFrame << endl;
	
	ofPushStyle();
	
	if(thumbsEnabled && getDrawRect().height > 10){
		ofSetColor(255);
		for(int i = 0; i < videoThumbs.size(); i++){
			if(videoThumbs[i].visible){
				videoThumbs[i].thumb.draw(videoThumbs[i].displayRect);
			}
		}
		
		for(int i = 0; i < videoThumbs.size(); i++){
			if(videoThumbs[i].visible){

				if (!thumbsEnabled) {
					ofFill();
					ofSetColor(0);
					ofRect(videoThumbs[i].displayRect);
				}
				ofNoFill();
				ofSetColor(255, 150, 0);
				ofDrawBitmapString(ofToString(videoThumbs[i].framenum), videoThumbs[i].displayRect.x+5, videoThumbs[i].displayRect.y+15);
				ofRect(videoThumbs[i].displayRect);
			}
		}		
	}
	
	int selectedFrameX = screenXForIndex(selectedFrame);
	ofSetColor(0, 125, 255);
	ofLine(selectedFrameX, bounds.y, selectedFrameX, bounds.y+bounds.height);
	ofDrawBitmapString(ofToString(selectedFrame), selectedFrameX, bounds.y+35);
	
	if(inFrame != -1){
		ofSetLineWidth(2);
		ofSetColor(timeline->getColors().highlightColor);
		int inFrameX  = screenXForIndex(inFrame);
		int outFrameX = screenXForIndex(outFrame);
		ofLine(inFrameX, bounds.y, inFrameX, bounds.y+bounds.height);
		ofLine(outFrameX, bounds.y, outFrameX, bounds.y+bounds.height);
		ofSetColor(timeline->getColors().keyColor);
		ofDrawBitmapString("IN:  " + ofToString(inFrameX),  inFrameX  + 5, bounds.y + 10);
		ofDrawBitmapString("OUT: " + ofToString(outFrameX), outFrameX + 5, bounds.y + bounds.height - 20);
	}
	
	ofPopStyle();
}
Beispiel #5
0
void ofxUISlider_<T>::drawSkinInDrawRect()
{
	ofPushMatrix();		
	transform();
    ofRectangle rect = getDrawRect();
	drawSkinRect(skin_fill, rect);
	ofPopMatrix();
}
Beispiel #6
0
void ofxTLPage::refreshSnapPoints(){
	//get the snapping points
	snapPoints.clear();
	if(timeline->getSnapToOtherElements()){
		for(int i = 0; i < headers.size(); i++){
			tracks[headers[i]->name]->getSnappingPoints(snapPoints);	
		}
	}
    
	if(ticker != NULL && timeline->getSnapToBPM()){
		ticker->getSnappingPoints(snapPoints);
	}
	
	//double check to make sure snap points are all on screen
	if(snapPoints.size()*snappingTolerance > getDrawRect().width){
		snapPoints.clear();
	}	
}
void ofxTLVideoPlayer::draw(){
	
	if(player == NULL){
		return;
	}
	
	if(player->isPlaying() && player->getSpeed() > 0.0){
		
//		cout << " is playing player frame " << player->getCurrentFrame() << " current frame " << getCurrentFrame() << endl;
		if(timeline->getIsFrameBased()){

			if(player->getCurrentFrame() < inFrame || player->getCurrentFrame() > outFrame){
//				cout << "reset in frame from " << player->getCurrentFrame() << endl;
				player->setFrame(inFrame);
//				cout << "	to: " << player->getCurrentFrame() << endl;
			}
			
			if(lastFrame > player->getCurrentFrame()){
				currentLoop++;
//				cout << "LOOPED! with last frame " << lastFrame << " " << player->getCurrentFrame() << " current loop " << currentLoop << endl;
			}
			
			if(timeline->getOutFrame() < getCurrentFrame() || timeline->getInFrame() > getCurrentFrame() ){				
				if(timeline->getInFrame() > player->getCurrentFrame() && timeline->getLoopType() == OF_LOOP_NONE){
					player->stop();
				}
				else {
					//player->setFrame( timeline->getInFrame() % player->getTotalNumFrames());
					selectFrame(timeline->getInFrame());
				}
			}
						
			timeline->setCurrentFrame(getCurrentFrame());
			lastFrame = player->getCurrentFrame();
		}
		else{
			if(timeline->getOutTime() < player->getPosition()*player->getDuration() || timeline->getInTime() > player->getPosition()*player->getDuration() ){
				player->setFrame(timeline->getInOutRange().min * player->getTotalNumFrames());
			}
			timeline->setCurrentTime( player->getPosition() * player->getDuration());
		}
	}
	
//	cout << "in out is " << inFrame << " " << outFrame << endl;
	
	ofPushStyle();
	
	if(thumbsEnabled && getDrawRect().height > 10){
		ofSetColor(255);
		for(int i = 0; i < videoThumbs.size(); i++){
			if(videoThumbs[i].visible){
				videoThumbs[i].thumb.draw(videoThumbs[i].displayRect);
			}
		}
		
		for(int i = 0; i < videoThumbs.size(); i++){
			if(videoThumbs[i].visible){

				if (!thumbsEnabled) {
					ofFill();
					ofSetColor(0);
					ofRect(videoThumbs[i].displayRect);
				}
				ofNoFill();
				ofSetColor(255, 150, 0);
				ofDrawBitmapString(ofToString(videoThumbs[i].framenum), videoThumbs[i].displayRect.x+5, videoThumbs[i].displayRect.y+15);
				ofRect(videoThumbs[i].displayRect);
			}
		}		
	}
	
	int selectedFrameX = screenXForIndex(selectedFrame);
	ofSetColor(0, 125, 255);
	ofLine(selectedFrameX, bounds.y, selectedFrameX, bounds.y+bounds.height);
	ofDrawBitmapString(ofToString(selectedFrame), selectedFrameX, bounds.y+35);
	
	if(inFrame != -1){
		ofSetLineWidth(2);
		ofSetColor(timeline->getColors().highlightColor);
		int inFrameX  = screenXForIndex(inFrame);
		int outFrameX = screenXForIndex(outFrame);
		ofLine(inFrameX, bounds.y, inFrameX, bounds.y+bounds.height);
		ofLine(outFrameX, bounds.y, outFrameX, bounds.y+bounds.height);
		ofSetColor(timeline->getColors().keyColor);
		ofDrawBitmapString("IN:  " + ofToString(inFrameX),  inFrameX  + 5, bounds.y + 10);
		ofDrawBitmapString("OUT: " + ofToString(outFrameX), outFrameX + 5, bounds.y + bounds.height - 20);
	}
	
	ofPopStyle();
}
void ofxTLVideoPlayer::mousePressed(ofMouseEventArgs& args){
	ofxTLElement::mousePressed(args);
	if(getDrawRect().inside(args.x, args.y)){
		timeline->unselectAll();
	}
}
void ofxTLVideoTrack::draw(){
	
	if(player == NULL){
		return;
	}
	//inFrame = outFrame = -1;
    inFrame = 0;
    outFrame = player->getTotalNumFrames();

	ofPushStyle();
    
	int selectedFrameX = screenXForTime( timeline->getTimecode().secondsForFrame(selectedFrame));
	
	if(thumbsEnabled && getDrawRect().height > 10){
		//clip hanging frames off the sides

		ofSetColor(255);
        lock();
		for(int i = 0; i < videoThumbs.size(); i++){
            if(videoThumbs[i].thumb != NULL){
                if(videoThumbs[i].loaded &&!videoThumbs[i].thumb->isUsingTexture()){
                    videoThumbs[i].thumb->setUseTexture(true);
                    videoThumbs[i].thumb->update();
                }

                videoThumbs[i].thumb->draw(videoThumbs[i].displayRect);
            }
            else{
                ofPushStyle();
                ofSetColor(0);
                ofRect(videoThumbs[i].displayRect);
                ofPopStyle();
            }
		}
		unlock();
        
		for(int i = 0; i < videoThumbs.size(); i++){

            if (!thumbsEnabled) {
                ofFill();
                ofSetColor(0);
                ofRect(videoThumbs[i].displayRect);
            }
					
            ofNoFill();
            ofSetColor(timeline->getColors().textColor);
            timeline->getFont().drawString(ofToString(videoThumbs[i].framenum), videoThumbs[i].displayRect.x+5, videoThumbs[i].displayRect.y+15);
            ofRect(videoThumbs[i].displayRect);
		}
        
        if(drawVideoPreview){
            ofRectangle previewRect = ofRectangle(0, 0, player->getWidth() - 2, player->getHeight() - 4);
            previewRect.scaleTo(bounds, OF_ASPECT_RATIO_KEEP);
            previewRect.x = selectedFrameX + 1;
            previewRect.y = bounds.y - 1;
            player->draw(previewRect);
            ofPushStyle();
            ofFill();
            ofSetColor(timeline->getColors().backgroundColor, 100);
            ofRect(selectedFrameX + 1, bounds.y + 1, previewRect.width - 2, bounds.height - 2);
            ofPopStyle();
        }
	}
	
	ofSetColor(timeline->getColors().textColor);
	ofLine(selectedFrameX, bounds.y, selectedFrameX, bounds.y+bounds.height);
	timeline->getFont().drawString("F# " + ofToString(selectedFrame), selectedFrameX, bounds.y+15);
	timeline->getFont().drawString(ofxTimecode::timecodeForSeconds(player->getPosition()*player->getDuration()), selectedFrameX, bounds.y+30);
	
	if(inFrame != -1){
		ofSetLineWidth(2);
		ofSetColor(timeline->getColors().highlightColor);
		int inFrameX  = screenXForTime( timeline->getTimecode().secondsForFrame(inFrame));
		int outFrameX = screenXForTime( timeline->getTimecode().secondsForFrame(outFrame));
		ofLine(inFrameX, bounds.y, inFrameX, bounds.y+bounds.height);
		ofLine(outFrameX, bounds.y, outFrameX, bounds.y+bounds.height);
		ofSetColor(timeline->getColors().textColor);
		timeline->getFont().drawString("in  " + ofToString(inFrame),  inFrameX  + 5, bounds.y + 10);
		timeline->getFont().drawString("out " + ofToString(outFrame), outFrameX + 5, bounds.y + bounds.height - 20);
	}
	
	ofPopStyle();
}
Beispiel #10
0
    void Vampire::draw(Point offset, Surface &surface) const{

        if (!visible)
            return;

		// Draw attack under vampire sprite
		smallAttack.draw(offset, surface);
		batAttack.draw(offset, surface);

		// Vampire sprite
        const Surface *image = 0;
        switch (dir){
        case DIR_E:
            switch (state){
            case IDLE:
                image = idleE; break;
            case MOVING:
                image = movingE; break;
            case ATTACKING:
                image = attackingE; break;
            case BURNING:
                image = burningR; break;
            }
            break;
        case DIR_F:
            switch (state){
            case IDLE:
                image = idleF; break;
            case MOVING:
                image = movingF; break;
            case ATTACKING:
                image = attackingF; break;
            case BURNING:
                image = burningR; break;
            }
            break;
        case DIR_G:
            switch (state){
            case IDLE:
                image = idleG; break;
            case MOVING:
                image = movingG; break;
            case ATTACKING:
                image = attackingG; break;
            case BURNING:
                image = burningL; break;
            }
            break;
        case DIR_H:
            switch (state){
            case IDLE:
                image = idleH; break;
            case MOVING:
                image = movingH; break;
            case ATTACKING:
                image = attackingH; break;
            case BURNING:
                image = burningL; break;
            }
            break;
		default:
			// Should not happen
			assert(false);
			break;
        }

		assert(image);
        size_t col = 0, row = 0;
        switch (state){
        case IDLE:
            row = frame / idleColumns;
            col = frame % idleColumns;
            break;
        case MOVING:
            row = frame / movingColumns;
            col = frame % movingColumns;
            break;
        case ATTACKING:
            row = frame / attackingColumns;
            col = frame % attackingColumns;
			break;
        case BURNING:
            row = frame / burningColumns;
            col = frame % burningColumns;
            debug("Burning; frame=", frame);
            break;
		default:
			// Should not happen
			assert(false);
			break;
        }
        SDL_Rect srcRect;
        srcRect.w = srcRect.h = 128;
        
        image->draw(screenBuf, &getDrawRect(offset), &makeRect(col * 128, row * 128, 128, 128));

		// Entity debug
		Entity::draw(offset, surface);
    }