void CompDateAxis::Draw(wxDC &dc, wxRect rc) { DateTimeDataset *dataset = m_datasets[0]->AsDateTimeDataset(); if (dataset == NULL) { return ; // BUG! } wxDateTime firstDate, lastDate; if (!GetWindowDateBounds(firstDate, lastDate)) { return ; } for (size_t nSpan = 0; nSpan < m_dateSpans.Count(); nSpan++) { wxDateSpan span = m_dateSpans[nSpan]; wxDateTime dateStart = RoundDateToSpan(firstDate, span); do { double start = DateToDataCoord(dateStart); wxDateTime dateEnd = dateStart; dateEnd += span; double end = DateToDataCoord(dateEnd); DrawSpan(dc, rc, nSpan, GetSpanLabel(dateStart, span), start, end); dateStart += span; } while (dateStart <= lastDate); } }
void Rasterizer::DrawSpanBetweenBuffers() { for ( int i = 0; i < _height; i++) { if ( _leftBounds[i] == (_width + 1) && _rightBounds[i] == -1 ) { continue; } Span spans(_leftColor[i], _leftBounds[i], _leftZBounds[i], _leftUBounds[i], _leftVBounds[i], _leftWBounds[i], _rightColor[i], _rightBounds[i], _rightZBounds[i], _rightUBounds[i], _rightVBounds[i], _rightWBounds[i]); DrawSpan(spans, i); } }
void R_Surf_DrawAll (void) { struct drawsurf_s *ds; for (ds = surfs; ds != surfs_p; ds++) { struct drawspan_s *s; int i; for (i = 0, s = &r_spans[ds->firstspanidx]; i < ds->numspans; i++, s++) { int c = ((uintptr_t)&map.surfaces[ds->msurfidx] >> 4) & 0xffffff; DrawSpan (s, c); } } }
static void DrawTriangle(POINT p1, DOUBLE z1, POINT p2, DOUBLE z2, POINT p3, DOUBLE z3, DOUBLE i, char c) { POINT pt; DOUBLE z31, z21, mx1, mx2, mz, dzNdx, dzNdy, x1, x2, z, zt, o; INT y31, y21, y32, x31, x32, x21, D, y; /* make p1.y <= p2.y <= p3.y */ if (p1.y > p2.y) { SWAP(p1, p2, pt); SWAP(z1, z2, zt); } if (p1.y > p3.y) { SWAP(p1, p3, pt); SWAP(z1, z3, zt); } if (p2.y > p3.y) { SWAP(p2, p3, pt); SWAP(z2, z3, zt); } y31 = p3.y - p1.y; /* height of long edge */ y21 = p2.y - p1.y; /* height of lower short edge */ y32 = p3.y - p2.y; /* height of upper short edge */ x31 = p3.x - p1.x; x32 = p3.x - p2.x; x21 = p2.x - p1.x; D = y21*x31-y31*x21; /* degenerated triangle ? */ if (D == 0) return; z31 = z3 - z1; z21 = z2 - z1; mx1 = (DOUBLE)x31 / (DOUBLE)y31; mz = z31 / (DOUBLE)y31; /* grad z */ dzNdx = (DOUBLE)(y21*z31-z21*y31)/(DOUBLE)D; dzNdy = (DOUBLE)(x31*z21-z31*x21)/(DOUBLE)D; /* offset for z coords proportional to max. depth slope */ /* should avoid line dropouts if surrounding is drawn later */ o = zOffsetFactor * sqrt(dzNdx*dzNdx+dzNdy*dzNdy); /* rasterize lower partial triangle */ if (y21 != 0) { mx2 = (DOUBLE)x21 / (DOUBLE)y21; x1 = x2 = (DOUBLE)p1.x + 0.5; z = z1-o; for (y = p1.y; y <= p2.y; y++) { DrawSpan((INT)x1, (INT)x2, y, z, dzNdx, i, c); x1 += mx1; x2 += mx2; z += mz; } } /* rasterize upper partial triangle */ if (y32 != 0) { mx2 = (DOUBLE)x32 / (DOUBLE)y32; x1 = x2 = (DOUBLE)p3.x + 0.5; z = z3-o; for (y = p3.y; y >= p2.y; y--) { DrawSpan((INT)x1, (INT)x2, y, z, dzNdx, i, c); x1 -= mx1; x2 -= mx2; z -= mz; } } }
void cOBJECT::DrawPolyZShade(POLYGON *currentpoly) { long signL,xL1,yL1,numeratorL,denominatorL,incrementL; long signR,xR1,yR1,numeratorR,denominatorR,incrementR; long i,top,yval,currentL,currentR,xL2,yL2,xR2,yR2,ystart,yend,yend1; MFLOAT zL1,zR1,zL2,zR2,inczL,inczR; // Z values for left and right point (used for z buffer) long numpoints=currentpoly->ClippedNumVectors; inczL=0;inczR=0; // determine bottom point yend1=(long)TVectors[currentpoly->ClippedVectorIndex[0]].y; for (i=1;i<numpoints;i++) { if ((long)TVectors[currentpoly->ClippedVectorIndex[i]].y>yend1) { yend1=(long)TVectors[currentpoly->ClippedVectorIndex[i]].y; } } // Clip to bottom of screen (line 400) if (yend1>400) yend1=400; // determine top point top=0; yval=(long)TVectors[currentpoly->ClippedVectorIndex[0]].y; for (i=1;i<numpoints;i++) { if ((long)TVectors[currentpoly->ClippedVectorIndex[i]].y<yval) { yval=(long)TVectors[currentpoly->ClippedVectorIndex[i]].y; top=i; } } currentL=top; currentR=top; xL1=(long)TVectors[currentpoly->ClippedVectorIndex[currentL]].x; // start line left yL1=(long)TVectors[currentpoly->ClippedVectorIndex[currentL]].y; zL1=TVectors[currentpoly->ClippedVectorIndex[currentL]].z; currentL++; if (currentL>numpoints-1) currentL=0; xL2=(long)TVectors[currentpoly->ClippedVectorIndex[currentL]].x; // end line left yL2=(long)TVectors[currentpoly->ClippedVectorIndex[currentL]].y; zL2=TVectors[currentpoly->ClippedVectorIndex[currentL]].z; numeratorL=xL2-xL1; signL=1; denominatorL=yL2-yL1; incrementL=denominatorL; if (denominatorL!=0) { inczL=(zL2-zL1)/(MFLOAT)(denominatorL); } xR1=(long)TVectors[currentpoly->ClippedVectorIndex[currentR]].x; // start line right yR1=(long)TVectors[currentpoly->ClippedVectorIndex[currentR]].y; zR1=TVectors[currentpoly->ClippedVectorIndex[currentR]].z; currentR--; if (currentR<0) currentR=numpoints-1; xR2=(long)TVectors[currentpoly->ClippedVectorIndex[currentR]].x; // end line right yR2=(long)TVectors[currentpoly->ClippedVectorIndex[currentR]].y; zR2=TVectors[currentpoly->ClippedVectorIndex[currentR]].z; numeratorR=xR2-xR1; signR=1; denominatorR=yR2-yR1; incrementR=denominatorR; if (denominatorR!=0) { inczR=(zR2-zR1)/(MFLOAT)(denominatorR); } if (numeratorL<0) { numeratorL=-numeratorL; signL=-signL; } if (numeratorR<0) { numeratorR=-numeratorR; signR=-signR; } if (yL1<yR1) ystart=yL1; else ystart=yR1; while (ystart<yend1) { if (yL2<yR2) yend=yL2; else yend=yR2; if (yend>yend1) // y clipping at maxY(400) yend=yend1; while (ystart<yend) { DrawSpan(xL1,xR1,zL1,zR1,ystart); zL1+=inczL; zR1+=inczR; incrementL+=numeratorL; incrementR+=numeratorR; while (incrementL>denominatorL) { xL1+=signL; incrementL-=denominatorL; } while (incrementR>denominatorR) { xR1+=signR; incrementR-=denominatorR; } ystart++; } if (yend==yL2) // end of left segment, get next line from list { xL1=xL2; yL1=yL2; zL1=zL2; currentL++; if (currentL>numpoints-1) currentL=0; xL2=(long)TVectors[currentpoly->ClippedVectorIndex[currentL]].x; // end line left yL2=(long)TVectors[currentpoly->ClippedVectorIndex[currentL]].y; zL2=TVectors[currentpoly->ClippedVectorIndex[currentL]].z; numeratorL=xL2-xL1; signL=1; denominatorL=yL2-yL1; incrementL=denominatorL; if (denominatorL!=0) { inczL=(zL2-zL1)/(MFLOAT)(denominatorL); } else { inczL=0; } if (numeratorL<0) { numeratorL=-numeratorL; signL=-signL; } } else { if (yend==yR2) { xR1=xR2; yR1=yR2; zR1=zR2; currentR--; if (currentR<0) currentR=numpoints-1; xR2=(long)TVectors[currentpoly->ClippedVectorIndex[currentR]].x; // end line right yR2=(long)TVectors[currentpoly->ClippedVectorIndex[currentR]].y; zR2=TVectors[currentpoly->ClippedVectorIndex [currentR]].z; numeratorR=xR2-xR1; signR=1; denominatorR=yR2-yR1; incrementR=denominatorR; if (denominatorR!=0) { inczR=(zR2-zR1)/(MFLOAT)(denominatorR); } else { inczR=0; } if (numeratorR<0) { numeratorR=-numeratorR; signR=-signR; } } } } }