📄 mfbbasic.c
字号:
cp = MFBFORMAT.setALUOR; break; case MFBALUNOR: cp = MFBFORMAT.setALUNOR; break; case MFBALUEOR: cp = MFBFORMAT.setALUEOR; break; default: cp = NULL; } if(cp == NULL || *cp == 0) return(MFBBADALU); MFBGenCode(cp); return(MFBOK); }intMFBSetCursorColor(colorId1,colorId2) int colorId1,colorId2; /* * Notes: * The cursor color is set when the pointing device is initialized */ { MFBCurrent->cursorColor1Id = colorId1; MFBCurrent->cursorColor2Id = colorId2; return(MFBOK); }intMFBSetBlinker(colorId,r,g,b,onFlag) int colorId,r,g,b,onFlag; /* * Notes: * Turn ON or OF a blinking color. */ { if(!MFBCurrent->blinkersBool) return(MFBNOBLNK); MFBCurrent->X = colorId; if(MFBCurrent->vltUseHLSBool){ MFBConvertToHLS(r,g,b); } else{ /* Normalize to 1000 */ MFBCurrent->Y = r * MFBCurrent->maxIntensity / 1000; MFBCurrent->Z = g * MFBCurrent->maxIntensity / 1000; MFBCurrent->T = b * MFBCurrent->maxIntensity / 1000; } if(onFlag == ON) { MFBGenCode(MFBFORMAT.blinkerON); ++MFBCurrent->numBlinkers; } else { MFBGenCode(MFBFORMAT.blinkerOFF); --MFBCurrent->numBlinkers; } if(MFBCurrent->numBlinkers >= MFBCurrent->maxBlinkers) return(MFBTMBLNK); return(MFBOK); }intMFBSetRubberBanding(RubberBandingBool,X,Y) Bool RubberBandingBool; int X,Y; /* * Notes: * Turn ON or OFF rubberbanding of pointing device. * The center of the rubberbanding is assumed to be the current * graphics position,but may be kludged in the enable sequence. */ { if(MFBFORMAT.enableRubberBanding == NULL || *MFBFORMAT.enableRubberBanding == 0) return(MFBNORBND); if(RubberBandingBool){ MFBCurrent->X = X; MFBCurrent->Y = Y; MFBGenCode(MFBFORMAT.movePenSequence); MFBGenCode(MFBFORMAT.enableRubberBanding); } else MFBGenCode(MFBFORMAT.disableRubberBanding); return(MFBOK); }/***************************************************************************** * * DEFINE VIEWPORT ATTRIBUTES * *****************************************************************************/intMFBDefineColor(colorId,r,g,b) int colorId,r,g,b; /* * Notes: * Defines an entry in the VLT contained in the terminal. * r,g, and b are the red, green, blue intensities normalized * to 1000. */ { /* Are there user defineable colors? */ if(!MFBCurrent->vltBool) return(MFBNODFCO); if(MFBCurrent->vltUseHLSBool){ /* HLS return in MFBCurrent->Y, MFBCurrent->Z, MFBCurrent->T */ MFBConvertToHLS(r,g,b); } else{ /* Normalize to 1000 */ MFBCurrent->Y = r * MFBCurrent->maxIntensity / 1000; MFBCurrent->Z = g * MFBCurrent->maxIntensity / 1000; MFBCurrent->T = b * MFBCurrent->maxIntensity / 1000; } MFBCurrent->X = MFBmax(0,MFBmin(MFBCurrent->maxColors,colorId)); MFBGenCode(MFBFORMAT.vltEntry); return(MFBOK); }intMFBDefineFillPattern(styleId,BitArray) int styleId; int *BitArray; /* * Notes: * A very difficult procedure to generalize. * BitArray is a pointer to 8 integers for which the 8 least * significant bits represent one row in the fill pattern. */ { int i,*j,Count; /* save current stipple pattern */ for(i=0; i<8; ++i) MFBCurrent->stipplePattern[i] = BitArray[i]; /* * Are there defineable fill patterns for this frame buffer? */ if(!MFBCurrent->fillPtrnDefineBool) return(MFBNODFFP); MFBCurrent->X = styleId; if(MFBCurrent->fillDefineRowMajorBool) Count = MFBCurrent->fillDefineHeight; else Count = MFBCurrent->fillDefineWidth; MFBGenCode(MFBFORMAT.fillDefineStart); for(i=0; i<Count; ++i){ if( (int)((i/8) * 8) == i) j = BitArray; MFBCurrent->Y = *j++; MFBGenCode(MFBFORMAT.fillDefineFormat); } MFBGenCode(MFBFORMAT.fillDefineEnd); /* return with the new fill pattern as the current one */ return( MFBSetFillPattern(styleId) ); }intMFBDefineLineStyle(styleId,BitArray) int styleId; int BitArray; { int l; /* * Are there defineable line styles for this frame buffer? */ if(!MFBCurrent->linePatternDefineBool) return(MFBNODFLP); MFBCurrent->X = styleId; MFBGenCode(MFBFORMAT.lineDefineStart); MFBCurrent->Y = BitArray; for(l = 0; l < MFBCurrent->lineDefineLength; ++l) MFBGenCode(MFBFORMAT.lineDefineFormat); MFBGenCode(MFBFORMAT.lineDefineEnd); /* return with the new line style as the current one */ return( MFBSetLineStyle(styleId) ); }/***************************************************************************** * * BASIC VIEWPORT GEOMETRIES * *****************************************************************************/int LastX, LastY; /* used for terminals which have no drawLineToSeq. */voidMFBMoveTo(X1,Y1) int X1,Y1; /* * Notes: * Move current graphics position to X1,Y1. */ { /* the assignment of lastX/Y is redundant for a Tek terminal */ LastX = MFBCurrent->X = X1; LastY = MFBCurrent->Y = Y1; MFBGenCode(MFBFORMAT.movePenSequence); }voidMFBDrawPath(path) MFBPATH *path; /* * Notes: * Draw the Path defined in "path" in the current linestyle. * Without a 'DrawSolidLineToSequence',we must call MFBLine * for the first segment to be certain that the linestyle is * properly set. */ { int n,x,y; if(MFBCurrent->reissueLineStyleBool) MFBSetLineStyle(MFBCurrent->lineStyle); if(path->nvertices < 2) return; n = 2; MFBLine(path->xy[0],path->xy[1],path->xy[2],path->xy[3]); while(n < path->nvertices){ x = path->xy[(n << 1)]; y = path->xy[(n << 1) + 1]; MFBDrawLineTo(x,y); n++; } }voidMFBDrawLineTo(X1,Y1) int X1,Y1; /* * Notes: * Draws a line in the current color and line style from * the last graphics position to X1,Y1. */ { if(MFBCurrent->reissueLineStyleBool) MFBSetLineStyle(MFBCurrent->lineStyle); if(MFBFORMAT.drawLineToSequence == NULL || *MFBFORMAT.drawLineToSequence == 0) { MFBLine(LastX,LastY,X1,Y1); /* the assignment of lastX/Y is redundant for a Tek terminal */ LastX = X1; LastY = Y1; } else{ MFBCurrent->X = X1; MFBCurrent->Y = Y1; if(MFBCurrent->lineStyle == 0 && MFBFORMAT.drawSolidLineToSequence != NULL && *MFBFORMAT.drawSolidLineToSequence != 0) MFBGenCode(MFBFORMAT.drawSolidLineToSequence); else MFBGenCode(MFBFORMAT.drawLineToSequence); } }voidMFBLine(X1,Y1,X2,Y2) int X1,Y1,X2,Y2; /* * Notes: * Draws a line in the current color and line style from X1,Y1 * to X2,Y2. */ {#ifdef DEBUG MFBCurrent->nLines += 1; MFBCurrent->sumLineLength += MFBmax(abs(X1-X2),abs(Y1-Y2));#endif if(MFBCurrent->reissueLineStyleBool) MFBSetLineStyle(MFBCurrent->lineStyle); MFBCurrent->X = X1; MFBCurrent->Y = Y1; MFBCurrent->Z = X2; MFBCurrent->T = Y2; if(MFBCurrent->lineStyle == 0 && MFBFORMAT.drawSolidLineSequence != NULL && *MFBFORMAT.drawSolidLineSequence != 0) MFBGenCode(MFBFORMAT.drawSolidLineSequence); else MFBGenCode(MFBFORMAT.drawLineSequence); LastX = X2; LastY = Y2; }voidMFBBox(l,b,r,t) int l,b,r,t; /* * Notes: * Draws a box in the current fill pattern from lower left * corner (l,b) to upper right corner (r,t). After * this sequence,pen must be left at (r,t). */ {#ifdef DEBUG MFBCurrent->nBoxes += 1; MFBCurrent->sumBoxArea += (r-l)*(t-b);#endif MFBCurrent->X = l; MFBCurrent->Y = b; MFBCurrent->Z = r; MFBCurrent->T = t; if(MFBCurrent->fillPattern == 0 && MFBFORMAT.drawSolidBoxSequence != NULL && *MFBFORMAT.drawSolidBoxSequence != 0) { MFBGenCode(MFBFORMAT.drawSolidBoxSequence); } else if (MFBFORMAT.drawBoxSequence != NULL && *MFBFORMAT.drawBoxSequence != 0) { MFBGenCode(MFBFORMAT.drawBoxSequence); } else MFBNaiveBoxFill(l,b,r,t); }voidMFBArc(x,y,r,astart,astop,s) int x; /* x coordinate of center */ int y; /* y coordinate of center */ int r; /* radius of arc */ int astart; /* initial angle ( +x axis = 0 degrees ) */ int astop; /* final angle ( +x axis = 0 degrees ) */ int s; /* number of segments in a 360 degree arc */ /* * Notes: * Draws an arc of radius r and center at (x,y) beginning at * angle astart (in degrees) and ending at astop */ { int i,j,xx,yy; double d; d = astart / RadToDeg; xx = x + (int)(r * cos(d)); yy = y + (int)(r * sin(d)); /* Must use MFBLine to force a DSL sequence if style Id is solid */ MFBLine(xx,yy,xx,yy); while(astart >= astop) astop += 360; if(s>2 && s<181) j = MFBmax(1,(astop - astart)/s); else j = MFBmax(1,(astop - astart)/18); for(i = astart + j; i <= astop; i += j){ d = i / RadToDeg; MFBCurrent->X = x + (int)(r * cos(d)); MFBCurrent->Y = y + (int)(r * sin(d)); MFBGenCode(MFBFORMAT.drawLineToSequence); } d = astop / RadToDeg; MFBCurrent->X = x + (int)(r * cos(d)); MFBCurrent->Y = y + (int)(r * sin(d)); MFBGenCode(MFBFORMAT.drawLineToSequence); }voidMFBCircle(x,y,r,s) int x; /* x coordinate of center */ int y; /* y coordinate of center */ int r; /* radius of circle */ int s; /* number of line segments in circle (default = 72) */ /* * Notes: * Draws a circle of radius r and center at (x,y) in the * current line style. */{ int i,j=5; double d=0; if(MFBFORMAT.drawCircleSequence == NULL || *MFBFORMAT.drawCircleSequence == 0) { MFBCurrent->X = x + r; MFBCurrent->Y = y; if(s>2 && s<181) j = MFBmax(1,360/s); for(i = j; i <= 360; i += j){ d = i / RadToDeg; MFBCurrent->Z = x + (int)(r * cos(d)); MFBCurrent->T = y + (int)(r * sin(d)); MFBGenCode(MFBFORMAT.drawLineSequence); MFBCurrent->X = MFBCurrent->Z; MFBCurrent->Y = MFBCurrent->T; } } else { MFBCurrent->X = x; MFBCurrent->Y = y; MFBCurrent->Z = r; MFBGenCode(MFBFORMAT.drawCircleSequence); }}voidMFBFlash(x,y,r,s) int x,y,r,s; /* * Notes: * Draws a roundflash of radius r and center at (x,y) in the * current fill style. */ { int i=0,j; double d=0; MFBCurrent->X = x + r; MFBCurrent->Y = y; if(s>2 && s<181) j = 360/s; else { j = 5; s = 72; } MFBCurrent->Z = s; MFBGenCode(MFBFORMAT.beginPlygnSequence); for(i = j; i < 360; i += j){ d = i / RadToDeg; MFBCurrent->X = x + (int)(r * cos(d)); MFBCurrent->Y = y + (int)(r * sin(d)); MFBGenCode(MFBFORMAT.sendPlygnVertex); } MFBCurrent->X = x + r; MFBCurrent->Y = y;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -