Пример #1
0
void presentMenu()
{
    printf("What would you like to draw? (type in an integer)\n");
    printf("1. Square\n");
    printf("2. Triangle\n");
    printf("3. Star\n");
    printf("4. Circle\n");
    
    int input;
    scanf("%i", &input);
    
    double size = 1.0;
    
    printf("Drawing..\n");
    
    switch (input) {
        case 1:
            drawSquare(size);
            break;
        case 2:
            drawTriangle(size);
            break;
        case 3:
            drawStar(size);
            break;
        case 4:
            drawCircle(size);
            break;
        default:
            break;
    }
    
    printf("Done!\n\n");
}
Пример #2
0
void renderScene(void) {

	// Clear Color and Depth Buffers
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    // Reset transformations
	glLoadIdentity();
	// Set the camera
	gluLookAt(	x, 1.0f, z,
			x+lx, 1.0f,  z+lz,
			0.0f, 1.0f,  0.0f);

        // Draw 1 Solar
	for(int i = 0; i < 1; i++)
		for(int j=0; j < 1; j++) {
			glPushMatrix();
			glTranslatef(i*10.0,0,j * 10.0);
			drawSolar();
			glPopMatrix();
		}

       // for Star
	for(int i = -1; i < 3; i++)
		for(int j=-1; j < 3; j++) {
			glPushMatrix();
			glTranslatef(i*10.0,0,j * 10.0);
			drawStar();
			glPopMatrix();
		}

	glutSwapBuffers();
}
Пример #3
0
void ItemUser::paint( QPainter *painter, const QStyleOptionViewItem &option) const
{
   drawBack( painter, option);
   int x = option.rect.x() + 5;
   int y = option.rect.y() + 2;
   int w = option.rect.width() - 10;
   int h = option.rect.height() - 4;
   int height_user = HeightUser-4;

   painter->setPen( clrTextMain( option) );
   if( permanent) painter->setFont( afqt::QEnvironment::f_name);
   else           painter->setFont( afqt::QEnvironment::f_info);
   painter->drawText( x, y, w, h, Qt::AlignLeft | Qt::AlignTop,     strLeftTop);

   painter->setPen( clrTextInfo( option) );
   painter->setFont( afqt::QEnvironment::f_info);
   painter->drawText( x, y, w, height_user, Qt::AlignLeft    | Qt::AlignBottom,  strLeftBottom  );
   painter->drawText( x, y, w, height_user, Qt::AlignHCenter | Qt::AlignTop,     strHCenterTop  );
   painter->drawText( x, y, w, height_user, Qt::AlignRight   | Qt::AlignBottom,  strRightBottom );
   painter->setPen( afqt::QEnvironment::qclr_black );
   painter->drawText( x, y, w, height_user, Qt::AlignRight   | Qt::AlignTop,     strRightTop    );

   if( false == annotation.isEmpty())
      painter->drawText( x, y, w, h, Qt::AlignBottom | Qt::AlignHCenter, annotation );

   {  // draw stars:
      static const int stars_size = 8;
      static const int stars_height = 21;
      static const int stars_left = 35;
      static const int stars_maxdelta = stars_size * 2 + 5;

      int quantity = numrunningtasks;
      //quantity = 155;

      if( quantity > 0)
      {
         int numstars = quantity;
         int stars_right = w - 50;
         int stars_delta = (stars_right - stars_left) / numstars;
         if( stars_delta < 1 )
         {
            stars_delta = 1;
            numstars = stars_right - stars_left;
         }
         else if( stars_delta > stars_maxdelta ) stars_delta = stars_maxdelta;
         int sx = x + stars_left;
         for( int j = 0; j < numstars; j++)
         {
            drawStar( stars_size, sx, y + stars_height, painter);
            sx += stars_delta;
         }

         painter->setFont( afqt::QEnvironment::f_name);
         painter->setPen( afqt::QEnvironment::clr_textstars.c);
         painter->drawText( x, y, w, HeightUser, Qt::AlignHCenter | Qt::AlignBottom, QString::number(numrunningtasks));
      }
   }

   drawPost( painter, option);
}
Пример #4
0
/**\brief Draws the Starfield
 */
