void TimelineWidget::drawContent(QPainter& painter, QRectF rect) { QRectF timelineRect(0, 0, rect.width() - TimeWidth, rect.height()); QRectF dateRect(rect.width() - TimeWidth, 0, TimeWidth, rect.height()); // Draw background //painter.setBrush(QBrush(Qt::lightGray)); painter.drawRect(timelineRect); painter.setBrush(QBrush(QColor(85, 85, 85))); painter.drawRect(timelineRect); painter.setBrush(QBrush(QColor(165, 165, 165))); painter.drawRect(dateRect); const double lowerTime = _currentTime.et - etSpread; const double upperTime = _currentTime.et + etSpread; std::vector<Image*> images; for (Image& i : _images) { if (i.beginning <= upperTime && i.ending >= lowerTime) images.push_back(&i); } drawImages(painter, timelineRect, images, lowerTime, upperTime); // Draw current time painter.setBrush(QBrush(Qt::black)); painter.setPen(QPen(Qt::black, 2)); painter.drawLine(QPointF(0, timelineRect.height() / 2), QPointF(timelineRect.width(), timelineRect.height() / 2)); painter.drawText(timelineRect.width(), timelineRect.height() / 2 + TextOffset, QString::fromStdString(_currentTime.time)); }
void testApp::draw() { ofBackground(85); ofSetColor(170); for(int i = -ofGetHeight(); i < ofGetWidth(); i += 3) { ofLine(i, 0, i + ofGetHeight(), ofGetHeight()); } ofSetColor(255); drawImages("jpg8", jpg8); ofTranslate(0, 40); drawImages("png8", png8); ofTranslate(0, 40); drawImages("png16", png16); ofTranslate(0, 40); drawImages("exrFloat", exrFloat); ofTranslate(exrFloat[0].getWidth()+10, 0); img8.draw(0, 0, 128, 128); img16.draw(0, 128, 128, 128); imgf.draw(0, 256, 128, 128); }
// doDraw //--------------------------------------------------------------------------- void ImageSelectorView::doDraw(const Surface &viewArea, const Surface &clientArea) { viewArea.fill(Color::black); // If no images are loaded, display the background saying that // there are no images loaded, else draw the loaded images. if (flagNoImagesLoaded) { viewArea.bltStringCenter("No Images.", Color::white); } else { drawImages(viewArea); } cView::doDraw(viewArea, clientArea); } // end doDraw
void draw_image(ModeInfo * mi) { Display *display = MI_DISPLAY(mi); Window window = MI_WINDOW(mi); int i; GC gc; imagestruct *ip; if (ims == NULL) return; ip = &ims[MI_SCREEN(mi)]; if (ip->icons == NULL) return; if (icononly && !MI_IS_ICONIC(mi)) return; gc = (message && *message) ? MI_GC(mi) : ip->bgGC; MI_IS_DRAWN(mi) = True; XSetForeground(display, gc, ip->black); if (ip->border.x < 0) ip->image_offset.x = -NRAND(-ip->border.x); else if (ip->border.x > 0) ip->image_offset.x = NRAND(ip->border.x); else ip->image_offset.x = 0; if (ip->border.y < 0) ip->image_offset.y = -NRAND(-ip->border.y); else if (ip->border.y > 0) ip->image_offset.y = NRAND(ip->border.y); else ip->image_offset.y = 0; for (i = 0; i < ip->iconcount; i++) { ip->icons[i].x = NRAND(ip->ncols); ip->icons[i].y = NRAND(ip->nrows); ip->icons[i].color = NRAND(MI_NPIXELS(mi)); if (ip->ncols * ip->nrows > ip->iconcount && ip->icons[i].x >= 0) XFillRectangle(display, window, gc, ip->pixw * ip->icons[i].x + ip->image_offset.x, ip->pixh * ip->icons[i].y + ip->image_offset.y, ip->pixw, ip->pixh); } drawImages(mi); }
void refresh_image(ModeInfo * mi) { #ifdef HAVE_XPM imagestruct *ip; if (ims == NULL) return; ip = &ims[MI_SCREEN(mi)]; if (ip->icons == NULL) return; if (ip->graphics_format >= IS_XPM) { /* This is needed when another program changes the colormap. */ free_image(MI_DISPLAY(mi), ip); init_image(mi); return; } #endif drawImages(mi); }
void Slider::draw(SpriteBatch* spriteBatch, const Rectangle& clip, bool needsClear, bool cleared, float targetHeight) { if (needsClear) { GL_ASSERT( glEnable(GL_SCISSOR_TEST) ); GL_ASSERT( glScissor(_clearBounds.x, targetHeight - _clearBounds.y - _clearBounds.height, _clearBounds.width, _clearBounds.height) ); Game::getInstance()->clear(Game::CLEAR_COLOR, Vector4::zero(), 1.0f, 0); GL_ASSERT( glDisable(GL_SCISSOR_TEST) ); } if (!_visible) return; spriteBatch->start(); drawBorder(spriteBatch, clip); drawImages(spriteBatch, clip); spriteBatch->finish(); drawText(clip); if (_delta == 0.0f) { _dirty = false; } }
// ADD ALL GRAPHICS DRAW MODES HERE -- INTO THE FBO !!! //-------------------------------------------------------------- void ofApp::drawFbo() { ofPushMatrix(); if (!fboFlip) { // defaul position for our system. x,y home (0,0) is top left corner. ofTranslate(stripWidth, stripHeight*stripsPerPort*numPorts); ofRotate(180); ofRotateZ(270); ofRotateY(180); } else { // inverted ofTranslate(stripWidth, 0); ofRotate(90); } ofPushMatrix(); switch (fboRotate) { case 0: ofTranslate(0, 0); ofRotate(0); break; case 1: if (!fboFlip) { ofTranslate(64, 0); ofRotate(90); } else { ofTranslate(0, 64); ofRotate(-90); } break; case 2: ofTranslate(64, 64); ofRotate(180); break; case 3: if (!fboFlip) { ofTranslate(0, 64); ofRotate(270); } else { ofTranslate(64, 0); ofRotate(-270); } break; default: break; } // graphics draw mode switch (drawModes) { case 0: drawTestPattern(); break; case 1: drawVideos(); break; case 2: drawImages(); break; case 3: gif.draw(currentGif, 255, waveSpeed, stripWidth, stripHeight*stripsPerPort*numPorts); break; case 4: drawDemos(); break; default: break; } /* // displaying pixels from sermad's nodeJS for (int y = 0; y < 64; y++) { for (int x = 0; x < 128; x++) { ofSetHexColor(pixelArray[x][y]); ofRect(x, y, 1, 1); //cout << x << " " << y << " " << pixelArray[x][y] << endl; } } */ ofPopMatrix(); ofPopMatrix(); tex.loadScreenData(699, 480, stripWidth, stripHeight*stripsPerPort*numPorts); tex.readToPixels(guiPixels); }
//-------------------------------------------------------------- void testApp::draw() { // Only if the wii-mote accelerates a bit i.e the swing moves or if the user presses "Enter" if(startInstallation) { // Play the Movie first if(!startingMovieFinished) { startingMovie.draw(0, 0); } else { #ifndef DEBUGMODE ofBackground(0, 0, 0); ofSetColor(255,255,255); // If startinganimation is active,have the startingCameraAnimation or the overshotCameraPosition if(isstartingAnimationActive) { if(!startoverShotCameraAnimation) camera.setPosition(startAnimationCameraPosition()); else camera.setPosition(adjustoverShotCameraPosition()); timesinceLastTransition=ofGetElapsedTimeMillis(); //animationMode=true; } else { if((ofGetElapsedTimeMillis()-timesinceLastTransition)>timeGap&&cameraindex!=0&&!animationMode) { cameraindex--; // cout<<"The current camera index value is "<<imageData[cameraindex].y<<endl; animationMode=true; animationCounter=0; timesinceLastTransition=ofGetElapsedTimeMillis(); } // If we are at the last image,or if the song is almost towards the end . End the experience by playing the startingMovie in reverse. else if(cameraindex==0||BluementhalMp3.getPosition()>0.92) { startingMovieFinished=false; ending=true; startingMovie.setSpeed(-1); // Reverse the video being played startingMovie.play(); fadeAudio=true; } if(animationMode) { // Animate the camera from one index to another .. if(combinedImageObjects[numberofImages-cameraindex].theloadedimage.getHeight()>=combinedImageObjects[numberofImages-cameraindex].theloadedimage.getWidth()) camera.setPosition(animate(cameraindex+1, cameraindex)); else camera.setPosition(animate(cameraindex+1, cameraindex)); } else { // Depending on whether the image is more wide or tall,we set the camera's position to be at a fixed position from the image and also wiggle the position of the camera. if(combinedImageObjects[numberofImages-cameraindex].theloadedimage.getHeight()>=combinedImageObjects[numberofImages-cameraindex].theloadedimage.getWidth()) { camera.setPosition(35*SpiralPoints[700*cameraindex]+ofVec3f(0,0,1.6*combinedImageObjects[numberofImages-cameraindex].theloadedimage.getHeight())+wiggle()); } else camera.setPosition(35*SpiralPoints[700*cameraindex]+ofVec3f(0,0,1.05*combinedImageObjects[numberofImages-cameraindex].theloadedimage.getWidth())+wiggle()); } } #endif camera.begin(); ofPushMatrix(); ofRotateX(180); ofPopMatrix(); drawImages(); camera.end(); } #ifdef USEWII // If acceleration is greater than a particular value ,Adjust the timegap or see if it is going backward or forward if(accel-0.2>0.008&&accel!=0) { if(angular_velocity<=-0.03) { ofSetColor(255, 0, 0); if(State.compare("Front")==0) isturnCompleted=true; State="Back"; } else if(angular_velocity>=0.03) { ofSetColor(0,255, 0); // fonttodisplayWiimoteValues.drawString("Front", ofGetWidth()/2,ofGetHeight()/2+50); if(State.compare("Back")==0) isturnCompleted=true; State="Front"; } #ifdef ADJUSTTIMEGAP if(angular_velocity<minAngularVelocity) minAngularVelocity=angular_velocity; if(angular_velocity>maxAngularVelocity) maxAngularVelocity=angular_velocity; if(accel<minAccel) minAccel=accel; if(accel>maxAccel&&accel*1000<400) maxAccel=accel; if(isturnCompleted) { // Adjust the time gap between 2 images.Depending upon the acceleration we adjust the timegap between 2 which 2 images are seen . maxAccel*=1000; if(maxAccel>204&&maxAccel<=214) timeGap=9000; if(maxAccel>214&&maxAccel<=224) timeGap=7500; if(maxAccel>224&&maxAccel<=234) timeGap=6000; if(maxAccel>234&&maxAccel<=244) timeGap=5000; if(maxAccel>244&&maxAccel<=254) timeGap=4000; maxAccel=0; isturnCompleted=false; } // fonttodisplayWiimoteValues.drawString(ofToString(timeGap), ofGetWidth()/2+200, ofGetHeight()/2+50); #endif } ofSetColor(255, 255, 255); /* Use these to get the Acceleration and Velocity values from the Wii-mote*/ // fonttodisplayWiimoteValues.drawString("Acceleration "+ofToString(accel*1000), ofGetWidth()/2, ofGetHeight()/2+100); // fonttodisplayWiimoteValues.drawString("Velocity "+ofToString(angular_velocity*1000), ofGetWidth()/2, ofGetHeight()/2+200); // fonttodisplayWiimoteValues.drawString("Max Acceleration "+ofToString(maxAccel*1000), ofGetWidth()/2, ofGetHeight()/2+250); // fonttodisplayWiimoteValues.drawString("Max Velocity "+ofToString(max*1000), ofGetWidth()/2, ofGetHeight()/2+350); // cout<<"Acceleration "<<accel*1000 <<"\n Max Acceleration "<<maxAccel*1000<<"\n\n Min Acceleration "<<minAccel<<endl; // // cout<<"\nAngular Velocity "<<angular_velocity<<"\n Max Velocity "<<max*1000<<"\n\n Min Velocity "<<minAngularVelocity<<endl;; #endif } else{ startingMovie.draw(0, 0); ofSetColor(255, 255, 255); tempText="Start Swinging !"; previewText.drawString(tempText, 500, startingMovie.getHeight()-25); } }