Esempio n. 1
0
int display_raw(void* data, int heigth, int width, int bsize, color_t
color)
{
	printf("bsize = %d, col=%d\n", bsize, color);
	if(SDL_Init(SDL_INIT_VIDEO) != 0){
		printf("SDL fail\n");
		return -1;
	};

	SDL_Surface *disp;

	disp = SDL_SetVideoMode(20*width,
							20*heigth,
						 32,
						 (SDL_HWSURFACE|SDL_DOUBLEBUF));

	if(!disp){
		printf("set video fail\n");
// 		return -1;
	};


	SDL_Surface *im;

	im = SDL_CreateRGBSurface(0,
							  width,
							  heigth,
						      32,
							  0,0,0,0);
	if(!im)
		printf("create fail\n");

	int x,y;
	uint8_t px[4];

	for(y=0; y<heigth; y++){
		for(x=0; x<width; x++){
			if(color == 1){
				memset(&px[1], *((uint8_t *)data), 4);
				data += bsize >> 3; //TODO this
			}
			else{
				memcpy(&px, (uint8_t *)data, 3);
				data += (bsize*color) >> 3;
			}

			putpixel(im, x, y, *(uint32_t *)px);
		}
Esempio n. 2
0
/* worker function for changing the type of an image */
static int do_changetype(DATAFILE *dat, int *param, int type)
{
   BITMAP *bmp;
   RLE_SPRITE *spr;
   int x, y, c, r, g, b;

   if ((dat->type != DAT_BITMAP) && (dat->type != DAT_RLE_SPRITE) &&
       (dat->type != DAT_C_SPRITE) && (dat->type != DAT_XC_SPRITE)) {
      (*param)++;
      return D_O_K;
   }

   if (dat->type == type)
      return D_O_K;

   if (dat->type == DAT_RLE_SPRITE) {
      spr = (RLE_SPRITE *)dat->dat;
      bmp = create_bitmap_ex(spr->color_depth, spr->w, spr->h);
      clear_to_color(bmp, bmp->vtable->mask_color);
      draw_rle_sprite(bmp, spr, 0, 0);
      dat->dat = bmp;
      destroy_rle_sprite(spr);
   }
   else if (type == DAT_RLE_SPRITE) {
      bmp = (BITMAP *)dat->dat;
      spr = get_rle_sprite(bmp);
      dat->dat = spr;
      destroy_bitmap(bmp);
   }
   else if ((type == DAT_C_SPRITE) || (type == DAT_XC_SPRITE)) {
      bmp = (BITMAP *)dat->dat;
      if (bitmap_color_depth(bmp) == 32) {
	 for (y=0; y<bmp->h; y++) {
	    for (x=0; x<bmp->w; x++) {
	       c = getpixel(bmp, x, y);
	       r = getr32(c);
	       g = getg32(c);
	       b = getb32(c);
	       putpixel(bmp, x, y, makecol32(r, g, b));
	    }
	 }
      }
   }

   dat->type = type;

   return D_REDRAW;
}
void bezier::detectallpt()
{
	int i,j,xcnt=0;

	int minx,miny,maxx,maxy;

	minx = maxx = ax[0];
	miny = maxy = ay[0];

	jblx = new int [cnt];
	jbly = new int [cnt];


	for(i=1;i<4;i++)
	{
		if(minx>ax[i])
			minx = ax[i];
		if(maxx<ax[i])
			maxx = ax[i];

		if(miny>ay[i])
			miny = ay[i];
		if(maxy<ay[i])
			maxy = ay[i];

	}

	for(i=miny-4;i<=479/*maxy+4*/;i++)
	{
		for(j=minx-4;j<=639/*maxx+4*/;j++)
		{
			if(WHITE == getpixel(i,j))
			{
				jblx[xcnt] = i;
				jbly[xcnt] = j;
				putpixel(i,j,YELLOW);
				xcnt++;
			}
		}
	}

	if(xcnt!=cnt)
	{
		cout<<"XCNT = "<<xcnt<<" and CNT = "<<cnt;
		getch();
	}

}
Esempio n. 4
0
void circular(int h,int k,int rx,int ry,int s,int e)
{
	float angle=((s<=e)?s:e)*((M_PI)/180);
	float range=((e>s)?e:s)*((M_PI)/180);

	float x=rx*cos(angle);
	float y=ry*sin(angle);

	do{
	putpixel((int)(h+x+0.5),(int)(k-y+0.5),RED);
	angle+=0.01;
	x=rx*cos(angle);
	y=ry*sin(angle);

	}while(angle<=range);
}
Esempio n. 5
0
void ffill4(int x,int y,int fcolor,int ocolor)
 {
          int current;
          current = getpixel(x,y);
          
          if(current == ocolor)
          {
               putpixel(x,y,fcolor);
               
                ffill4(x+1,y,fcolor,ocolor);
               ffill4(x-1,y,fcolor,ocolor);
               ffill4(x,y+1,fcolor,ocolor);
               ffill4(x,y-1,fcolor,ocolor);
               
          }
 }
Esempio n. 6
0
    void OpenLayerImage::putPixel(int x, int y, const Color& color)
    {
        if (mAllegroBitmap == NULL && mOpenLayerBitmap == NULL)
        {
            throw FCN_EXCEPTION("Trying to put a pixel in a non loaded image.");
        }

        if (mAllegroBitmap == NULL)
        {
            return;
        }

        int c = makeacol_depth(32, color.r, color.g, color.b, color.a);

        putpixel(mAllegroBitmap, x, y, c);
    }
Esempio n. 7
0
void
eksplozija(int i)
{		
		int j;
		float fi;
		
		for(j=0;kratr[j]!=-1;j++)	//poisce mesto za krater
			;
		kratr[j]=kgl[i].x;		//kjer kgla pade je nov kratr
		putpixel(screen,kgl[i].dx,kgl[i].dy,0);//zbrise zadnjo kgl			
		zmaga(j);			//pogleda ce je kdo zmagu
		krater();			//narise vse kraterje
		//play_sample(blast, 255, 255-(kgl[i].x/SIRINA*255),
		//	     1000, 0); 		//bummm
		kgl[i].t=-1;			//kugla se resetira
}		
Esempio n. 8
0
void boundaryFill(int x, int y, int bc, int fc)  // 4-connected (8-connected not possible)
{
	int color = getpixel(x,y);
	if((color!=bc)&&(color!=fc))
	{
		putpixel(x,y,fc);
		//delay(1);

		boundaryFill(x+1,y,bc,fc);    // right
		boundaryFill(x,y+1,bc,fc);    // top
		boundaryFill(x-1,y,bc,fc);    // left
		boundaryFill(x,y-1,bc,fc);    // bottom
	}
	else
		return;
}
Esempio n. 9
0
int drawchar(int ch, int x, int y)
{
	int i, j, maxx = 0;
	for (i = 0; i < 16; i++)
	{
		for (j = 0; j < 16; j++)
		{
			if (((char*)font->pixels)[((ch-32)*16+i)*16+j])
			{
				putpixel(x+j,y+i,0xffffffff);
				if (j > maxx) maxx = j;
			}
		}
	}
	return maxx + 1;
}
Esempio n. 10
0
void bezier_test(float t, int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3)
{
	float cx = 3 * (x1 - x0);
	float bx = 3 * (x2 - x1) - cx;
	float ax = x3 - x0 - cx - bx;
	float cy = 3 * (y1 - y0);
	float by = 3 * (y2 - y1) - cy;
	float ay = y3 - y0 - cy - by;
	float tCubed = t * t * t;
	float tSquared = t * t;
	float resultX = (ax * tCubed) + (bx * tSquared) + (cx * t) + x0;
	float resultY = (ay * tCubed) + (by * tSquared) + (cy * t) + y0;

	putpixel(screen, (int)resultX, (int)resultY, makecol(255,0,0));

}
Esempio n. 11
0
File: spline.c Progetto: ifilex/SRC
/* spline:
 *  Draws a bezier spline onto the specified bitmap in the specified color.
 */
void spline(BITMAP *bmp, int points[8], int color)
{
   #define NPTS   64

   int xpts[NPTS], ypts[NPTS];
   int i;

   calc_spline(points, NPTS, xpts, ypts);

   for (i=1; i<NPTS; i++) {
      line(bmp, xpts[i-1], ypts[i-1], xpts[i], ypts[i], color);

      if (_drawing_mode == DRAW_MODE_XOR)
	 putpixel(bmp, xpts[i], ypts[i], color);
   }
}
Esempio n. 12
0
void DrawSphere(SDL_Surface* screen, Sphere s, int width, int height, LightSource light)
{
	for (int x=0;x<width;x++) for (int y=0;y<height;y++)
	{
		if (x>width/2+70) if (y>height/2+20) 
			s=s;
		Vector sol = Solution(Vector(x-width/2,1000,y-height/2),Vector(0,0,0),s);
		if (sol!=Vector(0,0,0))
		{
			Color c1=s.color_;
			putpixel(screen,x,y,Shadow(light,sol,s).GetUint32());
			SDL_UpdateRect(screen,x,y,1,1);
		}
	}
	//SDL_UpdateRect(screen,0,0,1024,600);
}
// int main (int argc, char **argv)
void main ()
{
	int x,y;
	for (y=128;y<256;++y) {
		for (x=0;x<320;++x) {
			#define scry (y-127)
			#define scrx (x-160)
			int wz = PLANE_DEPTH * FOCAL_DIST / scry;
			// int wx = scrx * wz / FOCAL_DIST;
			int wx = PLANE_DEPTH * scrx / scry;
			// putpixel(x,y,1 + ((abs(wx/GRID_SIZE)+wz/GRID_SIZE)%2));
			putpixel(x, y, ( ((wx/GRID_SIZE)&3) == 2 ? 1 : 0 ) + ( ((wz/GRID_SIZE)&3) == 0 ? 2 : 0 ) );
			// putpixel(x,y,1 + (((wx+wz) >> 5) & 1)); // not working right
		}
	}
}
void ghost::drawghost(int x,int y)
{
	int i;

	setcolor(DARKGRAY);
	setfillstyle(SOLID_FILL,DARKGRAY);

	//head

	circle(x,y,r);
	fillellipse(x,y,r,r);  // to fill the head of ghost

	//body frame
	for(i=x-r/2;i<=x+r/2;i++)  // "i" is the vertical line being chosen (x coordinate)
	{
		line(i,y+r,i,y+r+lb);
	}

	//right arm       ....16 pixels down from the head
	for(i=0;i<wa;i++)     // "i" is the lateral line being chosen (y coordinate)
	{
		line(x+r/2,y+i+16,x+r/2+la,y+i+24);
	}

	//left arm      .... 16 pixels down from the head
	for(i=0;i<wa;i++)     // "i" is the lateral line being chosen (y coordinate)
	{
		line(x-r/2,y+i+16,x-r/2-la,y+i+24);
	}

	//right leg     ....4 pixels above the bottom of the body
	for(i=0;i<wl;i++)
	{
		line(x,y+r+lb+i-8,x+ll,y+r+lb+i+10);
	}

	//left leg     ....4 pixels above the bottom of the body
	for(i=0;i<wl;i++)
	{
		line(x,y+r+lb+i-8,x-ll,y+r+lb+i+10);
	}

	//eyes
	putpixel(x-r/2,y-r/2,LIGHTGRAY);
	putpixel(x+r/2,y-r/2,LIGHTGRAY);
	putpixel(x-r/2-1,y-r/2,LIGHTGRAY);
	putpixel(x+r/2+1,y-r/2,LIGHTGRAY);
	putpixel(x-r/2,y-r/2+1,LIGHTGRAY);
	putpixel(x+r/2,y-r/2+1,LIGHTGRAY);

	//to draw the nose
	setcolor(LIGHTGRAY);
	line(x,y-2,x,y+2);

}
Esempio n. 15
0
//draw julia set
void draw_julia(Screen* screen) {
	//each iteration, we calculate: new = old * old + c
	//c is constant
	//old starts at current pixel
	double cRe, cIm; //real and imaginary parts of c
	double new_re, new_im, old_re, old_im; //real and imaginary parts of new and old
	double zoom = 1, move_x = 0, move_y = 0;
	int max_iterations = 300; 

	//pick some values for constant c
	//determines shape
	//cRe = -0.7;
	cRe = -0.7;
	//cIm = 0.27015;
	cIm = -0.61841;

	int w = screen->window->size.width;
	int h = screen->window->size.height;

	//for every pixel
	for (int y = 0; y < h; y++) {
		for (int x = 0; x < w; x++) {
			//calculate real and imaginary part of z
			//based on pixel location and zoom and position values
			new_re = 1.5 * (x - w / 2) / (0.5 * zoom * w) + move_x;
			new_im = (y - h / 2) / (0.5 * zoom * h) + move_y;
			
			int i;
			for (i = 0; i < max_iterations; i++) {
				//remember value of previous iteration
				old_re = new_re;
				old_im = new_im;

				//the actual iteration, real and imaginary part are calculated
				new_re = old_re * old_re - old_im * old_im + cRe;
				new_im = 2 * old_re * old_im + cIm;

				//if point is outside the circle with radius 2: stop
				if ((new_re * new_re + new_im * new_im) > 4) break;
			}

			//Color color = color_make(180 * (i % max_iterations), 20 * (i % max_iterations), 100 * (i % max_iterations));
			Color color = color_make(i % max_iterations + 2, 0, 0);
			putpixel(screen, x, y, color);
		}
	}
}
Esempio n. 16
0
void writechar (int x, int y, char c, int cl)
{
  register int idx;
  register unsigned char *_font = (unsigned char*) &font[c-' '][0];
  XSetForeground(dis,gc,egacolors[cl]);
  for (idx=0; idx<8; idx++) {
    register unsigned char w = _font[idx];
    register unsigned int yidx = y+idx;
    if (w&128) putpixel (x+0, yidx);
    if (w&64)  putpixel (x+1, yidx);
    if (w&32)  putpixel (x+2, yidx);
    if (w&16)  putpixel (x+3, yidx);
    if (w&8)   putpixel (x+4, yidx);
    if (w&4)   putpixel (x+5, yidx);
    if (w&2)   putpixel (x+6, yidx);
    if (w&1)   putpixel (x+7, yidx);
  }
}
Esempio n. 17
0
void image_draw(int color, int iterations) {
	int px, py;
	
	x = 0;
	y = 0;
	for (i = 1; i <= iterations; i++) {
		j = (rand() % 32767);
		k = (j < p[0]) ? 0 :((j < p[1]) ? 1 : ((j < p[2]) ? 2 : 3));
		newx = (a[k]*x + b[k]*y + e[k]);
		y = (c[k]*x + d[k]*y + f[k]);
		x = newx;
		px = x*xscale + xoffset;
		py = (480 - y*yscale + yoffset);
		if ((px >= 0) && (px < 640) && (py >= 0) && (py < 480))
			putpixel(px, py, color);
	}
}
Esempio n. 18
0
File: key.c Progetto: quheng/fruit
int set_strengthright(int first) {
    static int angle=0,i,j,flag=1;
    if (first==0) {
        angle = 0;
        flag = 1 ;
        for (i=ps[1]; i<=ps[1]+length; i++)
            for (j=0; j<=CL; j++)     putpixel(i, PY+j, BLACK);
    }
    while (!bioskey(1)) {
        angle+=flag;
        if (angle==89)  flag=-1;
        if (angle==0 )  flag=1;
        draw_strengthR(angle,flag);
        for (i=0; i<80000; i++)delay(0.99999999999999994);
    }
    return angle;
}
Esempio n. 19
0
File: level.c Progetto: callaa/luola
static void draw_stars (SDL_Rect * cam, SDL_Rect * targ)
{
    int r, x, y;
    Uint8 *col;
    for (r = 0; r < sizeof(lev_stars)/sizeof(Star); r++) {
        x = cam->x + lev_stars[r].x;
        y = cam->y + lev_stars[r].y;
        col =
            (Uint8 *) lev_level.terrain->pixels +
            y * lev_level.terrain->pitch +
            x * lev_level.terrain->format->BytesPerPixel;
        if (x < lev_level.width && y < lev_level.height)
          if (lev_level.solid[x][y] == TER_FREE && col[0] < 5 && col[1] < 5 && col[2] < 5)
            putpixel (screen, targ->x + lev_stars[r].x,
                      targ->y + lev_stars[r].y, col_white);
    }
}
Esempio n. 20
0
static void
drawship(int x, int y) {
    int u, v;
    char c;

    x -= 8;
    y -= 8;

    for (u = 0; u < 16; u++)
        for (v = 0; v < 16; v++) {
            c = ship[u][v];

            /* transparency */
            if (c != 0)
                putpixel(u + x, v + y, c, virt);
        }
}
Esempio n. 21
0
void movemissile()
{     
     samExplosion2 = load_sample("C:\\Sanchit\\Game Pack\\Sprites\\explosion2.wav");
 
     int x = points[curpoint].x ;
     int y = points[curpoint].y ;
 
     scare_mouse();

     rectfill(buffer,x-6,y-3,x+6,y+1,BLACK);

     if (getpixel(screen,x,y) == GREEN)
     {  
            destroyed++;
            updatescore();
            rectfill(buffer, 2, 14, 636, 352, BLACK);
     }
     else
     {
          putpixel(buffer,x,y-3,SMOKE);
          circlefill(buffer,x,y,2,BLUE);
     }
         
     unscare_mouse();
     
     curpoint++;
     if (curpoint >= totalpoints)
     {        
          play_sample(samExplosion2, 128, 128, 1000, 0);
          destroyed++;

          explosion2(screen, x, y, BLACK);

          textout_ex( screen, font, "Game Over", 300, 230, makecol( 255, 0, 0), makecol( 0, 0, 0));       
          rest(2000);
          textprintf(screen,font,300,245,makecol(255,255,255), "Final Score=%d", score);
          rest(2000);
          
          stop_sample(samSong);
          stop_sample(samExplosion2);
          
          score=-1;
          
          openscreen();
     }
}
void hermite()
{
  double t;
  double a,b,c,d,x,y;
  line(getmaxx()/2,0,getmaxx()/2,getmaxy());
  line(0,getmaxy()/2,getmaxx(),getmaxy()/2);
  for(t=0;t<=1;t=t+0.001)
  {
    a=(2*t*t*t)-(3*t*t)+1;
    b=(-2*t*t*t)+(3*t*t);
    c=(t*t*t)-(2*t*t*t);
    d=(t*t*t)-(t*t);
    x=a*p[0][0]+b*p[1][0]+c*p[2][0]+d*p[3][0];
    y=a*p[0][1]+b*p[1][1]+c*p[2][1]+d*p[3][1];
    putpixel(x+getmaxx()/2,y+getmaxy()/2,RED);
  }
}
Esempio n. 23
0
void boundaryfill8(int x, int y, int fill, int boundary)
{
int current;
current = getpixel(x,y);
if(current!=boundary && current!=fill)
{
putpixel(x,y,fill);
boundaryfill8(x+1,y,fill,boundary);
boundaryfill8(x-1,y,fill,boundary);
boundaryfill8(x,y+1,fill,boundary);
boundaryfill8(x,y-1,fill,boundary);
boundaryfill8(x+1,y+1,fill,boundary);
boundaryfill8(x-1,y+1,fill,boundary);
boundaryfill8(x-1,y-1,fill,boundary);
boundaryfill8(x+1,y-1,fill,boundary);
}
}
Esempio n. 24
0
void draw()
{
	int		i;
	char	*p = new char[100];

	gets( stream );

	for( i = 1; i < _argc; i++ )
	{
		sscanf( stream, "%s", p );
		strcpy( stream, stream+strlen( p ) );
		if ( stream[0] == ' ' )
			strcpy( stream, stream+1 );
		if ( strstr( "1234567" , _argv[i] ) != NULL )
			putpixel( px, 200-200.0*atof( p ), atoi( _argv[i] ));
	}
}
Esempio n. 25
0
void polygon::bres(int x1,int y1,int x2,int y2)        //Line drawing by bresenhams
{

int dx,dy,exchange,i,s1,s2,x,y,temp,g;
 dx=abs(x2-x1);
 dy=abs(y2-y1);

 s1=sign(x2-x1);
 s2=sign(y2-y1);

 x=x1;
 y=y1;
 if(dy>=dx)
 {
  temp=dy;
  dy=dx;
  dx=temp;
  exchange=1;
 }
 else
 exchange=0;

 g=2*dy-dx;
 for(i=1;i<dx;i++)
 {
  putpixel(x,y,WHITE);
  delay(10);

  while(g>=0)
  {
   if(exchange==1)
   x=x+s1;
   else
   y=y+s2;

   g=g-2*dx;
  }
  if(exchange==1)
  y=y+s2;
  else
  x=x+s1;
  g=g+2*dy;

}
}
Esempio n. 26
0
// Very, very slow ;p
void DrawMode7Stretched(BITMAP *target,
	BITMAP *bitmap,
	float angle,
	float cameraX,
	float cameraY,
	Params params,
	int backgroundColor
	)
{
	int screenX, screenY;

	float distance, horizontalScale;

	int temp1 = bitmap->w - 1;
	int temp2 = bitmap->h - 1;

	float lineDX, lineDY;
	float spaceX, spaceY;

	static BITMAP *temp;
	if (!temp)
		temp = create_bitmap(SCREEN_W / 2, SCREEN_H / 2);

	floodfill(temp, 0, 0, backgroundColor);

	for (screenY = -params.horizon; screenY < temp->h; screenY++) {
		distance = (params.spaceZ * params.scaleY) / (screenY + params.horizon);
		horizontalScale = (distance / params.scaleX);
		lineDX = -sin(angle) * horizontalScale;
		lineDY = cos(angle) * horizontalScale;
		spaceX = cameraX + (distance * cos(angle)) - temp->w * lineDX;
		spaceY = cameraY + (distance * sin(angle)) - temp->w * lineDY;

		for (screenX = 0; screenX < temp->w; screenX++) {
			if ((spaceX<temp1) && (spaceY<temp2) && (spaceX>0) && (spaceY>0))
				putpixel(temp, screenX, screenY, getpixel(bitmap, spaceX, spaceY));

			spaceX += lineDX + lineDX;
			spaceY += lineDY + lineDY;
		}			
	}

	stretch_sprite(target, temp, 0, 0, SCREEN_W, SCREEN_H);
	clear(temp);
}
Esempio n. 27
0
void tools_icons()
{
	int poly[12]={323,3,337,3,330,10,337,17,323,17,323,3};
	int x, y, mx, my, mb,i,j,c=0;
	int pix[16][16];
	int startX=19,startY=0,BUTTON_WIDTH=20,GAP=0;
	FILE* fp = NULL;
	if((fp = fopen("Icons.icl","rb")) !=NULL)
	{
		x = startX+4, y = startY+2;
		while( fread(&pix, sizeof(pix), 1, fp) != NULL)
		{
			for(i=0; i<16; i++)
			{
				for(j=0; j<16; j++)
				{
					if(pix[i][j] != 16)
						putpixel(x+j, y+i, pix[i][j]);
				}
			}
				x+=BUTTON_WIDTH+GAP;
				c++;
				if(c==14)
				break;
		}
		fclose(fp);
	}
	else
	{
		closegraph();
		printf("\n Error: Icons.icl file not found.....");
		getch();

	}
	setcolor(BLUE);
	setlinestyle(1,0xffff,1);
	rectangle(303,3,317,17);
	setlinestyle(0,0xffff,1);
	drawpoly(6,poly);
	circle(350,10,7);
	setfillstyle(1,9);
	bar(368,3,373,17);
	setfillstyle(1,4);
	bar(373,3,378,17);
}
void bez(int x[], int y[], int n)
{
	int i, coeff, deg = n - 1;
	float p[10], u, h, k;
	float temp1, temp2;
	for(i = 0; i < (n - 1); i++)
	{
		setcolor(GREEN);
		line(x[i], y[i], x[i+1], y[i+1]);
	}
	u = 0;
	while(u <= 1.0)
	{
		if(u == 0)
		{
			h = x[0];
			k = y[0];
		}
		else if(u == 1)
		{
			h = x[n - 1];
			k = y[n - 1];
		}
		else
		{
			for(i = 0; i <= deg; i++)
			{
				coeff = bezcoeff(deg, i);
				temp1 = pow(u, i);
				temp2 = pow((1 - u),(deg - i));
				p[i] = coeff * temp1 * temp2;
			}
			h = 0;
			k = 0;
			for(i = 0; i <= deg; i++)
			{
				h = h + (p[i] * x[i]);
				k = k + (p[i] * y[i]);
			}
		}
		putpixel((int) h, (int) k, RED);
		delay(100);
		u += 0.005;
	}
}
Esempio n. 29
0
main()
{
    int x,y,x_ekr,y_ekr;
    initwindow(800,600,"f(x)=|2x+30|");
    setcolor(WHITE);
    line(0,300,799,300);
    line(400,0,400,599);
                   
    for (x_ekr=0; x_ekr<=800; x_ekr++)
    {
        x=x_ekr-400; 
        y=abs(2*x+30);
        y_ekr=300-y; 
        putpixel(x_ekr,y_ekr,LIGHTRED);
    }
    getch();
    closegraph();
}
Esempio n. 30
0
void main()
{
int gdriver=DETECT,gmode;
int x0,y0,x1,y1,x2,y2,x3,y3,xt,yt;
float t;
initgraph(&gdriver,&gmode,"C:\\TC\\BGI");
clrscr();
printf("Enter the control points");
scanf("\n%d%d%d%d%d%d%d%d",&x0,&y0,&x1,&y1,&x2,&y2,&x3,&y3);
for(t=0.1;t<=0.9;t+=0.1)
{
xt=x0*pow((1-t),3)+3*x1*t*pow((1-t),2)+3*x2*t*t*(1-t)+x3*pow(t,3);
yt=y0*pow((1-t),3)+3*y1*t*pow((1-t),2)+3*y2*t*t*(1-t)+y3*pow(t,3);
putpixel(xt,yt,RED);
}
getch();
closegraph();
}