void Starfield::Draw( void ) {
	int i;

	for( i = 0; i < num; i++ ) {
		drawStar(stars[i].x, stars[i].y, stars[i].clr);
	}
}
Пример #5
0
static void display(void)
{
 		
 		drawStar();
		glRotatef(theta[0]/10, 1.0, 0.0, 0.0);
		glRotatef(theta[1]/10, 0.0, 1.0, 0.0);
		glRotatef(theta[2]/10, 0.0, 0.0, 1.0);		
}
Пример #6
0
/* draw 3 Stars in a circle centered at center */
void drawStars(float *center)
{
	double pi= 3.14159;
	int radius= 75;

	 for (double angle =0; angle < 2*pi; angle = angle + (pi/1.5))
	 {
		drawStar(center[0]+sin(angle)*radius, center[1]+cos(angle)*radius);
	 }	 
	
}
Пример #7
0
void display() {

    glClear(GL_COLOR_BUFFER_BIT);

    drawLine(0,0,540,540, 40, 40, 40);

    rotateHouse();

    drawPlanet(380, 380, 70,  0,   100, 255);       //земля
    drawPlanet(540, 540, 20,  127, 127, 127);      //луна
    drawPlanet(-99, -99, 400, 255, 255, 0);       //солнце

    drawStar(30,  500);
    drawStar(240, 400);
    drawStar(350, 680);
    drawStar(400, 600);
    drawStar(580, 100);
    drawStar(600, 300);



    glFlush();
    glFinish();

}
Пример #8
0
void drawScene()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    // Reset transformations
    glLoadIdentity();

    // look at the origin spot (0,0,0) from camera position, moved by mouse
    gluLookAt(	startX+deltaX, startY+deltaY, startZ+deltaZ, //camera pos
                0.0, 0.0,   0.0, //looking at
                0.0, 1.0,   0.0); //up orientation

    // draw model elements (stars and planet)
    drawStar(&universe);
    drawStar(&sun);
    drawPlanet(&p1);
    drawPlanet(&p2);
    drawPlanet(&p3);
    drawPlanet(&p4);
    drawPlanet(&p5);
    drawPlanet(&p6);
    drawPlanet(&p7);
    drawPlanet(&p8);

    // draw time
    char time[10000];
    int int_hours = (int)(hours);
    int int_days = int_hours/24;
    int int_years = int_days/365;
    sprintf(time, "Time:\tY-%d\tD-%d\tH-%d", int_years, int_days%365, int_hours%24);
    draw2DText(1.0,GLUT_WINDOW_HEIGHT*1.89, time);

    // draw legend
    char legend[10000];
    sprintf(legend, "\"ESC\" for exit, \"t\" for planet label, \"s\" for step animation, \"r\" for running animation, Mouse moves camera (wheel or ctrl | shift | alt for zoom) ");
    draw2DText(1.0, 1.0, legend);

    glFlush();
    glutSwapBuffers();
}
Пример #9
0
void switchShape(int shape){
  switch ( shape ) 
  {
    case 0:        
      drawTriangles();  
      break;

    case 1:
      drawSquares();
      break;

    case 2:
      drawStar();
      break;

    default:
      break;
  }
}
Пример #10
0
int main()
{
	int N;
	scanf("%d", &N);

	// init
	for (int i=0; i<N; i++)
		for (int j=0; j<N; j++)
			star[i][j] = '*';

	// draw
	drawStar(N, 0, 0);

	// print
	for (int i = 0; i<N; i++) {
		for (int j = 0; j<N; j++)
			printf("%c", star[i][j]);
		printf("\n");
	}

	return 0;
}
Пример #11
0
void Starfield::draw()
{
	clear_screen(0);

	foreach (Star& star, stars)
	{
		if (star.z <= movementSpeed)
		{
			star = newStar();
		}
		else
		{
			const int scrX = star.x / static_cast<signed>(star.z) + scr_width / 2;
			const int scrY = star.y / static_cast<signed>(star.z) + scr_height / 2;
			const Uint8 drawColor = color + ((star.z / 16) & 0x1F);

			drawStar(scrX, scrY, drawColor, VGAScreen);

			star.z -= movementSpeed;
		}
	}

	if (!helpText.empty())
	{
		if (showHelp)
			drawHelp();
		else
			JE_outText(4, 4, "F1: Help", 1, 0);
	}

	if (messageDisplayTime > 0)
	{
		JE_outText(JE_fontCenter(message, TINY_FONT), 4, message, fadeColors(messageDisplayTime, MESSAGE_TIME, 2, 8, 11), 4);

		--messageDisplayTime;
	}

	pattern->step(speed, speed2);
}
Пример #12
0
void drawStar(int n, int x, int y)
{
	if (n <= 1) {
		return;
	}

	int a, b;

	// 9등분. 
	// top-left 좌표를 기준. 
	for (int i=0; i<3; i++) {
		for (int j=0; j<3; j++) {
			a = x + n/3*i;
			b = y + n / 3 * j;
			if (i == 1 && j == 1) 
				for (int c = 0; c<n/3; c++)
					for (int d = 0; d<n/3; d++)
						star[a+c][b+d] = ' ';
			else
				drawStar(n/3, x+n/3*i, y+n/3*j);
		}
	}
}
Пример #13
0
void
draw_galaxy(ModeInfo * mi)
{
	Display    *display = MI_DISPLAY(mi);
	Drawable    drawable;
	GC          gc = MI_GC(mi);
	double      d;		/* tmp */
	int         i, j, k;	/* more tmp */
	unistruct  *gp;
	Bool        clipped;

	if (universes == NULL)
		return;
	gp = &universes[MI_SCREEN(mi)];
	if (gp->galaxies == NULL)
		return;

	if (gp->fisheye)
		drawable = (Drawable) gp->pixmap;
	else
		drawable = MI_WINDOW(mi);
	MI_IS_DRAWN(mi) = True;
	for (i = 0; i < gp->ngalaxies; ++i) {
		Galaxy     *gt = &gp->galaxies[i];

		for (j = 0; j < gp->galaxies[i].nstars; ++j) {
			Star       *st = &gt->stars[j];
			double      v0 = st->vel[0];
			double      v1 = st->vel[1];
			double      v2 = st->vel[2];

			for (k = 0; k < gp->ngalaxies; ++k) {
				Galaxy     *gtk = &gp->galaxies[k];
				double      d0 = gtk->pos[0] - st->pos[0];
				double      d1 = gtk->pos[1] - st->pos[1];
				double      d2 = gtk->pos[2] - st->pos[2];

				d = d0 * d0 + d1 * d1 + d2 * d2;
				if (d > EPSILON)
					d = gt->mass / (d * sqrt(d)) * DELTAT * DELTAT * QCONS;
				else
					d = gt->mass / (EPSILON * sqrt_EPSILON) * DELTAT * DELTAT * QCONS;
				v0 += d0 * d;
				v1 += d1 * d;
				v2 += d2 * d;
			}

			st->vel[0] = v0;
			st->vel[1] = v1;
			st->vel[2] = v2;

#ifndef NO_VELOCITY_COLORING
			d = (v0 * v0 + v1 * v1 + v2 * v2) / (3.0 * DELTAT * DELTAT);
			if (d > (double) COLORBASE)
				st->color = gt->galcol + COLORBASE - 1;
			else
				st->color = gt->galcol + ((int) d) % COLORBASE;
#endif
			st->pos[0] += v0;
			st->pos[1] += v1;
			st->pos[2] += v2;

			clipped = True;
			if (gp->fisheye) {
/* clip if star Z position < 0.0 - also avoid divide by zero errors */

			if(st->pos[2]>0.0)
			{
			st->px = (int) ((st->pos[0] * gp->scale) / st->pos[2]) + gp->midx;
			st->py = (int) ((st->pos[1] * gp->scale) / st->pos[2]) + gp->midy;
			st->size = (int) (gp->star_scale_Z / st->pos[2]) + st->Z_size;
			if(st->size>12)st->size=12;
			clipped = False;
			}
			} else {

			if (st->px >= gp->clip.left &&
			    st->px <= gp->clip.right - st->size &&
			    st->py >= gp->clip.top &&
			    st->py <= gp->clip.bottom - st->size) {
				XSetForeground(display, gc, MI_BLACK_PIXEL(mi));
				drawStar(st->px, st->py, st->size);
			}
			st->px = (int) (st->pos[0] * gp->scale) + gp->midx;
			st->py = (int) (st->pos[1] * gp->scale) + gp->midy;


#ifdef WRAP /* won't WRAP if FISHEYE_LENS */
			if (st->px < gp->clip.left) {
				(void) printf("wrap l -> r\n");
				st->px = gp->clip.right;
			}
			if (st->px > gp->clip.right) {
				(void) printf("wrap r -> l\n");
				st->px = gp->clip.left;
			}
			if (st->py > gp->clip.bottom) {
				(void) printf("wrap b -> t\n");
				st->py = gp->clip.top;
			}
			if (st->py < gp->clip.top) {
				(void) printf("wrap t -> b\n");
				st->py = gp->clip.bottom;
			}
#endif /*WRAP */


			if (st->px >= gp->clip.left &&
			    st->px <= gp->clip.right - st->size &&
			    st->py >= gp->clip.top &&
				 st->py <= gp->clip.bottom - st->size) {
			clipped = False;
			}
			}
			if (!clipped) {

				if (MI_NPIXELS(mi) >= COLORS) {
#ifdef NO_VELOCITY_COLORING
					XSetForeground(display, gc, MI_PIXEL(mi, gt->galcol));
#else
					XSetForeground(display, gc, MI_PIXEL(mi, st->color));
#endif
				} else 
					XSetForeground(display, gc, MI_WHITE_PIXEL(mi));
				if (gp->tracks) {
					drawStar(st->px + 1, st->py, st->size);
				} else {
					drawStar(st->px, st->py, st->size);
				}
			}
		}

		for (k = i + 1; k < gp->ngalaxies; ++k) {
			Galaxy     *gtk = &gp->galaxies[k];
			double      d0 = gtk->pos[0] - gt->pos[0];
			double      d1 = gtk->pos[1] - gt->pos[1];
			double      d2 = gtk->pos[2] - gt->pos[2];

			d = d0 * d0 + d1 * d1 + d2 * d2;
			if (d > EPSILON)
				d = gt->mass * gt->mass / (d * sqrt(d)) * DELTAT * QCONS;
			else
				d = gt->mass * gt->mass / (EPSILON * sqrt_EPSILON) * DELTAT * QCONS;
			d0 *= d;
			d1 *= d;
			d2 *= d;
			gt->vel[0] += d0 / gt->mass;
			gt->vel[1] += d1 / gt->mass;
			gt->vel[2] += d2 / gt->mass;
			gtk->vel[0] -= d0 / gtk->mass;
			gtk->vel[1] -= d1 / gtk->mass;
			gtk->vel[2] -= d2 / gtk->mass;
		}
		gt->pos[0] += gt->vel[0] * DELTAT;
		gt->pos[1] += gt->vel[1] * DELTAT;
		gt->pos[2] += gt->vel[2] * DELTAT;
	}

	if (gp->fisheye) {
		XCopyArea(display, drawable, MI_WINDOW(mi), gc,
			0, 0, MI_WIDTH(mi), MI_HEIGHT(mi),0 , 0);

		XSetForeground(display, gc, MI_BLACK_PIXEL(mi));

		XFillRectangle(display, drawable, gc,
			0, 0, MI_WIDTH(mi), MI_HEIGHT(mi));
	}
	gp->step++;
	if (gp->step > gp->f_hititerations * 4)
		(void) startover(mi);
}
Пример #14
0
void MidasGL::paintGL()
{
  int xdrawn, ydrawn;
  float xcut, ycut;
  double angle, tcrit;
  int i, nControl;
  int numlines = 2;
  float xcen, ycen, boxXcen, boxYcen;
  bool boxCenSet = false;
  float zoom = VW->truezoom;
  float censize = 7.;
  float *xControl, *yControl, *xVector, *yVector;

  midas_clear();

  /* DNM 2/5/01: set sdatSize here.  This may be redundant now that the
     expose_cb tests correctly for need for new array */
  if (!VW->sdat) {
    VW->sdat = (b3dUInt32 *)
      malloc( VW->width * VW->height * sizeof(b3dUInt32));
    VW->sdatSize = VW->width * VW->height;
  }

  draw_image(VW, VW->id, 0, 0, VW->width, VW->height, &xdrawn, &ydrawn);
     
  if (VW->paramstate[2] < 1.0001 && VW->paramstate[2] > 0.9999)
    numlines = 1;

  if (VW->showref)
    numlines = 0;
  else {

    if (!(VW->curWarpFile >= 0 && VW->editWarps)) {

      // If not in warp mode, draw the center of action and the possible fixed point
      xcen = zoom * VW->xcenter + VW->xoffset;
      ycen = zoom * VW->ycenter + VW->yoffset;
      glColor3f(1.0f, 1.0f, 0.0f);
      drawStar(xcen, ycen, censize);
      if (VW->useFixed) {
        xcen = zoom * VW->xfixed + VW->xoffset;
        ycen = zoom * VW->yfixed + VW->yoffset;
        glColor3f(1.0f, 0.0f, 0.0f);
        drawStar(xcen, ycen, censize);
      }
    }
  }

  // If there are control points, draw them
  i = VW->numChunks ? VW->curChunk : VW->cz;
  if (VW->curWarpFile >= 0 && i < VW->warpNz && !getNumWarpPoints(i, &nControl)) {
    if (nControl && !getWarpPointArrays(i, &xControl, &yControl, &xVector, &yVector)) {
      for (i = 0; i < nControl; i++) {
        //printf("%d %f %f %f %f\n", i, xControl[i], yControl[i], xVector[i], yVector[i]);
        xcen = zoom * xControl[i] / VW->warpScale + VW->xoffset;
        ycen = zoom * yControl[i] / VW->warpScale + VW->yoffset;
        glColor3f(1.0f, (VW->editWarps && i == VW->curControl) ? 1.f : 0.f, 0.0f);
        drawStar(xcen, ycen, censize);
        if (VW->drawVectors) {
          glBegin(GL_LINES);
          glVertex2f(xcen, ycen);
          glVertex2f(xcen - zoom * xVector[i] / VW->warpScale, 
                     ycen - zoom * yVector[i] / VW->warpScale);
          glEnd();
        }
        if (i == VW->curControl) {
          boxXcen = xcen;
          boxYcen = ycen;
          boxCenSet = true;
        }
      }
    }
  }
     
  // On the first draw, update parameter display
  // 12/7/03, move up above drawing of stretch line so it is correct
  if (!VW->exposed)
    VW->midasSlots->update_parameters();

  /* First line is for the defined stretch angle */
     
  tcrit = atan(((double)ydrawn)/xdrawn);
  glEnable(GL_LINE_STIPPLE);
  glLineStipple(10,0x5555);
     
  glColor3f(1.0f, 0.0f, 0.0f);
  angle = 0.1 * VW->sangle * RADIANS_PER_DEGREE;

  for (i = 0; i < numlines; i ++) {
    if (angle > tcrit || angle < -tcrit) {
      ycut = ydrawn / 2.;
      xcut = ycut * cos(angle) / sin(angle);
    } else {
      xcut = xdrawn / 2.;
      ycut = xcut * tan(angle);
    }
    glBegin(GL_LINES);
    glVertex2f(VW->width / 2. - xcut, VW->height / 2. - ycut);
    glVertex2f(VW->width / 2. + xcut, VW->height / 2. + ycut);
    glEnd();

    /* now actual stretch axis, conditional on existence of stretch */
    glColor3f(0.0f, 0.4f, 1.0f);
    angle = VW->phi * RADIANS_PER_DEGREE;
  }

  if (VW->drawCorrBox) {
    glColor3f(VW->drawCorrBox > 1 ? 1.0f : 0.f, 
              VW->drawCorrBox < 3 ? 1.0f : 0.0f, 0.0f);
    if (!boxCenSet) {
      boxXcen = zoom * VW->xcenter + VW->xoffset;
      boxYcen = zoom * VW->ycenter + VW->yoffset;
    }
    xcut = zoom * VW->corrBoxSize / 2.;
    glBegin(GL_LINE_STRIP);
    glVertex2f(boxXcen - xcut, boxYcen - xcut);
    glVertex2f(boxXcen - xcut, boxYcen + xcut);
    glVertex2f(boxXcen + xcut, boxYcen + xcut);
    glVertex2f(boxXcen + xcut, boxYcen - xcut);
    glVertex2f(boxXcen - xcut, boxYcen - xcut);
    glEnd();
    VW->drawCorrBox = 0;
  }

  glFlush();

  VW->exposed = 1;
}
Пример #15
0
 virtual void draw() { drawStar(); }
