Mercurial > dwindows
comparison os2/dw.c @ 1261:61d0c5f84644
Initial attempt at adding dw_draw_arc() support on all platforms.
This code doesn't yet work... will probably require a bunch of fixes...
but I wanted to get the code committed while doing research on it.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 25 Oct 2011 10:51:59 +0000 |
parents | 3cbd8de0b50b |
children | 4b0aa8429592 |
comparison
equal
deleted
inserted
replaced
1260:3cbd8de0b50b | 1261:61d0c5f84644 |
---|---|
26 #include <stddef.h> | 26 #include <stddef.h> |
27 #include <ctype.h> | 27 #include <ctype.h> |
28 #include <process.h> | 28 #include <process.h> |
29 #include <time.h> | 29 #include <time.h> |
30 #include <io.h> | 30 #include <io.h> |
31 #include <math.h> | |
31 #ifndef __EMX__ | 32 #ifndef __EMX__ |
32 #include <direct.h> | 33 #include <direct.h> |
33 #endif | 34 #endif |
34 #include <sys/time.h> | 35 #include <sys/time.h> |
35 #include "dw.h" | 36 #include "dw.h" |
8657 | 8658 |
8658 if(!pixmap) | 8659 if(!pixmap) |
8659 WinReleasePS(hps); | 8660 WinReleasePS(hps); |
8660 } | 8661 } |
8661 | 8662 |
8663 /* Draw an arc on a window (preferably a render window). | |
8664 * Parameters: | |
8665 * handle: Handle to the window. | |
8666 * pixmap: Handle to the pixmap. (choose only one of these) | |
8667 * flags: For future use. | |
8668 * xorigin: X coordinate of center of arc. | |
8669 * yorigin: Y coordinate of center of arc. | |
8670 * x1: X coordinate of first segment of arc. | |
8671 * y1: Y coordinate of first segment of arc. | |
8672 * x2: X coordinate of second segment of arc. | |
8673 * y2: Y coordinate of second segment of arc. | |
8674 */ | |
8675 void API dw_draw_arc(HWND handle, HPIXMAP pixmap, int flags, int xorigin, int yorigin, int x1, int y1, int x2, int y2) | |
8676 { | |
8677 HPS hps; | |
8678 int thisheight; | |
8679 ARCPARAMS ap = { 1, 1, 0, 0 }; | |
8680 POINTL pts[2]; | |
8681 double r, a1, a2, a; | |
8682 int x3, y3; | |
8683 | |
8684 if(handle) | |
8685 { | |
8686 hps = _set_colors(handle); | |
8687 thisheight = _get_height(handle); | |
8688 } | |
8689 else if(pixmap) | |
8690 { | |
8691 hps = _set_hps(pixmap->hps); | |
8692 thisheight = pixmap->height; | |
8693 } | |
8694 else | |
8695 return; | |
8696 | |
8697 /* Setup the arc info on the presentation space */ | |
8698 GpiSetArcParams(hps, &ap); | |
8699 pts[0].x = x1; | |
8700 pts[0].y = thisheight - y1 - 1; | |
8701 /* Move to the initial position */ | |
8702 GpiMove(hps, pts); | |
8703 /* Calculate the midpoint */ | |
8704 r = 0.5 * (hypot((double)(y1 - yorigin), (double)(x1 - xorigin)) + | |
8705 hypot((double)(y2 - yorigin), (double)(x2 - xorigin))); | |
8706 a1 = atan2((double)(y1 - yorigin), (double)(x1 - xorigin)); | |
8707 a2 = atan2((double)(y2 - yorigin), (double)(x2 - xorigin)); | |
8708 if(a2 < a1) | |
8709 a2 += M_PI * 2; | |
8710 a = (a1 + a2) / 2.; | |
8711 /* Prepare to draw */ | |
8712 pts[0].x = (int)(xorigin + r * cos(a)); | |
8713 pts[0].y = thisheight - (int)(yorigin + r * sin(a)) - 1; | |
8714 pts[1].x = x2; | |
8715 pts[1].y = thisheight - y2 - 1; | |
8716 /* Actually draw the arc */ | |
8717 GpiPointArc(hps, pts); | |
8718 | |
8719 if(!pixmap) | |
8720 WinReleasePS(hps); | |
8721 } | |
8722 | |
8662 /* Call this after drawing to the screen to make sure | 8723 /* Call this after drawing to the screen to make sure |
8663 * anything you have drawn is visible. | 8724 * anything you have drawn is visible. |
8664 */ | 8725 */ |
8665 void API dw_flush(void) | 8726 void API dw_flush(void) |
8666 { | 8727 { |