DrawRectangle(pDC);
DrawLine(100,200,400,300,RGB(255,0,0), pDC);
C_S_Line_Clip(100,200,400,300,pDC); } void pDC) { }
void CLineCutView::DrawLine(int x0,int y0,int x1,int y1,int color,CDC* pDC) { }
CLineCutDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc);
// TODO: add draw code for native data
void CLineCutView::encode(float x,float y,int &code) {
CLineCutView::DrawRectangle(CDC*
for(int i=200;i<=300;i++) {
pDC->SetPixelV(200,i,RGB(0,0,0)); pDC->SetPixelV(300,i,RGB(0,0,0)); pDC->SetPixelV(i,200,RGB(0,0,0)); pDC->SetPixelV(i,300,RGB(0,0,0)); }
} void {
int x;
float dx,dy,k,y; dx=x1-x0; dy=y1-y0; k=dy/dx; y=y0;
for(x=x0;x<=x1;x++) {
pDC->SetPixelV(x,int (y+0.5),color); }
y=y+k;
int x,y;
int code1,code2,code; encode(x1,y1,code1); encode(x2,y2,code2); while(code1!=0 || code2!=0) {
y=y1+(y2-y1)*(XL-x1)/(x2-x1);
}
else if((RIGHT&code)!=0) { }
else if((BOTTOM&code)!=0) {
x=XR;
y=y1+(y2-y1)*(XR-x1)/(x2-x1); if((code1&code2)!=0)
return; code=code1; if(code1==0) {
x=XL; code=code2; if((LEFT&code)!=0)
CLineCutView::C_S_Line_Clip(float
x1,float y1,float x2,float y2,CDC* pDC)
int c; c=0; if(x<XL)
c=c|LEFT; c=c|RIGHT; c=c|BOTTOM; c=c|TOP; else if(x>XR) if(y<YB) else if(y>YT) code=c;
here