Пример #16
0
void CStarCrosshairs::selectStar(int index, CVideoSurface *surface,
		CStarField *starField, CStarMarkers *markers) {
	if (_entryIndex >= 0) {
		// There are existing selected stars already
		if (_entryIndex == _matchIndex) {
			// All the stars selected so far have been matched. Only allow
			// a selection addition if not all three stars have been found
			if (!isSolved()) {
				// Don't allow the most recent match or the one before
				// it to be re-selected (while they are locked/matched)
				if (_positions[index] != _entries[_entryIndex]) {
					if (_entryIndex == 1) {
						// 2 stars are matched
						if (_positions[index] == _entries[_entryIndex - 1])
							return;
					}

					surface->lock();

					// Draw crosshairs around the selected star
					CSurfaceArea surfaceArea(surface);
					drawStar(index, &surfaceArea);
					surface->unlock();

					// Copy the star into the list of selected ones
					++_entryIndex;
					CStarPosition &newP = _entries[_entryIndex];
					newP = _positions[index];

					// Set up a marker in the main starfield for that same star
					const CBaseStarEntry *starP = starField->getDataPtr(newP._index1);
					markers->addStar(starP);
				}
			}
		} else if (_entryIndex == _matchIndex + 1) {
			// There is a most recently selected star that has not yet been matched.
			// So we allow the user to reselect it to remove the selection, or shift
			// the selection to some other star
			if (_positions[index] == _entries[_entryIndex]) {
				// Player has selected the most recent star
				// Remove the crosshairs for the previously selected star
				surface->lock();
				CSurfaceArea surfaceArea(surface);
				eraseCurrent(&surfaceArea);
				surface->unlock();

				// Decrement number of selections
				--_entryIndex;

				// Call the markers addStar method, which will remove the existing marker
				const CBaseStarEntry *starP = starField->getDataPtr(_positions[index]._index1);
				markers->addStar(starP);
			} else {
				// Player has selected some other star other than the most recent
				// Remove/Add it if it is not one of the other star(s) already matched

				// Check that it is not a previously star and don't remove it if it is
				for (int i = 0; i < _entryIndex; ++i) {
					if (_positions[index] == _entries[i])
						return;
				}

				// Erase the prior selection and draw the new one
				surface->lock();
				CSurfaceArea surfaceArea(surface);
				eraseCurrent(&surfaceArea);
				drawStar(index, &surfaceArea);
				surface->unlock();

				// Remove the old selection from the starfield markers
				const CBaseStarEntry *starP;
				starP = starField->getDataPtr(_entries[_entryIndex]._index1);
				markers->addStar(starP);

				// Add the new selection to the markers list
				starP = starField->getDataPtr(_positions[index]._index1);
				markers->addStar(starP);

				// Copy the newly selected star's details into our selections list
				CStarPosition &newP = _entries[_entryIndex];
				newP = _positions[index];
			}
		}
	} else {
		// Very first star being selected
		// Draw crosshairs around the selected star
		surface->lock();
		CSurfaceArea surfaceArea(surface);
		drawStar(index, &surfaceArea);
		surface->unlock();

		// Copy the star into the list of selected ones
		++_entryIndex;
		const CStarPosition &srcPos = _positions[index];
		CStarPosition &destPos = _entries[_entryIndex];
		destPos = srcPos;

		// Set up a marker in the main starfield for that same star
		const CBaseStarEntry *starP = starField->getDataPtr(destPos._index1);
		markers->addStar(starP);
	}
}
Пример #17
0
 virtual void draw() { drawLight(); drawPlanet(); drawStar(); }