#include <stdio.h>
#include <math.h>
-#include <gtk-canvas.h>
+#include <cairo.h>
+#include <libgnomecanvas/libgnomecanvas.h>
#include "canvas-simpleline.h"
#include "rgb_macros.h"
+#include "gettext.h"
+#define _(Text) dgettext (PACKAGE,Text)
enum {
- ARG_0,
- ARG_X1,
- ARG_Y1,
- ARG_X2,
- ARG_Y2,
- ARG_COLOR_RGBA
+ PROP_0,
+ PROP_X1,
+ PROP_Y1,
+ PROP_X2,
+ PROP_Y2,
+ PROP_COLOR_RGBA
};
-static void gtk_canvas_simpleline_class_init (GtkCanvasSimpleLineClass *class);
-static void gtk_canvas_simpleline_init (GtkCanvasSimpleLine *simpleline);
-static void gtk_canvas_simpleline_set_arg (GtkObject *object,
- GtkArg *arg,
- guint arg_id);
-static void gtk_canvas_simpleline_get_arg (GtkObject *object,
- GtkArg *arg,
- guint arg_id);
+static void gnome_canvas_simpleline_class_init (GnomeCanvasSimpleLineClass *class);
-static void gtk_canvas_simpleline_update (GtkCanvasItem *item, double *affine, ArtSVP *clip_path, int flags);
-static void gtk_canvas_simpleline_bounds (GtkCanvasItem *item, double *x1, double *y1, double *x2, double *y2);
-static double gtk_canvas_simpleline_point (GtkCanvasItem *item, double x, double y, int cx, int cy, GtkCanvasItem **actual_item);
-static void gtk_canvas_simpleline_render (GtkCanvasItem *item, GtkCanvasBuf *buf);
-static void gtk_canvas_simpleline_draw (GtkCanvasItem *item, GdkDrawable *drawable, int x, int y, int w, int h);
+static void gnome_canvas_simpleline_init (GnomeCanvasSimpleLine *simpleline);
-static GtkCanvasItemClass *parent_class;
+static void gnome_canvas_simpleline_destroy (GtkObject *object);
+static void gnome_canvas_simpleline_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void gnome_canvas_simpleline_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
-GtkType
-gtk_canvas_simpleline_get_type (void)
+static void gnome_canvas_simpleline_update (GnomeCanvasItem *item,
+ double *affine,
+ ArtSVP *clip_path,
+ int flags);
+
+static void gnome_canvas_simpleline_bounds (GnomeCanvasItem *item,
+ double *x1,
+ double *y1,
+ double *x2,
+ double *y2);
+
+static double gnome_canvas_simpleline_point (GnomeCanvasItem *item,
+ double x,
+ double y,
+ int cx,
+ int cy,
+ GnomeCanvasItem **actual_item);
+
+static void gnome_canvas_simpleline_render (GnomeCanvasItem *item,
+ GnomeCanvasBuf *buf);
+
+static void gnome_canvas_simpleline_draw (GnomeCanvasItem *item,
+ GdkDrawable *drawable,
+ int x,
+ int y,
+ int w,
+ int h);
+
+static GnomeCanvasItemClass *parent_class;
+
+
+GType
+gnome_canvas_simpleline_get_type (void)
{
- static GtkType simpleline_type = 0;
+ static GType simpleline_type;
if (!simpleline_type) {
- GtkTypeInfo simpleline_info = {
- "GtkCanvasSimpleLine",
- sizeof (GtkCanvasSimpleLine),
- sizeof (GtkCanvasSimpleLineClass),
- (GtkClassInitFunc) gtk_canvas_simpleline_class_init,
- (GtkObjectInitFunc) gtk_canvas_simpleline_init,
- NULL, /* reserved_1 */
- NULL, /* reserved_2 */
- (GtkClassInitFunc) NULL
+ static const GTypeInfo object_info = {
+ sizeof (GnomeCanvasSimpleLineClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) gnome_canvas_simpleline_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL, /* class_data */
+ sizeof (GnomeCanvasSimpleLine),
+ 0, /* n_preallocs */
+ (GInstanceInitFunc) gnome_canvas_simpleline_init,
+ NULL /* value_table */
};
- simpleline_type = gtk_type_unique (gtk_canvas_item_get_type (), &simpleline_info);
+ simpleline_type = g_type_register_static (GNOME_TYPE_CANVAS_ITEM, "GnomeCanvasSimpleLine",
+ &object_info, 0);
}
return simpleline_type;
}
static void
-gtk_canvas_simpleline_class_init (GtkCanvasSimpleLineClass *class)
+gnome_canvas_simpleline_class_init (GnomeCanvasSimpleLineClass *class)
{
+ GObjectClass *gobject_class;
GtkObjectClass *object_class;
- GtkCanvasItemClass *item_class;
+ GnomeCanvasItemClass *item_class;
+ gobject_class = (GObjectClass *) class;
object_class = (GtkObjectClass *) class;
- item_class = (GtkCanvasItemClass *) class;
-
- parent_class = gtk_type_class (gtk_canvas_item_get_type ());
-
- gtk_object_add_arg_type ("GtkCanvasSimpleLine::x1", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_X1);
- gtk_object_add_arg_type ("GtkCanvasSimpleLine::y1", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_Y1);
- gtk_object_add_arg_type ("GtkCanvasSimpleLine::x2", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_X2);
- gtk_object_add_arg_type ("GtkCanvasSimpleLine::y2", GTK_TYPE_DOUBLE, GTK_ARG_READWRITE, ARG_Y2);
- gtk_object_add_arg_type ("GtkCanvasSimpleLine::color_rgba", GTK_TYPE_INT, GTK_ARG_READWRITE, ARG_COLOR_RGBA);
-
- object_class->set_arg = gtk_canvas_simpleline_set_arg;
- object_class->get_arg = gtk_canvas_simpleline_get_arg;
-
- item_class->update = gtk_canvas_simpleline_update;
- item_class->bounds = gtk_canvas_simpleline_bounds;
- item_class->point = gtk_canvas_simpleline_point;
- item_class->render = gtk_canvas_simpleline_render;
- item_class->draw = gtk_canvas_simpleline_draw;
+ item_class = (GnomeCanvasItemClass *) class;
+
+ parent_class = g_type_class_peek_parent (class);
+
+ gobject_class->set_property = gnome_canvas_simpleline_set_property;
+ gobject_class->get_property = gnome_canvas_simpleline_get_property;
+
+ g_object_class_install_property (gobject_class,
+ PROP_X1,
+ g_param_spec_double ("x1",
+ _("x1"),
+ _("x coordinate of upper left corner of rect"),
+ -G_MAXDOUBLE,
+ G_MAXDOUBLE,
+ 0.0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (gobject_class,
+ PROP_Y1,
+ g_param_spec_double ("y1",
+ _("y1"),
+ _("y coordinate of upper left corner of rect "),
+ -G_MAXDOUBLE,
+ G_MAXDOUBLE,
+ 0.0,
+ G_PARAM_READWRITE));
+
+
+ g_object_class_install_property (gobject_class,
+ PROP_X2,
+ g_param_spec_double ("x2",
+ _("x2"),
+ _("x coordinate of lower right corner of rect"),
+ -G_MAXDOUBLE,
+ G_MAXDOUBLE,
+ 0.0,
+ G_PARAM_READWRITE));
+
+ g_object_class_install_property (gobject_class,
+ PROP_Y2,
+ g_param_spec_double ("y2",
+ _("y2"),
+ _("y coordinate of lower right corner of rect "),
+ -G_MAXDOUBLE,
+ G_MAXDOUBLE,
+ 0.0,
+ G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class,
+ PROP_COLOR_RGBA,
+ g_param_spec_uint ("color_rgba",
+ _("color rgba"),
+ _("color of line"),
+ 0,
+ G_MAXUINT,
+ 0,
+ G_PARAM_READWRITE));
+
+ object_class->destroy = gnome_canvas_simpleline_destroy;
+
+ item_class->update = gnome_canvas_simpleline_update;
+ item_class->bounds = gnome_canvas_simpleline_bounds;
+ item_class->point = gnome_canvas_simpleline_point;
+ item_class->render = gnome_canvas_simpleline_render;
+ item_class->draw = gnome_canvas_simpleline_draw;
}
static void
-gtk_canvas_simpleline_init (GtkCanvasSimpleLine *simpleline)
+gnome_canvas_simpleline_init (GnomeCanvasSimpleLine *simpleline)
{
simpleline->x1 = 0.0;
simpleline->y1 = 0.0;
simpleline->x2 = 0.0;
simpleline->y2 = 0.0;
simpleline->color = RGBA_TO_UINT(98,123,174,241);
- simpleline->horizontal = TRUE; /* reset in the _update() method */
- GTK_CANVAS_ITEM(simpleline)->object.flags |= GTK_CANVAS_ITEM_NO_AUTO_REDRAW;
}
static void
-gtk_canvas_simpleline_bounds_world (GtkCanvasItem *item, int* ix1, int* iy1, int* ix2, int* iy2)
-{
- double x1, x2, y1, y2;
- ArtPoint i1, i2;
- ArtPoint w1, w2;
- double i2w[6];
- GtkCanvasSimpleLine *simpleline = GTK_CANVAS_SIMPLELINE(item);
-
- gtk_canvas_simpleline_bounds (item, &x1, &y1, &x2, &y2);
-
- i1.x = x1;
- i1.y = y1;
- i2.x = x2;
- i2.y = y2;
-
- gtk_canvas_item_i2w_affine (item, i2w);
- art_affine_point (&w1, &i1, i2w);
- art_affine_point (&w2, &i2, i2w);
-
- *ix1 = (int) rint(w1.x);
- *ix2 = (int) rint(w2.x);
- *iy1 = (int) rint(w1.y);
- *iy2 = (int) rint(w2.y);
-
- /* the update rect has to be of non-zero width and height */
-
- if (x1 == x2) {
- simpleline->horizontal = FALSE;
- *ix2 += 1;
- } else {
- simpleline->horizontal = TRUE;
- *iy2 += 1;
- }
-}
-
-static void
-gtk_canvas_simpleline_reset_bounds (GtkCanvasItem *item)
+gnome_canvas_simpleline_destroy (GtkObject *object)
{
- int Ix1, Ix2, Iy1, Iy2;
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GNOME_IS_CANVAS_SIMPLELINE (object));
- gtk_canvas_simpleline_bounds_world (item, &Ix1, &Iy1, &Ix2, &Iy2);
- gtk_canvas_update_bbox (item, Ix1, Iy1, Ix2, Iy2);
+ if (GTK_OBJECT_CLASS (parent_class)->destroy)
+ (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
-/*
- * CANVAS CALLBACKS
+/*
+ * CANVAS CALLBACKS
*/
static void
-gtk_canvas_simpleline_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
+gnome_canvas_simpleline_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+
{
- GtkCanvasItem *item;
- GtkCanvasSimpleLine *simpleline;
- int redraw;
- int calc_bounds;
-
- item = GTK_CANVAS_ITEM (object);
- simpleline = GTK_CANVAS_SIMPLELINE (object);
-
- redraw = FALSE;
- calc_bounds = FALSE;
-
- switch (arg_id) {
- case ARG_X1:
- if (simpleline->x1 != GTK_VALUE_DOUBLE (*arg)) {
- simpleline->x1 = GTK_VALUE_DOUBLE (*arg);
- calc_bounds = TRUE;
+ (void) pspec;
+
+ GnomeCanvasSimpleLine *simpleline;
+ int update = FALSE;
+ int bounds_changed = FALSE;
+ double d;
+
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GNOME_IS_CANVAS_SIMPLELINE (object));
+
+ simpleline = GNOME_CANVAS_SIMPLELINE (object);
+
+ switch (prop_id) {
+ case PROP_X1:
+ d = g_value_get_double (value);
+ if (simpleline->x1 != d) {
+ simpleline->x1 = d;
+ bounds_changed = TRUE;
}
break;
- case ARG_Y1:
- if (simpleline->y1 != GTK_VALUE_DOUBLE (*arg)) {
- simpleline->y1 = GTK_VALUE_DOUBLE (*arg);
- calc_bounds = TRUE;
+ case PROP_Y1:
+ d = g_value_get_double (value);
+ if (simpleline->y1 != d) {
+ simpleline->y1 = d;
+ bounds_changed = TRUE;
}
break;
- case ARG_X2:
- if (simpleline->x2 != GTK_VALUE_DOUBLE (*arg)) {
- simpleline->x2 = GTK_VALUE_DOUBLE (*arg);
- calc_bounds = TRUE;
+ case PROP_X2:
+ d = g_value_get_double (value);
+ if (simpleline->x2 != d) {
+ simpleline->x2 = d;
+ bounds_changed = TRUE;
}
break;
- case ARG_Y2:
- if (simpleline->y2 != GTK_VALUE_DOUBLE (*arg)) {
- simpleline->y2 = GTK_VALUE_DOUBLE (*arg);
- calc_bounds = TRUE;
+ case PROP_Y2:
+ d = g_value_get_double (value);
+ if (simpleline->y2 != d) {
+ simpleline->y2 = d;
+ bounds_changed = TRUE;
}
break;
- case ARG_COLOR_RGBA:
- if (simpleline->color != GTK_VALUE_INT(*arg)) {
- simpleline->color = GTK_VALUE_INT(*arg);
+ case PROP_COLOR_RGBA:
+ if (simpleline->color != g_value_get_uint(value)) {
+ simpleline->color = g_value_get_uint(value);
UINT_TO_RGBA (simpleline->color, &simpleline->r, &simpleline->g, &simpleline->b, &simpleline->a);
- redraw = TRUE;
+ update = TRUE;
}
break;
-
default:
break;
}
-
- if (calc_bounds) {
- gtk_canvas_item_request_update (item);
-
- } else if (redraw) {
-
- int Ix1, Ix2, Iy1, Iy2;
- gtk_canvas_simpleline_bounds_world (item, &Ix1, &Iy1, &Ix2, &Iy2);
- gtk_canvas_request_redraw (item->canvas, Ix1, Iy1, Ix2, Iy2);
+ if (update || bounds_changed) {
+ gnome_canvas_item_request_update (GNOME_CANVAS_ITEM(object));
}
}
static void
-gtk_canvas_simpleline_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
+gnome_canvas_simpleline_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
{
- GtkCanvasSimpleLine *simpleline;
+ g_return_if_fail (object != NULL);
+ g_return_if_fail (GNOME_IS_CANVAS_SIMPLELINE (object));
- simpleline = GTK_CANVAS_SIMPLELINE (object);
+ GnomeCanvasSimpleLine *line = GNOME_CANVAS_SIMPLELINE (object);
- switch (arg_id) {
- case ARG_X1:
- GTK_VALUE_DOUBLE (*arg) = simpleline->x1;
+ switch (prop_id) {
+ case PROP_X1:
+ g_value_set_double (value, line->x1);
break;
- case ARG_Y1:
- GTK_VALUE_DOUBLE (*arg) = simpleline->y1;
+ case PROP_X2:
+ g_value_set_double (value, line->x2);
break;
- case ARG_X2:
- GTK_VALUE_DOUBLE (*arg) = simpleline->x2;
+ case PROP_Y1:
+ g_value_set_double (value, line->y1);
break;
- case ARG_Y2:
- GTK_VALUE_DOUBLE (*arg) = simpleline->y2;
+ case PROP_Y2:
+ g_value_set_double (value, line->y2);
break;
- case ARG_COLOR_RGBA:
- GTK_VALUE_INT (*arg) = simpleline->color;
+ case PROP_COLOR_RGBA:
+ g_value_set_uint (value, line->color);
break;
default:
- arg->type = GTK_TYPE_INVALID;
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
-gtk_canvas_simpleline_update (GtkCanvasItem *item, double *affine, ArtSVP *clip_path, int flags)
+gnome_canvas_simpleline_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags)
{
- GtkCanvasSimpleLine *simpleline;
- double x;
- double y;
+ GnomeCanvasSimpleLine *simpleline;
+ double x1, x2, y1, y2;
- simpleline = GTK_CANVAS_SIMPLELINE (item);
+ simpleline = GNOME_CANVAS_SIMPLELINE (item);
if (parent_class->update)
(* parent_class->update) (item, affine, clip_path, flags);
- gtk_canvas_simpleline_reset_bounds (item);
+ /* redraw old location */
+
+ gnome_canvas_request_redraw (item->canvas, item->x1, item->y1, item->x2, item->y2);
- x = simpleline->x1;
- y = simpleline->y1;
+ /* get current bounding box in parent-relative world coordinates */
- gtk_canvas_item_i2w (item, &x, &y);
- gtk_canvas_w2c (GTK_CANVAS(item->canvas), x, y, &simpleline->bbox_ulx, &simpleline->bbox_uly);
+ gnome_canvas_simpleline_bounds (item, &x1, &y1, &x2, &y2);
- x = simpleline->x2;
- y = simpleline->y2;
+ /* convert parent-relative item coordinates to world coordinates */
- gtk_canvas_item_i2w (item, &x, &y);
- gtk_canvas_w2c (GTK_CANVAS(item->canvas), x, y, &simpleline->bbox_lrx, &simpleline->bbox_lry);
+ gnome_canvas_item_i2w (item, &x1, &y1);
+ gnome_canvas_item_i2w (item, &x2, &y2);
+
+ /* don't suffer from rounding errors */
+
+ x1 = floor (x1);
+ y1 = floor (y1);
+ x2 = ceil (x2);
+ y2 = ceil (y2);
+
+ /* force non-zero dimensionality for both axes */
+
+ if (x1 == x2) {
+ x2 += 1.0;
+ }
+
+ if (y1 == y2) {
+ y2 += 1.0;
+ }
+
+ /* reset item bounding box (canvas coordinates, so integral. but stored in doubles) */
+
+ gnome_canvas_w2c_d (GNOME_CANVAS(item->canvas), x1, y1, &item->x1, &item->y1);
+ gnome_canvas_w2c_d (GNOME_CANVAS(item->canvas), x2, y2, &item->x2, &item->y2);
+
+ /* redraw new location */
+
+ gnome_canvas_request_redraw (item->canvas, item->x1, item->y1, item->x2, item->y2);
+
+ /* store actual line coords as canvas coordinates for use in render() */
+
+ x1 = simpleline->x1;
+ y1 = simpleline->y1;
+ x2 = simpleline->x2;
+ y2 = simpleline->y2;
+ /* convert to world */
+ gnome_canvas_item_i2w (item, &x1, &y1);
+ gnome_canvas_item_i2w (item, &x2, &y2);
+ /* avoid rounding errors */
+ x1 = (int) floor (item->x1);
+ y1 = (int) floor (item->y1);
+ x2 = (int) ceil (item->x2);
+ y2 = (int) ceil (item->y2);
+ /* convert to canvas coordinates, integral, stored in integers */
+ gnome_canvas_w2c (GNOME_CANVAS(item->canvas), x1, y1, &simpleline->cx1, &simpleline->cy1);
+ gnome_canvas_w2c (GNOME_CANVAS(item->canvas), x2, y2, &simpleline->cx2, &simpleline->cy2);
}
static void
-gtk_canvas_simpleline_render (GtkCanvasItem *item,
- GtkCanvasBuf *buf)
+gnome_canvas_simpleline_render (GnomeCanvasItem *item,
+ GnomeCanvasBuf *buf)
{
- GtkCanvasSimpleLine *simpleline;
- int end, begin;
+ GnomeCanvasSimpleLine *simpleline;
+ int x1, x2;
+ int y1, y2;
- simpleline = GTK_CANVAS_SIMPLELINE (item);
+ simpleline = GNOME_CANVAS_SIMPLELINE (item);
- if (parent_class->render) {
- (*parent_class->render) (item, buf);
- }
+ x1 = simpleline->cx1;
+ x2 = simpleline->cx2;
+ y1 = simpleline->cy1;
if (buf->is_bg) {
- gtk_canvas_buf_ensure_buf (buf);
+ gnome_canvas_buf_ensure_buf (buf);
buf->is_bg = FALSE;
}
- // begin = MAX(simpleline->bbox_ulx,buf->rect.x0);
- // end = MIN(simpleline->bbox_lrx,buf->rect.x1);
-
- begin = simpleline->bbox_ulx;
- end = simpleline->bbox_lrx;
-
- if (simpleline->color != 0) {
- if (simpleline->horizontal) {
- PAINT_HORIZA(buf, simpleline->r, simpleline->g, simpleline->b, simpleline->a,
- begin, end, simpleline->bbox_uly);
- } else {
- PAINT_VERTA(buf, simpleline->r, simpleline->g, simpleline->b, simpleline->a,
- begin, simpleline->bbox_uly, simpleline->bbox_lry);
- }
- }
+ if (simpleline->x1 != simpleline->x2) {
+ PAINT_HORIZA(buf, simpleline->r, simpleline->g, simpleline->b, simpleline->a,
+ x1, x2, y1);
+ } else {
+ y2 = simpleline->cy2;
+ PAINT_VERTA (buf, simpleline->r, simpleline->g, simpleline->b, simpleline->a,
+ x1, y1, y2);
+
+ }
}
static void
-gtk_canvas_simpleline_draw (GtkCanvasItem *item,
- GdkDrawable *drawable,
- int x, int y,
- int width, int height)
+gnome_canvas_simpleline_draw (GnomeCanvasItem* canvas,
+ GdkDrawable* drawable,
+ int x, int y,
+ int width, int height)
{
- GtkCanvasSimpleLine *simpleline;
-
- simpleline = GTK_CANVAS_SIMPLELINE (item);
-
- if (parent_class->draw) {
- (* parent_class->draw) (item, drawable, x, y, width, height);
- }
-
- fprintf (stderr, "please don't use the CanvasSimpleLine item in a non-aa Canvas\n");
- abort ();
+ /* XXX not implemented */
}
static void
-gtk_canvas_simpleline_bounds (GtkCanvasItem *item, double *x1, double *y1, double *x2, double *y2)
+gnome_canvas_simpleline_bounds (GnomeCanvasItem *item, double *x1, double *y1, double *x2, double *y2)
{
- GtkCanvasSimpleLine *simpleline = GTK_CANVAS_SIMPLELINE (item);
+ GnomeCanvasSimpleLine *simpleline = GNOME_CANVAS_SIMPLELINE (item);
- *x1 = simpleline->x1;
- *y1 = simpleline->y1;
- *x2 = simpleline->x2;
- *y2 = simpleline->y2;
+ *x1 = simpleline->x1;
+ *y1 = simpleline->y1;
+ *x2 = simpleline->x1;
+ *y2 = simpleline->y2;
}
static double
-gtk_canvas_simpleline_point (GtkCanvasItem *item, double x, double y, int cx, int cy, GtkCanvasItem **actual_item)
+gnome_canvas_simpleline_point (GnomeCanvasItem *item, double x, double y, int cx, int cy, GnomeCanvasItem **actual_item)
{
- GtkCanvasSimpleLine *simpleline;
+ (void) cx;
+ (void) cy;
+
double x1, y1, x2, y2;
double dx, dy;
- simpleline = GTK_CANVAS_SIMPLELINE (item);
-
*actual_item = item;
- /* Find the bounds for the rectangle plus its outline width */
+ /* Find the bounds for the line */
- gtk_canvas_simpleline_bounds (item, &x1, &y1, &x2, &y2);
+ gnome_canvas_simpleline_bounds (item, &x1, &y1, &x2, &y2);
+
+ /* Is point inside line */
- /* Is point inside rectangle */
-
if ((x >= x1) && (y >= y1) && (x <= x2) && (y <= y2)) {
return 0.0;
}
-
- /* Point is outside rectangle */
+ /* Point is outside line */
if (x < x1)
dx = x1 - x;