aboutsummaryrefslogtreecommitdiff
path: root/osx.m
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2005-07-03 09:35:29 +0000
committerSimon Tatham <anakin@pobox.com>2005-07-03 09:35:29 +0000
commit64e114cce121e55f0f90cb5692c5020d917aa202 (patch)
tree57186385bcb66066feff354d9f23c400d4e360e4 /osx.m
parent8dd7ee300726872072075a5cdb35ebe9497e3adb (diff)
downloadpuzzles-64e114cce121e55f0f90cb5692c5020d917aa202.zip
puzzles-64e114cce121e55f0f90cb5692c5020d917aa202.tar.gz
puzzles-64e114cce121e55f0f90cb5692c5020d917aa202.tar.bz2
puzzles-64e114cce121e55f0f90cb5692c5020d917aa202.tar.xz
draw_polygon() and draw_circle() have always had a portability
constraint: because some front ends interpret `draw filled shape' to mean `including its boundary' while others interpret it to mean `not including its boundary' (and X seems to vacillate between the two opinions as it moves around the shape!), you MUST NOT draw a filled shape only. You can fill in one colour and outline in another, you can fill or outline in the same colour, or you can just outline, but just filling is a no-no. This leads to a _lot_ of double calls to these functions, so I've changed the interface. draw_circle() and draw_polygon() now each take two colour arguments, a fill colour (which can be -1 for none) and an outline colour (which must be valid). This should simplify code in the game back ends, while also reducing the possibility for coding error. [originally from svn r6047]
Diffstat (limited to 'osx.m')
-rw-r--r--osx.m32
1 files changed, 18 insertions, 14 deletions
diff --git a/osx.m b/osx.m
index b009cd7..c3f6d1b 100644
--- a/osx.m
+++ b/osx.m
@@ -1216,16 +1216,13 @@ struct frontend {
* Drawing routines called by the midend.
*/
void draw_polygon(frontend *fe, int *coords, int npoints,
- int fill, int colour)
+ int fillcolour, int outlinecolour)
{
NSBezierPath *path = [NSBezierPath bezierPath];
int i;
[[NSGraphicsContext currentContext] setShouldAntialias:YES];
- assert(colour >= 0 && colour < fe->ncolours);
- [fe->colours[colour] set];
-
for (i = 0; i < npoints; i++) {
NSPoint p = { coords[i*2] + 0.5, coords[i*2+1] + 0.5 };
if (i == 0)
@@ -1236,30 +1233,37 @@ void draw_polygon(frontend *fe, int *coords, int npoints,
[path closePath];
- if (fill)
+ if (fillcolour >= 0) {
+ assert(fillcolour >= 0 && fillcolour < fe->ncolours);
+ [fe->colours[fillcolour] set];
[path fill];
- else
- [path stroke];
+ }
+
+ assert(outlinecolour >= 0 && outlinecolour < fe->ncolours);
+ [fe->colours[outlinecolour] set];
+ [path stroke];
}
void draw_circle(frontend *fe, int cx, int cy, int radius,
- int fill, int colour)
+ int fillcolour, int outlinecolour)
{
NSBezierPath *path = [NSBezierPath bezierPath];
[[NSGraphicsContext currentContext] setShouldAntialias:YES];
- assert(colour >= 0 && colour < fe->ncolours);
- [fe->colours[colour] set];
-
[path appendBezierPathWithArcWithCenter:NSMakePoint(cx + 0.5, cy + 0.5)
radius:radius startAngle:0.0 endAngle:360.0];
[path closePath];
- if (fill)
+ if (fillcolour >= 0) {
+ assert(fillcolour >= 0 && fillcolour < fe->ncolours);
+ [fe->colours[fillcolour] set];
[path fill];
- else
- [path stroke];
+ }
+
+ assert(outlinecolour >= 0 && outlinecolour < fe->ncolours);
+ [fe->colours[outlinecolour] set];
+ [path stroke];
}
void draw_line(frontend *fe, int x1, int y1, int x2, int y2, int colour)
{