From 12829482a8ada0a8d3f16a7d67e510309a6010bd Mon Sep 17 00:00:00 2001 From: Stephen Adams Date: Fri, 12 Jul 1996 17:52:28 +0000 Subject: [PATCH] Added X-GRAPHICS-DRAW-ARC for drawing filled and unfilled arcs. --- v7/src/microcode/x11graph.c | 55 ++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/v7/src/microcode/x11graph.c b/v7/src/microcode/x11graph.c index 49c8a0e5d..f48f1ff90 100644 --- a/v7/src/microcode/x11graph.c +++ b/v7/src/microcode/x11graph.c @@ -1,6 +1,6 @@ /* -*-C-*- -$Id: x11graph.c,v 1.34 1995/09/18 22:33:08 cph Exp $ +$Id: x11graph.c,v 1.35 1996/07/12 17:52:28 adams Exp $ Copyright (c) 1989-95 Massachusetts Institute of Technology @@ -68,6 +68,10 @@ struct gw_extra #define ROUND_FLOAT(flonum) \ ((int) (((flonum) >= 0.0) ? ((flonum) + 0.5) : ((flonum) - 0.5))) +#define X_COORDINATE(virtual_device_x,xw) (ROUND_FLOAT(((XW_X_SLOPE (xw)) * (virtual_device_x - (XW_X_LEFT (xw)))))) + +#define Y_COORDINATE(virtual_device_y,xw) (((int) ((XW_Y_SIZE (xw)) - 1)) + (ROUND_FLOAT ((XW_Y_SLOPE (xw)) * (virtual_device_y - (XW_Y_BOTTOM (xw)))))) + static int DEFUN (arg_x_coordinate, (arg, xw), unsigned int arg AND @@ -460,6 +464,55 @@ Subsequently move the graphics cursor to those coordinates.") PRIMITIVE_RETURN (UNSPECIFIC); } +DEFINE_PRIMITIVE ("X-GRAPHICS-DRAW-ARC", Prim_x_graphics_draw_arc, 8, 8, + "(X-GRAPHICS-DRAW-ARC WINDOW X Y RADIUS-X RADIUS-Y START-ANGLE SWEEP-ANGLE FILL?)\n\ +Draw an arc at the given coordinates, with given X and Y radii.\n\ +START-ANGLE and SWEEP-ANGLE are in degrees, anti-clocwise.\n\ +START-ANGLE is from 3 o'clock, and SWEEP-ANGLE is relative to the START-ANGLE\n\ +If FILL? is true, the arc is filled.") +{ + PRIMITIVE_HEADER (3); + { + struct xwindow * xw = (x_window_arg (1)); + unsigned int internal_border_width = (XW_INTERNAL_BORDER_WIDTH (xw)); + float virtual_device_x = arg_real_number (2); + float virtual_device_y = arg_real_number (3); + float radius_x = arg_real_number (4); + float radius_y = arg_real_number (5); + float angle_start = arg_real_number (6); + float angle_sweep = arg_real_number (7); + + int x1 = X_COORDINATE (virtual_device_x - radius_x, xw); + int x2 = X_COORDINATE (virtual_device_x + radius_x, xw); + int y1 = Y_COORDINATE (virtual_device_y - radius_y, xw); + int y2 = Y_COORDINATE (virtual_device_y + radius_y, xw); + int width, height; + int angle1 = ((int)(angle_start * 64)); + int angle2 = ((int)(angle_sweep * 64)); + if (x2