Mercurial > dwindows
changeset 1282:4f0f816f1e76
Update to draw as an ellipse and fix for circles on OS/2.
This sort of works but it really needs more work.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 31 Oct 2011 02:39:40 +0000 |
parents | fe92a6f6d3e7 |
children | 87d6d11b6323 |
files | dwtest.c os2/dw.c |
diffstat | 2 files changed, 48 insertions(+), 29 deletions(-) [+] |
line wrap: on
line diff
--- a/dwtest.c Mon Oct 31 00:57:54 2011 +0000 +++ b/dwtest.c Mon Oct 31 02:39:40 2011 +0000 @@ -369,7 +369,7 @@ dw_color_foreground_set(DW_CLR_BLUE); dw_draw_polygon(window, pixmap, TRUE, 7, x, y); dw_color_foreground_set(DW_CLR_BLACK); - dw_draw_rect(window, pixmap, DW_DRAW_FILL, 80, 80, 40, 40); + dw_draw_rect(window, pixmap, DW_DRAW_FILL, 80, 80, 80, 40); dw_color_foreground_set(DW_CLR_CYAN); /* Bottom right corner */ dw_draw_arc(window, pixmap, 0, width - 30, height - 30, width - 10, height - 30, width - 30, height - 10); @@ -378,7 +378,7 @@ /* Bottom left corner */ dw_draw_arc(window, pixmap, 0, 30, height - 30, 30, height - 10, 10, height - 30); /* Full circle in the left top area */ - dw_draw_arc(window, pixmap, DW_DRAW_FULL, 100, 100, 80, 80, 120, 120); + dw_draw_arc(window, pixmap, DW_DRAW_FULL, 120, 100, 80, 80, 160, 120); if(image) { if(image_stretch)
--- a/os2/dw.c Mon Oct 31 00:57:54 2011 +0000 +++ b/os2/dw.c Mon Oct 31 02:39:40 2011 +0000 @@ -8687,14 +8687,6 @@ POINTL pts[2]; double r, a1, a2, a; - /* Handle full circle/ellipse */ - if(flags & DW_DRAW_FULL) - { - /* Draw one half... */ - dw_draw_arc(handle, pixmap, flags & ~DW_DRAW_FULL, xorigin, yorigin, x2, y2, x1, y1); - /* ... then continue to draw the other half */ - } - if(handle) { hps = _set_colors(handle); @@ -8713,25 +8705,52 @@ GpiBeginArea(hps, 0L); /* Setup the arc info on the presentation space */ GpiSetArcParams(hps, &ap); - pts[0].x = x1; - pts[0].y = thisheight - y1 - 1; - /* Move to the initial position */ - GpiMove(hps, pts); - /* Calculate the midpoint */ - r = 0.5 * (hypot((double)(y1 - yorigin), (double)(x1 - xorigin)) + - hypot((double)(y2 - yorigin), (double)(x2 - xorigin))); - a1 = atan2((double)(y1 - yorigin), (double)(x1 - xorigin)); - a2 = atan2((double)(y2 - yorigin), (double)(x2 - xorigin)); - if(a2 < a1) - a2 += M_PI * 2; - a = (a1 + a2) / 2.; - /* Prepare to draw */ - pts[0].x = (int)(xorigin + r * cos(a)); - pts[0].y = thisheight - (int)(yorigin + r * sin(a)) - 1; - pts[1].x = x2; - pts[1].y = thisheight - y2 - 1; - /* Actually draw the arc */ - GpiPointArc(hps, pts); + + /* Handle full circle/ellipse */ + if(flags & DW_DRAW_FULL) + { + int xmid = ((x2 - x1)/2) + x1; + int ymid = ((y2 - y1)/2) + y1; + + /* Draw one half... */ + pts[0].x = x1; + pts[0].y = thisheight - ymid - 1; + GpiMove(hps, pts); + pts[0].x = xmid; + pts[0].y = thisheight - y1 - 1; + pts[1].x = x2; + pts[1].y = thisheight - ymid - 1; + GpiPointArc(hps, pts); + /* ... then continue to draw the other half */ + GpiMove(hps, &pts[1]); + pts[0].x = xmid; + pts[0].y = thisheight - y2 - 1; + pts[1].x = x1; + pts[1].y = thisheight - ymid - 1; + GpiPointArc(hps, pts); + } + else + { + pts[0].x = x1; + pts[0].y = thisheight - y1 - 1; + /* Move to the initial position */ + GpiMove(hps, pts); + /* Calculate the midpoint */ + r = 0.5 * (hypot((double)(y1 - yorigin), (double)(x1 - xorigin)) + + hypot((double)(y2 - yorigin), (double)(x2 - xorigin))); + a1 = atan2((double)(y1 - yorigin), (double)(x1 - xorigin)); + a2 = atan2((double)(y2 - yorigin), (double)(x2 - xorigin)); + if(a2 < a1) + a2 += M_PI * 2; + a = (a1 + a2) / 2.; + /* Prepare to draw */ + pts[0].x = (int)(xorigin + r * cos(a)); + pts[0].y = thisheight - (int)(yorigin + r * sin(a)) - 1; + pts[1].x = x2; + pts[1].y = thisheight - y2 - 1; + /* Actually draw the arc */ + GpiPointArc(hps, pts); + } if(flags & DW_DRAW_FILL) GpiEndArea(hps);