Example #1
0
void demo() {
    word e;
    float i;
    pyor = currentTime * 100;
    for(i=6.0; i>1.0f; i--){
        struct Vec a = VecCreateF( 110.0f,-122.0f, fmod(i+currentTime,12.0f)+1.2f);
        struct Vec b = VecCreateF(-110.0f,-110.0f, fmod(i+currentTime,12.0f)+1.2f);
        struct Vec c = VecCreateF( i, 110.0f, fmod(i,12.0f)+1.2f);
        struct Vec z =  VecCreateF( 160.0f+sin(currentTime+i*3.141591f*2.0f/6.0f)*64.0f, 100.0f+cos(currentTime+i*3.141591f*2.0f/6.0f)*64.0f, 0.0f);
        
        rot2D( &a, pyor + i * 32 );
        rot2D( &b, pyor + i * 32 );
        rot2D( &c, pyor + i * 32 );
        a.x = FIXEDDIV(a.x, a.z);
        a.y = FIXEDDIV(a.y, a.z);
        b.x = FIXEDDIV(b.x, b.z);
        b.y = FIXEDDIV(b.y, a.z);
        c.x = FIXEDDIV(c.x, a.z);
        c.y = FIXEDDIV(c.y, a.z);
        add( &a, &z);
        add( &b, &z);
        add( &c, &z);
        polygonFillFixed(a.x, a.y, b.x, b.y, c.x, c.y);
    }
    drawHorizontalLines();
}
Example #2
0
void Ground::draw() {
   glPushMatrix(); {
      glColor3f(1, 1, 1);
      glBegin(GL_LINES); {
         drawHorizontalLines();
         drawVerticalLines();
      } glEnd();
   } glPopMatrix();
}
Example #3
0
QGraphicsPixmapItem* Diagram::draw(QString title){
    if(pixmap == 0)
        return 0;
    QPainter p(pixmap);
    p.setPen(QPen(Qt::white));
    p.setBrush(Qt::white);
    p.drawRect(pixmap->rect());

    calculateAxisSteps();

    drawCaption(p, title);
    drawXAxis(p);
    drawYAxis(p);
    drawValues(p);
    drawHorizontalLines(p);

    return new QGraphicsPixmapItem(*pixmap,0,scene);
}
void TrafficGraph::drawWidget(QPainter *p, uint w, uint height, int horizontalScale)
{
  uint h = height; //h will become the height of just the bit we draw the beams in
  p->setFont( mFont );

  uint fontheight = p->fontMetrics().height();
  if(mMinValue < mNiceMinValue || mMaxValue > mNiceMaxValue || mMaxValue < (mNiceRange*0.75 + mNiceMinValue) || mNiceRange == 0)
    calculateNiceRange();
  QPen pen;
  pen.setWidth(1);
  pen.setCapStyle(Qt::RoundCap);
  p->setPen(pen);

  uint top = p->pen().width() / 2; //The y position of the top of the graph.  Basically this is one more than the height of the top bar
  h-= top;

  //check if there's enough room to actually show a top bar. Must be enough room for a bar at the top, plus horizontal lines each of a size with room for a scale
  bool showTopBar = mShowTopBar &&  h > (fontheight/*top bar size*/ +5/*smallest reasonable size for a graph*/ );
  if(showTopBar) {
    top += fontheight; //The top bar has the same height as fontheight. Thus the top of the graph is at fontheight
    h -= fontheight;
  }
  if(mBackgroundImage.isNull() || (uint)mBackgroundImage.height() != height || (uint)mBackgroundImage.width() != w) { //recreate on resize etc
    mBackgroundImage = QImage(w, height, QImage::Format_RGB32);
    QPainter pCache(&mBackgroundImage);
    pCache.setRenderHint(QPainter::Antialiasing, false);
    pCache.setFont( mFont );

    drawBackground(&pCache, w, height);

    if(mShowThinFrame) {
      drawThinFrame(&pCache, w, height);
      //We have a 'frame' in the bottom and right - so subtract them from the view
      h--;
      w--;
      pCache.setClipRect( 0, 0, w, height-1 );
    }
    
    if(showTopBar) { 
      int seperatorX = w / 2;
      drawTopBarFrame(&pCache, w, seperatorX, top);
    }

    /* Draw scope-like grid vertical lines if it doesn't move.  If it does move, draw it in the dynamic part of the code*/
    if(!mVerticalLinesScroll && mShowVerticalLines && w > 60)
      drawVerticalLines(&pCache, top, w, h);

    if ( mShowHorizontalLines ) 
      drawHorizontalLines(&pCache, top, w, h);
  
  } else {
    if(mShowThinFrame) {
      //We have a 'frame' in the bottom and right - so subtract them from the view
      h--;
      w--;
   }  
  }
  p->drawImage(0,0, mBackgroundImage);
  p->setRenderHint(QPainter::Antialiasing, true);

  if ( showTopBar ) {
    int seperatorX = w / 2;
    int topBarWidth = w - seperatorX -2;
    drawTopBarContents(p, seperatorX, topBarWidth, top -1);
  }

  p->setClipRect( 0, top, w, h);
  /* Draw scope-like grid vertical lines */
  if ( mVerticalLinesScroll && mShowVerticalLines && w > 60 )
    drawVerticalLines(p, top, w, h);

  drawBeams(p, top, w, h, horizontalScale);

  if( mShowLabels && w > 60 && h > ( fontheight + 1 ) )   //if there's room to draw the labels, then draw them!
    drawAxisText(p, top, h);

}