Example #1
0
void StepLine(
       register struct region *R,  /* region being built                     */
       register fractpel x1,     /* starting ...                             */
       register fractpel y1,     /* ... point                                */
       register fractpel x2,     /* ending ...                               */
       register fractpel y2)     /* ... point                                */
{
       register fractpel dy;
 
       IfTrace4((LineDebug > 0), ".....StepLine: (%dl,%dl) to (%dl,%dl)\n",
                                            x1, y1, x2, y2);
 
       dy = y2 - y1;
 
/*
We execute the "GOING_TO" macro to call back the REGIONS module, if
necessary (like if the Y direction of the edge has changed):
*/
       GOING_TO(R, x1, y1, x2, y2, dy);
 
       if (dy == 0)
               return;
 
       if (dy < 0)
               Bresenham(R->edge, x2, y2, x1, y1);
       else
               Bresenham(R->edge, x1, y1, x2, y2);
       return;
}
Example #2
0
void cohen_test(Pixel *PixelBuffer) {
    Raster raster;

    Points bounds;
    bounds.push_back({ 10, 10 });
    bounds.push_back({ 10, 100 });
    bounds.push_back({ 100, 100 });
    bounds.push_back({ 100, 10 });

    Points shape;
    shape.push_back({ 5, 5 });
    shape.push_back({ 50, 115 });

    View view = View(SCREENSIZE, SCREENSIZE, PixelBuffer);

    Points *p = raster.cohen_sutherland(&bounds, &shape);

    if (p != NULL) {
        Points *r = Bresenham(p->at(0), p->at(1));
        view.update_buffer(r);
        delete r;
    } else {
        std::cout << "NOPE< NULLLLLL\n";
    }

    delete p;
}
Example #3
0
void main()
{
	int gDriver=DETECT, gMode;
	int x1,x2,y1,y2;

	void Bresenham(int,int,int,int);
	initgraph(&gDriver,&gMode,"c:\\tc\\bgi");

	cout<<endl<<"x1   : ";
	cin>>x1;
	cout<<endl<<"y1   : ";
	cin>>y1;
	cout<<endl<<"x2   : ";
	cin>>x2;
	cout<<endl<<"y2   : ";
	cin>>y2;
   //	line(320,0,320,480);
	//line(0,240,640,240);
	Bresenham(x1,x2,y1,y2);
	getch();
}