2005-05-03 12:00 AM - last edited on 2024-09-09 10:44 AM by Doreena Deng
void DrawPoly(void){ API_ElementMemo memo; API_ElementMemo* pMemo = &memo; API_Element newPoly; API_Element* pNewPoly = &newPoly; GSErrCode err; BNZeroMemory(pNewPoly,sizeof(API_Element)); BNZeroMemory(pMemo,sizeof(API_ElementMemo)); pNewPoly->header.typeID = API_PolyLineID; pNewPoly->header.layer = 1; pNewPoly->header.floorInd = 1; pNewPoly->polyLine.poly.nArcs = 0; //no arcs pNewPoly->polyLine.poly.nSubPolys = 1; //no holes pNewPoly->polyLine.poly.nCoords = 4; //a closed triangle //allocate space for 3points + final point to close shape + space for storing max vertID = 5 pMemo->vertexIDs = (unsigned long **) BMAllocateHandle(sizeof(long) * (5), ALLOCATE_CLEAR, 0); (*pMemo->vertexIDs)[0] = 3; //max vertexID //allocate space for pends. no holes, so the 4th vert is the only endpoint. pMemo->pends = (long **) BMAllocateHandle(sizeof(long) * 2, ALLOCATE_CLEAR, 0); (*pMemo->pends)[0] = 0; //required (*pMemo->pends)[1] = 4; //4th vert closes the shape //allocate space for the coord array. 4 vertices + the dummy coord. pMemo->coords = (API_Coord **) BMAllocateHandle(sizeof(API_Coord) * 5, ALLOCATE_CLEAR, 0); (*pMemo->coords)[0].x = -1.0; //polylines start with a "dummy" coord of -1,0 (*pMemo->coords)[0].y = 0.0; //setup complete....add vertices. //1st point: 1,1 (*pMemo->coords)[1].x = 1; (*pMemo->coords)[1].y = 1; (*pMemo->vertexIDs)[1] = 1; //2nd point: 2,1 (*pMemo->coords)[2].x = 2; (*pMemo->coords)[2].y = 1; (*pMemo->vertexIDs)[2] = 2; //3rd point: 1,2 (*pMemo->coords)[3].x = 1; (*pMemo->coords)[3].y = 2; (*pMemo->vertexIDs)[3] = 3; //4th point. Same as point 1. (*pMemo->coords)[4].x = 1; (*pMemo->coords)[4].y = 1; (*pMemo->vertexIDs)[4] = 1; err = ACAPI_Element_Create(pNewPoly,pMemo); //handle return code... ACAPI_DisposeElemMemoHdls(pMemo); }
2005-05-03 04:27 PM
2006-08-14 12:03 PM