Public feed #722885

Something

public text v1 · immutable
Raw Edit
·published 2007-10-02 12:20 UTC
rendered paste body
public void draw (CG1Canvas canvas)
	{
		


		int x = x1;
		int y = y1;

		int dx = x2 -x1;
		int dy = y2 - y1;
		
		int incx = sgn(dx);
		int incy = sgn(dy);
		
		if (dx<0) dx = -dx;
		if (dy<0) dy = -dy;
		
		
		int dist = (dx>dy)?dx:dy;
		
		
		
		int xerr = dx;
		int yerr = dy;
		
		for (int t=0; t<dist; ++t) {
			
			
			canvas.setPixel(x, y, color);
			
			xerr += dx;
			yerr += dy;
			
			if (xerr>dist) {
				
				xerr -= dist;
				x += incx;
			}
			
			if (yerr>dist) {
				
				yerr -=dist;
				y += incy;
			}
		}
		
	}