static bool HHVM_METHOD(ImagickDraw, bezier, const Array& coordinates) { auto wand = getDrawingWandResource(Object{this_}); auto points = toPointInfoArray(coordinates); if (points.empty()) { IMAGICKDRAW_THROW("Unable to read coordinate array"); } DrawBezier(wand->getWand(), points.size(), points.data()); return true; }
void Bezier::MouseButtonUp(LPARAM lparam, WPARAM wparam) { if (wparam & MK_LBUTTON || wparam & MK_RBUTTON) { hdc = GetDC(hwnd); setupPaintingTools(hdc); SelectObject(hdc, GetStockObject(WHITE_PEN)); DrawBezier(hdc, points); if (wparam & MK_LBUTTON) { points[1].x = LOWORD (lparam); points[1].y = HIWORD (lparam); } if (wparam & MK_RBUTTON) { points[2].x = LOWORD (lparam); points[2].y = HIWORD (lparam); } SelectObject(hdc, GetStockObject(BLACK_PEN)); DrawBezier(hdc, points); ReleaseDC(hwnd, hdc); } }
static void DrawBeziers(sdot_op* o, int param) { /* GLfloat tempX[4]; */ /* GLfloat tempY[4]; */ /* GLfloat tempZ[4]; */ /* int temp = 0; */ int filled; int i = 0; xdot_op * op=&o->op; xdot_point* ps = op->u.bezier.pts; view->Topview->global_z = view->Topview->global_z + o->layer*LAYER_DIFF; /* SelectBeziers((sdot_op *) op); */ /* relocate_spline((sdot_op *) op, param); */ if (op->kind == xd_filled_bezier) filled = 1; else filled = 0; for (i = 1; i < op->u.bezier.cnt; i += 3) { DrawBezier(ps, filled, param); ps += 3; } }
/* {{{ proto GmagickDraw GmagickDraw::bezier(array coordinates) Draws a bezier curve through a set of points on the image. */ PHP_METHOD(gmagickdraw, bezier) { zval *coordinate_array; php_gmagickdraw_object *internd; PointInfo *coordinates; int num_elements = 0; /* Parse parameters given to function */ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &coordinate_array) == FAILURE) { return; } coordinates = get_pointinfo_array(coordinate_array, &num_elements TSRMLS_CC); if (coordinates == (PointInfo *)NULL) { GMAGICK_THROW_EXCEPTION_WITH_MESSAGE(GMAGICKDRAW_CLASS, "Unable to read coordinate array", 2); } internd = (php_gmagickdraw_object *)zend_object_store_get_object(getThis() TSRMLS_CC); DrawBezier(internd->drawing_wand, num_elements, coordinates); efree(coordinates); GMAGICK_CHAIN_METHOD; }
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static POINT apt[4] ; HDC hdc ; int cxClient, cyClient ; PAINTSTRUCT ps ; RECT rc; GetClientRect(hwnd, &rc); switch (message) { case WM_SIZE: cxClient = LOWORD (lParam) ; cyClient = HIWORD (lParam) ; apt[0].x = cxClient / 4 ; apt[0].y = cyClient / 2 ; apt[1].x = cxClient / 2 ; apt[1].y = cyClient / 4 ; apt[2].x = cxClient / 2 ; apt[2].y = 3 * cyClient / 4 ; apt[3].x = 3 * cxClient / 4 ; apt[3].y = cyClient / 2 ; return 0 ; case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: case WM_MOUSEMOVE: if (wParam & MK_LBUTTON || wParam & MK_RBUTTON) { hdc = GetDC (hwnd) ; // alte Kurve löschen (mit Weiß übermalen) SelectObject (hdc, GetStockObject (WHITE_PEN)) ; DrawBezier (hdc, apt) ; if (wParam & MK_LBUTTON) { apt[1].x = LOWORD (lParam) ; apt[1].y = HIWORD (lParam) ; } if (wParam & MK_RBUTTON) { apt[2].x = LOWORD (lParam) ; apt[2].y = HIWORD (lParam) ; } // neue Kurve (mit Schwarz) zeichnen SelectObject (hdc, GetStockObject (BLACK_PEN)) ; gdDrawImage(hdc, &rc); DrawBezier (hdc, apt) ; ReleaseDC (hwnd, hdc) ; } return 0 ; case WM_PAINT: hdc = BeginPaint (hwnd, &ps) ; GetClientRect(hwnd, &rc); gdDrawImage(hdc, &rc); DrawBezier (hdc, apt) ; EndPaint (hwnd, &ps) ; return 0 ; case WM_DESTROY: PostQuitMessage (0) ; return 0 ; } return DefWindowProc (hwnd, message, wParam, lParam) ; }
/* This function is called by the Windows function DispatchMessage() */ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static HWND hwndButton1, hwndButton2, hwndButton3, hwndButton4, hwndButton5, hwndButton6, hwndButton7; static HWND hwndCheckBox3, hwndCheckBox5, hwndCheckBox6; static HBITMAP hBitmap; static int cxClient, cyClient, cxSource, cySource; BITMAP bitmap; HDC hdc, hdcMem; int x, y; PAINTSTRUCT ps; LPDRAWITEMSTRUCT pdis; POINT pt[3]; RECT rc,rect, rectTemp; HPEN hPen; HBRUSH hBrush; HBRUSH hbr; UINT coll = 0; COLORREF colRef; HDC hDC = GetDC(hwnd); static BOOL IsDrawing = FALSE; static int StartX, StartY; static int EndX, EndY; static BOOL isLine, isFreeHand, isEllipse, isTriangle, isRectangle, isEraser; int state; switch (message) { /* handle the messages */ case WM_CREATE: hBitmap = LoadBitmap (hInst, TEXT ("header")); GetObject (hBitmap, sizeof (BITMAP), &bitmap); cxSource = bitmap.bmWidth; cySource = bitmap.bmHeight; hwndButton1 = CreateWindow ( TEXT("BUTTON"), TEXT (""), WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, 50, 60, 30, 30, hwnd, (HMENU) IDB_BUTTON1, hInst, NULL); hwndButton2 = CreateWindow ( TEXT("BUTTON"), TEXT (""), WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, 50, 95, 30, 30, hwnd, (HMENU) IDB_BUTTON2, hInst, NULL); hwndCheckBox3 = CreateWindow ( TEXT("BUTTON"), TEXT (""), WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 20, 130, 13, 13, hwnd, (HMENU) IDR_RADIOBUTTON3, hInst, NULL); hwndButton3 = CreateWindow ( TEXT("BUTTON"), TEXT (""), WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, 50, 130, 30, 30, hwnd, (HMENU) IDB_BUTTON3, hInst, NULL); hwndButton4 = CreateWindow ( TEXT("BUTTON"), TEXT (""), WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, 50, 165, 30, 30, hwnd, (HMENU) IDB_BUTTON4, hInst, NULL); hwndCheckBox5 = CreateWindow ( TEXT("BUTTON"), TEXT (""), WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 20, 200, 13, 13, hwnd, (HMENU) IDR_RADIOBUTTON5, hInst, NULL); hwndButton5 = CreateWindow ( TEXT("BUTTON"), TEXT (""), WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, 50, 200, 30, 30, hwnd, (HMENU) IDB_BUTTON5, hInst, NULL); hwndCheckBox6 = CreateWindow ( TEXT("BUTTON"), TEXT (""), WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, 20, 235, 13, 13, hwnd, (HMENU) IDR_RADIOBUTTON6, hInst, NULL); hwndButton6 = CreateWindow ( TEXT("BUTTON"), TEXT (""), WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, 50, 235, 30, 30, hwnd, (HMENU) IDB_BUTTON6, hInst, NULL); hwndButton7 = CreateWindow ( TEXT("BUTTON"), TEXT (""), WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, 50, 270, 30, 30, hwnd, (HMENU) IDB_BUTTON7, hInst, NULL); return 0 ; case WM_DRAWITEM : pdis = (LPDRAWITEMSTRUCT) lParam; FillRect (pdis->hDC, &pdis->rcItem, (HBRUSH) GetStockObject (WHITE_BRUSH)); FrameRect (pdis->hDC, &pdis->rcItem, (HBRUSH) GetStockObject (BLACK_BRUSH)); switch (pdis->CtlID) { case IDB_BUTTON1 : hPen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0)); SelectObject(pdis->hDC, hPen); MoveToEx (pdis->hDC, 5, 18, NULL) ; LineTo (pdis->hDC, 19, 4) ; hPen = CreatePen(PS_SOLID, 2, RGB(0, 0, 0)); SelectObject(pdis->hDC, hPen); MoveToEx (pdis->hDC, 8, 21, NULL) ; LineTo (pdis->hDC, 22, 7) ; hPen = CreatePen(PS_SOLID, 3, RGB(0, 0, 0)); SelectObject(pdis->hDC, hPen); MoveToEx (pdis->hDC, 11, 25, NULL); LineTo (pdis->hDC, 25, 11); break; case IDB_BUTTON2 : pt[0].x = 3; pt[0].y = 3; pt[1].x = 3; pt[1].y = 27; pt[2].x = 27; pt[2].y = 15; pt[3].x = 27; pt[3].y = 3; DrawBezier (pdis->hDC, pt); break; case IDB_BUTTON3 : state = SendMessage(hwndCheckBox3, BM_GETCHECK, 0, 0); if(state == BST_CHECKED) { Circle (pdis->hDC, 3, 3, 24, true); } else { Circle (pdis->hDC, 3, 3, 24, false); } break; case IDB_BUTTON4 : hPen = CreatePen(PS_SOLID, 3, RGB(0, 0, 0)); SelectObject(pdis->hDC, hPen); MoveToEx (pdis->hDC, 8, 21, NULL) ; LineTo (pdis->hDC, 22, 7) ; hPen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0)); SelectObject(pdis->hDC, hPen); MoveToEx (pdis->hDC, 8, 21, NULL); LineTo (pdis->hDC, 3, 24); break; case IDB_BUTTON5 : pt[0].x = 4; pt[0].y = 26; pt[1].x = 26; pt[1].y = 26; pt[2].x = 15; pt[2].y = 3; Triangle (pdis->hDC, pt); break; case IDB_BUTTON6 : pt[0].x = 3; pt[0].y = 3; pt[1].x = 3; pt[1].y = 26; pt[2].x = 26; pt[2].y = 26; pt[3].x = 26; pt[3].y = 3; Rectangle(pdis->hDC, pt); break; case IDB_BUTTON7 : pt[0].x = 3; pt[0].y = 20; pt[1].x = 6; pt[1].y = 15; pt[2].x = 16; pt[2].y = 15; pt[3].x = 13; pt[3].y = 20; Rectangle(pdis->hDC, pt); hPen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0)); SelectObject(pdis->hDC, hPen); MoveToEx (pdis->hDC, 6, 15, NULL); LineTo (pdis->hDC, 15, 11); MoveToEx (pdis->hDC, 16, 15, NULL); LineTo (pdis->hDC, 25, 11); MoveToEx (pdis->hDC, 13, 20, NULL); LineTo (pdis->hDC, 22, 16); MoveToEx (pdis->hDC, 15, 11, NULL); LineTo (pdis->hDC, 25, 11); MoveToEx (pdis->hDC, 25, 11, NULL); LineTo (pdis->hDC, 21, 17); break; } if (pdis->itemState & ODS_SELECTED) InvertRect (pdis->hDC, &pdis->rcItem); if (pdis->itemState & ODS_FOCUS) // Draw a focus rectangle if the button has the focus DrawFocusRect (pdis->hDC, &pdis->rcItem) ; return 0; case WM_LBUTTONDOWN: if((LOWORD(lParam) > 15) && (HIWORD(lParam) > 400) && (LOWORD(lParam) < 90) && (HIWORD(lParam) <550) ) { coll = 255* (HIWORD(lParam) - 400)/150; updateColorPreview(hDC, RGB(coll, coll, coll), 15, 350); colRef = RGB(coll, coll, coll); return 0; } hDC = GetDC(hwnd); StartX = LOWORD(lParam); StartY = HIWORD(lParam); EndX = LOWORD(lParam); EndY = HIWORD(lParam); if(isLine) { hPen = CreatePen(PS_SOLID, 1, colRef); hbr = CreateSolidBrush(colRef); SelectObject(hDC, hPen); SelectObject(hDC, hbr); SetROP2(hDC, R2_XORPEN); MoveToEx(hDC, StartX, StartY, NULL); LineTo(hDC, EndX, EndY); IsDrawing = TRUE; DeleteObject(hPen); DeleteObject(hbr); } if(isFreeHand) { hPen = CreatePen(PS_SOLID, 1, colRef); hbr = CreateSolidBrush(colRef); SelectObject(hDC, hPen); SelectObject(hDC, hbr); StartX = LOWORD(lParam); StartY = HIWORD(lParam); IsDrawing = TRUE; DeleteObject(hPen); DeleteObject(hbr); } if(isEllipse){ state = SendMessage(hwndCheckBox3, BM_GETCHECK, 0, 0); hPen = CreatePen(PS_SOLID, 1, colRef); if(state){ hbr = CreateSolidBrush(colRef); SelectObject(hDC, hbr); } else { hbr = (HBRUSH)GetStockObject(NULL_BRUSH); SelectObject(hDC, hbr); } SelectObject(hDC, hPen); SetROP2(hDC, R2_XORPEN); Ellipse(hDC, StartX, StartY, EndX, EndY); ReleaseDC(hwnd, hDC); IsDrawing = TRUE; DeleteObject(hPen); DeleteObject(hbr); } if (isTriangle) { state = SendMessage(hwndCheckBox5, BM_GETCHECK, 0, 0); hPen = CreatePen(PS_SOLID, 1, colRef); if (state){ hbr = CreateSolidBrush(colRef); SelectObject(hDC, hbr); } else { hbr = (HBRUSH)GetStockObject(NULL_BRUSH); SelectObject(hDC, hbr); } SelectObject(hDC, hPen); SetROP2(hDC, R2_XORPEN); pt[0].x = StartX; pt[0].y = EndY; pt[1].x = (EndX + StartX) / 2; pt[1].y = StartY; pt[2].x = EndX; pt[2].y = EndY; Triangle(hDC, pt); ReleaseDC(hwnd, hDC); IsDrawing = TRUE; DeleteObject(hPen); DeleteObject(hbr); } if (isRectangle) { hPen = CreatePen(PS_SOLID, 1, colRef); state = SendMessage(hwndCheckBox6, BM_GETCHECK, 0, 0); if (state) { hbr = CreateSolidBrush(colRef); } else { hbr = (HBRUSH)GetStockObject(NULL_BRUSH); } SelectObject(hDC, hbr); SelectObject(hDC, hPen); SetROP2(hDC, R2_XORPEN); pt[0].x = StartX; pt[0].y = StartY; pt[1].x = StartX; pt[1].y = EndY; pt[2].x = EndX; pt[2].y = EndY; pt[3].x = EndX; pt[3].y = StartY; Rectangle(hDC, pt); ReleaseDC(hwnd, hDC); IsDrawing = TRUE; DeleteObject(hPen); DeleteObject(hbr); } if (isEraser) { rect.left = StartX - 15; rect.right = StartX + 15; rect.top = StartY - 15; rect.bottom = StartY + 15 ; InvalidateRect(hwnd, &rect, FALSE); SendMessage(hwnd, WM_PAINT, 0, 0); ValidateRect(hwnd, &rect); } ReleaseDC(hwnd, hDC); return 0; case WM_MOUSEMOVE: if(IsDrawing) { hDC = GetDC(hwnd); if(isLine) { hPen = CreatePen(PS_SOLID, 1, colRef); SelectObject(hDC, hPen); SetROP2(hDC, R2_NOTXORPEN); MoveToEx(hDC, StartX, StartY, NULL); LineTo(hDC, EndX, EndY); EndX = LOWORD(lParam); EndY = HIWORD(lParam); MoveToEx(hDC, StartX, StartY, NULL); LineTo(hDC, EndX, EndY); DeleteObject(hPen); } if(isFreeHand) { hPen = CreatePen(PS_SOLID, 1, colRef); SelectObject(hDC, hPen); MoveToEx(hDC, EndX, EndY, NULL); EndX = LOWORD(lParam); EndY = HIWORD(lParam); LineTo(hDC, EndX, EndY); DeleteObject(hPen); } if(isEllipse) { hPen = CreatePen(PS_SOLID, 1, colRef); state = SendMessage(hwndCheckBox3, BM_GETCHECK, 0, 0); if(state) { hbr = CreateSolidBrush(colRef); } else { hbr = (HBRUSH)GetStockObject(NULL_BRUSH); } SelectObject(hDC, hbr); SelectObject(hDC, hPen); SetROP2(hDC, R2_NOTXORPEN); Ellipse(hDC, StartX, StartY, EndX, EndY); EndX = LOWORD(lParam); EndY = HIWORD(lParam); Ellipse(hDC, StartX, StartY, EndX, EndY); DeleteObject(hbr); DeleteObject(hPen); } if(isTriangle) { hPen = CreatePen(PS_SOLID, 1, colRef); state = SendMessage(hwndCheckBox5, BM_GETCHECK, 0, 0); if (state){ hbr = CreateSolidBrush(colRef); } else { hbr = (HBRUSH)GetStockObject(NULL_BRUSH); } SelectObject(hDC, hbr); SelectObject(hDC, hPen); SetROP2(hDC, R2_NOTXORPEN); pt[0].x = StartX; pt[0].y = EndY; pt[1].x = (EndX + StartX) / 2; pt[1].y = StartY; pt[2].x = EndX; pt[2].y = EndY; Triangle(hDC, pt); EndX = LOWORD(lParam); EndY = HIWORD(lParam); pt[0].x = StartX; pt[0].y = EndY; pt[1].x = (EndX + StartX) / 2; pt[1].y = StartY; pt[2].x = EndX ; pt[2].y = EndY; Triangle(hDC, pt); DeleteObject(hPen); DeleteObject(hbr); } if (isRectangle) { hPen = CreatePen(PS_SOLID, 1, colRef); state = SendMessage(hwndCheckBox6, BM_GETCHECK, 0, 0); hPen = CreatePen(PS_SOLID, 1, colRef); if(state) { hbr = CreateSolidBrush(colRef); SelectObject(hDC, hbr); } else { hbr = (HBRUSH)GetStockObject(NULL_BRUSH); SelectObject(hDC, hbr); } SelectObject(hDC, hPen); SetROP2(hDC, R2_NOTXORPEN); pt[0].x = StartX ; pt[0].y = StartY; pt[1].x = StartX; pt[1].y = EndY ; pt[2].x = EndX ; pt[2].y = EndY ; pt[3].x = EndX ; pt[3].y = StartY ; Rectangle(hDC, pt); EndX = LOWORD(lParam); EndY = HIWORD(lParam); pt[0].x = StartX; pt[0].y = StartY; pt[1].x = StartX; pt[1].y = EndY; pt[2].x = EndX; pt[2].y = EndY; pt[3].x = EndX; pt[3].y = StartY; Rectangle(hDC, pt); DeleteObject(hPen); DeleteObject(hbr); } if (isEraser) { SetROP2(hDC, R2_NOTXORPEN); rect.left = StartX - 5; rect.right = StartX + 5; rect.top = StartY - 5; rect.bottom = StartY + 5 ; InvalidateRect(hwnd, &rect, FALSE); SendMessage(hwnd, WM_PAINT, 0, 0); ValidateRect(hwnd, &rect); EndX = LOWORD(lParam); EndY = HIWORD(lParam); rect.left = EndX - 5; rect.right = EndX + 5; rect.top = EndY - 5; rect.bottom = EndY + 5 ; InvalidateRect(hwnd, &rect, FALSE); SendMessage(hwnd, WM_PAINT, 0, 0); ValidateRect(hwnd, &rect); } } ReleaseDC(hwnd, hDC); break; case WM_LBUTTONUP: hDC = GetDC(hwnd); EndX = LOWORD(lParam); EndY = HIWORD(lParam); SetROP2(hDC, R2_XORPEN); MoveToEx(hDC, StartX, StartY, NULL); LineTo(hDC, EndX, EndY); IsDrawing = FALSE; ReleaseDC(hwnd, hDC); break; case WM_SIZE: cxClient = LOWORD (lParam); cyClient = HIWORD (lParam); return 0; case WM_COMMAND : switch (LOWORD(wParam)){ case IDB_BUTTON1: isEraser = false; isRectangle = false; isLine = true; isFreeHand = false; isEllipse = false; isTriangle = false; break; case IDB_BUTTON3: isEraser = false; isRectangle = false; isLine = false; isFreeHand = false; isEllipse = true; isTriangle = false; break; case IDB_BUTTON4: isEraser = false; isRectangle = false; isLine = false; isFreeHand = true; isEllipse = false; isTriangle = false; break; case IDB_BUTTON5: isEraser = false; isRectangle = false; isTriangle = true; isLine = false; isFreeHand = false; isEllipse = false; break; case IDB_BUTTON6: isEraser = false; isRectangle = true; isTriangle = false; isLine = false; isFreeHand = false; isEllipse = false; break; case IDB_BUTTON7: isEraser = true; isRectangle = false; isTriangle = false; isLine = false; isFreeHand = false; isEllipse = false; break; } GetWindowRect (hwnd, &rc); return 0; case WM_PAINT: /*draw the header*/ hdc = BeginPaint (hwnd, &ps); hdcMem = CreateCompatibleDC (hdc); SelectObject (hdcMem, hBitmap); for (y = 0 ; y < cySource ; y += cySource) for (x = 0 ; x < cxSource ; x += cxSource) BitBlt (hdc, x, y, cxSource, cySource, hdcMem, 0, 0, SRCCOPY); DeleteDC (hdcMem) ; updateColorPreview(hdc, colRef, 15, 350); rectTemp.top = 400; rectTemp.bottom = 550; rectTemp.left =15; rectTemp.right =90; for(int l = 0; l < 150; l++) { int r; r = l * 255 / 150; rectTemp.top = 400 + l; rectTemp.bottom = 400 + l + 1; hBrush = CreateSolidBrush(RGB(r, r, r)); FillRect(hdc, &rectTemp, hBrush); DeleteObject(hBrush); } EndPaint (hwnd, &ps) ; return 0; case WM_DESTROY: DeleteObject (hBitmap) ; PostQuitMessage (0); /* send a WM_QUIT to the message queue */ break; default: /* for messages that we don't deal with */ return DefWindowProc (hwnd, message, wParam, lParam); } return 0; }
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static POINT apt[4] ; HDC hdc ; int cxClient, cyClient ; PAINTSTRUCT ps ; switch (message) { case WM_SIZE: cxClient = LOWORD (lParam) ; cyClient = HIWORD (lParam) ; apt[0].x = cxClient / 4 ; apt[0].y = cyClient / 2 ; apt[1].x = cxClient / 2 ; apt[1].y = cyClient / 4 ; apt[2].x = cxClient / 2 ; apt[2].y = 3 * cyClient / 4 ; apt[3].x = 3 * cxClient / 4 ; apt[3].y = cyClient / 2 ; return 0 ; case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: case WM_MOUSEMOVE: if (wParam & MK_LBUTTON || wParam & MK_RBUTTON) { hdc = GetDC (hwnd) ; SelectObject (hdc, GetStockObject (WHITE_PEN)) ; DrawBezier (hdc, apt) ; if (wParam & MK_LBUTTON) { apt[1].x = LOWORD (lParam) ; apt[1].y = HIWORD (lParam) ; } if (wParam & MK_RBUTTON) { apt[2].x = LOWORD (lParam) ; apt[2].y = HIWORD (lParam) ; } SelectObject (hdc, GetStockObject (BLACK_PEN)) ; DrawBezier (hdc, apt) ; ReleaseDC (hwnd, hdc) ; } return 0 ; case WM_PAINT: InvalidateRect (hwnd, NULL, TRUE) ; hdc = BeginPaint (hwnd, &ps) ; DrawBezier (hdc, apt) ; EndPaint (hwnd, &ps) ; return 0 ; case WM_DESTROY: PostQuitMessage (0) ; return 0 ; } return DefWindowProc (hwnd, message, wParam, lParam) ; }
void ServiceEntity::draw(void) { ODL_OBJENTER(); //#### ServiceViewerApp & owner = _panel.getOwner(); _panel.draw(); if (_drawConnectMarker) { ofPoint markerPos(_panel.getWidth() / 2, _panel.getHeader()); ofSetColor(ServiceViewerApp::getMarkerColor()); ofFill(); ofCircle(markerPos + getShape().getTopLeft(), kMarkerSide / 2); } else if (_drawDisconnectMarker) { ofPoint markerPos(_panel.getWidth() / 2, _panel.getHeader()); ofSetColor(ServiceViewerApp::getMarkerColor()); ofNoFill(); ofSetLineWidth(2); ofCircle(markerPos + getShape().getTopLeft(), kMarkerSide / 2); } else if (_drawMoveMarker) { ofPoint markerPos(_panel.getWidth() / 2, _panel.getHeader()); ofSetColor(ServiceViewerApp::getMarkerColor()); ofFill(); markerPos += getShape().getTopLeft() - ofPoint(kMarkerSide / 2, kMarkerSide / 2); ofRect(markerPos, kMarkerSide, kMarkerSide); } for (int ii = 0, mm = _panel.getNumPorts(); mm > ii; ++ii) { PortEntry * anEntry = _panel.getPort(ii); if (anEntry) { ofPoint aCentre(anEntry->getCentre()); const PortEntry::Connections & connex = anEntry->getOutputConnections(); for (PortEntry::Connections::const_iterator walker(connex.begin()); connex.end() != walker; ++walker) { PortEntry::AnchorSide anchorHere; PortEntry::AnchorSide anchorThere; MplusM::Common::ChannelMode mode = walker->_connectionMode; PortEntry * otherEntry = walker->_otherPort; ofPoint otherCentre(otherEntry->getCentre()); ofPoint fromHere; ofPoint toThere; // Check if the destination is above the source, in which case we // determine the anchors in the reverse order. if (aCentre.y < otherCentre.y) { anchorHere = anEntry->calculateClosestAnchor(fromHere, true, false, otherCentre); anchorThere = otherEntry->calculateClosestAnchor(toThere, false, PortEntry::kAnchorBottomCentre == anchorHere, aCentre); } else { anchorThere = otherEntry->calculateClosestAnchor(toThere, false, false, aCentre); anchorHere = anEntry->calculateClosestAnchor(fromHere, true, PortEntry::kAnchorBottomCentre == anchorThere, otherCentre); } if (otherEntry->isService()) { ofSetLineWidth(owner.getServiceConnectionWidth()); } else if (otherEntry->isInputOutput()) { ofSetLineWidth(owner.getInputOutputConnectionWidth()); } else { ofSetLineWidth(owner.getNormalConnectionWidth()); } switch (mode) { case MplusM::Common::kChannelModeTCP : ofSetColor(ServiceViewerApp::getTcpConnectionColor()); break; case MplusM::Common::kChannelModeUDP : ofSetColor(ServiceViewerApp::getUdpConnectionColor()); break; default : ofSetColor(ServiceViewerApp::getOtherConnectionColor()); break; } DrawBezier(fromHere, toThere, aCentre, otherCentre); ofSetLineWidth(1); PortEntry::drawSourceAnchor(anchorHere, fromHere); PortEntry::drawTargetAnchor(anchorThere, toThere); } } } ODL_OBJEXIT(); //#### } // ServiceEntity::draw
MAGICK_NET_EXPORT void DrawingWand_Bezier(DrawingWand *instance, const PointInfo *coordinates, const size_t length, ExceptionInfo **exception) { DrawBezier(instance, length, coordinates); MAGICK_NET_SET_DRAW_EXCEPTION; }