# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1319935222 0 # Node ID 9e477efbacca25f197b0c864bb250fff8d6a4dfb # Parent 148daf522080f1cc51cdbcd29ccb8fd983e70680 Added DW_DRAW_DEFAULT, DW_DRAW_FILL and DW_DRAW_FULL drawing flags. Adde some more arc segments and full circle commands to test program. diff -r 148daf522080 -r 9e477efbacca dw.h --- a/dw.h Tue Oct 25 12:33:09 2011 +0000 +++ b/dw.h Sun Oct 30 00:40:22 2011 +0000 @@ -1412,6 +1412,12 @@ #define DW_HTML_STOP 5 #define DW_HTML_PRINT 6 +/* Drawing flags... used for Arc currently */ +#define DW_DRAW_DEFAULT 0 +#define DW_DRAW_FILL 1 +#define DW_DRAW_FULL (1 << 1) + + /* Macro for casting resource IDs to HICN */ #define DW_RESOURCE(a) (a < 65536 ? (HICN)a : (HICN)0) diff -r 148daf522080 -r 9e477efbacca dwtest.c --- a/dwtest.c Tue Oct 25 12:33:09 2011 +0000 +++ b/dwtest.c Sun Oct 30 00:40:22 2011 +0000 @@ -369,7 +369,14 @@ dw_color_foreground_set(DW_CLR_BLUE); dw_draw_polygon(window, pixmap, TRUE, 7, x, y); 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); + /* Top right corner */ + dw_draw_arc(window, pixmap, 0, width - 30, 30, width - 30, 10, width - 10, 30); + /* 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, 0, 100, 100, 80, 80, 120, 120); if(image) { if(image_stretch) diff -r 148daf522080 -r 9e477efbacca mac/dw.m --- a/mac/dw.m Tue Oct 25 12:33:09 2011 +0000 +++ b/mac/dw.m Sun Oct 30 00:40:22 2011 +0000 @@ -5267,18 +5267,32 @@ NSColor *color = pthread_getspecific(_dw_fg_color_key); [color set]; - [aPath moveToPoint:NSMakePoint(x1, y1)]; - /* 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 */ - [aPath appendBezierPathWithArcFromPoint:NSMakePoint((xorigin + r * cos(a)), (yorigin + r * sin(a))) - toPoint:NSMakePoint(x2, y2) radius:r]; + /* Special state of a full circle/oval */ + if(flags & DW_DRAW_FULL) + { + [aPath appendBezierPathWithOvalInRect:NSMakeRect(x1, y1, x2, y2)]; + } + else + { + [aPath moveToPoint:NSMakePoint(x1, y1)]; + /* 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 */ + [aPath appendBezierPathWithArcFromPoint:NSMakePoint((xorigin + r * cos(a)), (yorigin + r * sin(a))) + toPoint:NSMakePoint(x2, y2) radius:r]; + } + /* If the fill flag is passed */ + if(flags & DW_DRAW_FILL) + { + [aPath fill]; + } + /* Actually do the drawing */ [aPath stroke]; if(pixmap) {