Exemplo n.º 1
0
static gboolean
goo_canvas_polyline_is_item_at (GooCanvasItemSimple *simple,
				gdouble              x,
				gdouble              y,
				cairo_t             *cr,
				gboolean             is_pointer_event)
{
  GooCanvasItemSimpleData *simple_data = simple->simple_data;
  GooCanvasPolyline *polyline = (GooCanvasPolyline*) simple;
  GooCanvasPolylineData *polyline_data = polyline->polyline_data;
  GooCanvasPointerEvents pointer_events = GOO_CANVAS_EVENTS_ALL;
  gboolean do_stroke;

  if (polyline_data->num_points == 0)
    return FALSE;

  /* Check if the item should receive events. */
  if (is_pointer_event)
    pointer_events = simple_data->pointer_events;

  /* If the path isn't closed, we never check the fill. */
  if (!(polyline_data->close_path && polyline_data->num_points > 2))
    pointer_events &= ~GOO_CANVAS_EVENTS_FILL_MASK;

  goo_canvas_polyline_create_path (polyline, cr);
  if (goo_canvas_item_simple_check_in_path (simple, x, y, cr, pointer_events))
    return TRUE;

  /* Check the arrows, if the polyline has them. */
  if ((polyline_data->start_arrow || polyline_data->end_arrow)
      && polyline_data->num_points >= 2
      && (pointer_events & GOO_CANVAS_EVENTS_STROKE_MASK))
    {
      /* We use the stroke pattern to match the style of the line. */
      do_stroke = goo_canvas_style_set_stroke_options (simple_data->style, cr);
      if (!(pointer_events & GOO_CANVAS_EVENTS_PAINTED_MASK) || do_stroke)
	{
	  if (polyline_data->start_arrow)
	    {
	      goo_canvas_polyline_create_start_arrow_path (polyline, cr);
	      if (cairo_in_fill (cr, x, y))
		return TRUE;
	    }

	  if (polyline_data->end_arrow)
	    {
	      goo_canvas_polyline_create_end_arrow_path (polyline, cr);
	      if (cairo_in_fill (cr, x, y))
		return TRUE;
	    }
	}
    }

  return FALSE;
}
Exemplo n.º 2
0
static cairo_test_status_t
preamble (cairo_test_context_t *ctx)
{
    int x,y;
    int width = 10;
    int height = 10;
    cairo_surface_t *surf;
    cairo_t *cr;
    int false_positive_count = 0;
    cairo_status_t status;
    cairo_test_status_t ret;

    surf = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
    cr = cairo_create (surf);
    cairo_surface_destroy (surf);

    /* Empty horizontal trapezoid. */
    cairo_move_to (cr, 0, height/3);
    cairo_line_to (cr, width, height/3);
    cairo_close_path (cr);

    /* Empty non-horizontal trapezoid #1. */
    cairo_move_to (cr, 0, 0);
    cairo_line_to (cr, width, height/2);
    cairo_close_path (cr);

    /* Empty non-horizontal trapezoid #2 intersecting #1. */
    cairo_move_to (cr, 0, height/2);
    cairo_line_to (cr, width, 0);
    cairo_close_path (cr);

    status = cairo_status (cr);

    /* Point sample the tessellated path. */
    for (y = 0; y < height; y++) {
	for (x = 0; x < width; x++) {
	    if (cairo_in_fill (cr, x, y)) {
		false_positive_count++;
	    }
	}
    }
    cairo_destroy (cr);

    /* Check that everything went well. */
    ret = CAIRO_TEST_SUCCESS;
    if (CAIRO_STATUS_SUCCESS != status) {
	cairo_test_log (ctx, "Failed to create a test surface and path: %s\n",
			cairo_status_to_string (status));
	ret = CAIRO_TEST_XFAILURE;
    }

    if (0 != false_positive_count) {
	cairo_test_log (ctx, "Point sampling found %d false positives "
			"from cairo_in_fill()\n",
			false_positive_count);
	ret = CAIRO_TEST_XFAILURE;
    }

    return ret;
}
Exemplo n.º 3
0
static int
cr_in_fill (lua_State *L) {
    cairo_t **obj = luaL_checkudata(L, 1, OOCAIRO_MT_NAME_CONTEXT);
    lua_pushboolean(L,
        cairo_in_fill(*obj, luaL_checknumber(L, 2), luaL_checknumber(L, 3)));
    return 1;
}
Exemplo n.º 4
0
Arquivo: media.cpp Projeto: snorp/moon
bool
Image::InsideObject (cairo_t *cr, double x, double y)
{
	if (!FrameworkElement::InsideObject (cr, x, y))
		return false;

	cairo_save (cr);
	cairo_new_path (cr);
	cairo_set_matrix (cr, &absolute_xform);

	double nx = x;
	double ny = y;

	TransformPoint (&nx, &ny);

	Render (cr, NULL, true);
	bool inside = cairo_in_fill (cr, nx, ny);
	cairo_restore (cr);

	if (inside)
		inside = InsideLayoutClip (x, y);

	if (inside)
		inside = InsideClip (cr, x, y);

	return inside;
}
static GeglNode *detect (GeglOperation *operation,
                         gint           x,
                         gint           y)
{
  GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
  cairo_t *cr;
  cairo_surface_t *surface;
  gchar *data = "     ";
  gboolean result = FALSE;

  surface = cairo_image_surface_create_for_data ((guchar*)data,
                                                 CAIRO_FORMAT_ARGB32,
                                                 1,1,4);
  cr = cairo_create (surface);
  gegl_path_cairo_play (o->d, cr);

  if (!result)
    {
      if (o->d)
        {
          gdouble r,g,b,a;
          gegl_color_get_rgba (o->color, &r,&g,&b,&a);
          if (a * o->opacity>0.8)
            result = cairo_in_fill (cr, x, y);
        }
    }

  cairo_destroy (cr);

  if (result)
    return operation->node;

  return NULL;
}
Exemplo n.º 6
0
CAMLprim value
ml_cairo_in_fill (value v_cr, value p)
{
  cairo_bool_t c_ret;
  c_ret =
    cairo_in_fill (cairo_t_val (v_cr), Double_field (p, 0), Double_field (p, 1));
  check_cairo_status (v_cr);
  return Val_bool (c_ret);
}
Exemplo n.º 7
0
static VALUE
cr_in_fill (VALUE self, VALUE x, VALUE y)
{
  if (rb_block_given_p ())
    {
      cr_new_path (self);
      rb_yield (self);
    }
  return CBOOL2RVAL (cairo_in_fill (_SELF, NUM2DBL (x), NUM2DBL (y)));
}
Exemplo n.º 8
0
static int cairo_in_fill_l( lua_State* L )
{
  lua_cairo_t* lc = lua_cairo_check( L, 1 );

  lua_pushboolean( L, cairo_in_fill( lc->cairo,
                                     luaL_checknumber( L, 2 ),     /* x */
                                     luaL_checknumber( L, 3 ) ) ); /* y */

  return( 1 );
}
Exemplo n.º 9
0
bool Path::contains(const FloatPoint& point, WindRule rule) const
{
    if (!isfinite(point.x()) || !isfinite(point.y()))
        return false;
    cairo_t* cr = platformPath()->context();
    cairo_fill_rule_t cur = cairo_get_fill_rule(cr);
    cairo_set_fill_rule(cr, rule == RULE_EVENODD ? CAIRO_FILL_RULE_EVEN_ODD : CAIRO_FILL_RULE_WINDING);
    bool contains = cairo_in_fill(cr, point.x(), point.y());
    cairo_set_fill_rule(cr, cur);
    return contains;
}
Exemplo n.º 10
0
bool
PathCairo::ContainsPoint(const Point &aPoint, const Matrix &aTransform) const
{
  Matrix inverse = aTransform;
  inverse.Invert();
  Point transformed = inverse * aPoint;

  EnsureContainingContext();

  return cairo_in_fill(mContainingContext, transformed.x, transformed.y);
}
Exemplo n.º 11
0
bool
PathCairo::ContainsPoint(const Point &aPoint, const Matrix &aTransform) const
{
  CairoTempMatrix(*mPathContext, mTransform);

  Matrix inverse = aTransform;
  inverse.Invert();
  Point transformed = inverse * aPoint;

  // Needs the correct fill rule set.
  cairo_set_fill_rule(*mPathContext, GfxFillRuleToCairoFillRule(mFillRule));
  return cairo_in_fill(*mPathContext, transformed.x, transformed.y);
}
Exemplo n.º 12
0
static PyObject *
pycairo_in_fill (PycairoContext *o, PyObject *args) {
  double x, y;
  PyObject *result;

  if (!PyArg_ParseTuple (args, "dd:Context.in_fill", &x, &y))
    return NULL;

  result = cairo_in_fill (o->ctx, x, y) ? Py_True : Py_False;
  RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
  Py_INCREF(result);
  return result;
}
static PyObject *
pycairo_in_fill (PycairoContext *o, PyObject *args)
{
    double x, y;
    PyObject *result;

    if (!PyArg_ParseTuple (args, "dd:Context.in_fill", &x, &y))
	return NULL;

    result = cairo_in_fill (o->ctx, x, y) ? Py_True : Py_False;
    if (Pycairo_Check_Status (cairo_status (o->ctx)))
	return NULL;
    Py_INCREF(result);
    return result;
}
Exemplo n.º 14
0
bool
Border::InsideObject (cairo_t *cr, double x, double y)
{
	if (!FrameworkElement::InsideObject (cr, x, y))
		return false;

	cairo_save (cr);
	cairo_new_path (cr);
	cairo_set_matrix (cr, &absolute_xform);

	TransformPoint (&x, &y);

	Render (cr, NULL, true);
	cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
	bool inside = cairo_in_fill (cr, x, y);
	cairo_restore (cr);

	return inside;
}
Exemplo n.º 15
0
static cairo_perf_ticks_t
mosaic_perform(cairo_t *cr, unsigned flags, int width, int height, int loops)
{
    struct mosaic_region_iter iter;

    /* Scale to fit the window.*/
    double minx = -40.7;
    double maxx = 955.1;
    double miny = -88.4;
    double maxy = 884.5;

    cairo_identity_matrix (cr);

    if (flags & MOSAIC_FILL) {
	cairo_set_source_rgb (cr, 1, 1, 1);
	cairo_rectangle (cr, 0, 0, width, height);
	cairo_fill (cr);
    }

    cairo_scale (cr, width / (maxx - minx) , height / (maxy - miny));
    cairo_translate (cr, -minx, -miny);

    /* Iterate over all closed regions in the mosaic filling or
     * tessellating them as dictated by the flags.  */

    cairo_perf_timer_start ();
    while (loops--) {
	mosaic_region_iter_init (&iter, flags & MOSAIC_CURVE_TO);
	while (mosaic_next_path (cr, &iter)) {
	    if (flags & MOSAIC_FILL) {
		cairo_fill (cr);
	    }
	    else {
		double x, y;
		cairo_get_current_point (cr, &x, &y);
		cairo_in_fill (cr, x, y);
	    }
	}
    }
    cairo_perf_timer_stop ();

    return cairo_perf_timer_elapsed ();
}
Exemplo n.º 16
0
static cairo_perf_ticks_t
zrusin_another_tessellate (cairo_t *cr, int width, int height, int loops)
{
    zrusin_another_path (cr);

    cairo_perf_timer_start ();

    /* We'd like to measure just tessellation without
     * rasterization. For now, we can do that with cairo_in_fill. But
     * we'll have to be careful since cairo_in_fill might eventually
     * be optimized to have an implementation that doesn't necessarily
     * include tessellation. */
    while (loops--)
	cairo_in_fill (cr, 50, 50);

    cairo_perf_timer_stop ();

    cairo_new_path (cr);

    return cairo_perf_timer_elapsed ();
}
Exemplo n.º 17
0
static cairo_perf_ticks_t
do_tessellate (cairo_t *cr, int num_points)
{
    int i;

    for (i=0; i < num_points; i++)
	cairo_line_to (cr, points[i].x, points[i].y);

    cairo_perf_timer_start ();

    /* We'd like to measure just tessellation without
     * rasterization. For now, we can do that with cairo_in_fill. But
     * we'll have to be careful since cairo_in_fill might eventually
     * be optimized to have an implementation that doesn't necessarily
     * include tessellation. */
    cairo_in_fill (cr, 50, 50);

    cairo_perf_timer_stop ();

    cairo_new_path (cr);

    return cairo_perf_timer_elapsed ();
}
Exemplo n.º 18
0
static void
draw_check_if_object_is_in_selected_area (cairo_t *cairoTarget,
		gboolean isStroke, gerbv_selection_info_t *selectionInfo,
		gerbv_image_t *image, struct gerbv_net *net,
		enum draw_mode drawMode)
{
	gerbv_selection_item_t sItem = {image, net};
	gdouble corner1X, corner1Y, corner2X, corner2Y;
	gdouble x1, x2, y1, y2;
	gdouble minX, minY, maxX, maxY;

	corner1X = selectionInfo->lowerLeftX;
	corner1Y = selectionInfo->lowerLeftY;
	corner2X = selectionInfo->upperRightX;
	corner2Y = selectionInfo->upperRightY;

	/* calculate the coordinate of the user's click in the current
	   transformation matrix */
	cairo_device_to_user (cairoTarget, &corner1X, &corner1Y);
	cairo_device_to_user (cairoTarget, &corner2X, &corner2Y);

	switch (selectionInfo->type) {
	case GERBV_SELECTION_POINT_CLICK:
		/* use the cairo in_fill routine to see if the point is within the
		   drawn area */
		if ((isStroke && cairo_in_stroke (cairoTarget, corner1X, corner1Y)) ||
			(!isStroke && cairo_in_fill (cairoTarget, corner1X, corner1Y))) {

			if (!draw_net_is_in_selection_buffer_remove (net,
					selectionInfo,
					(drawMode == FIND_SELECTIONS_TOGGLE))) {
				selection_add_item (selectionInfo, &sItem);
			}
		}
		break;

	case GERBV_SELECTION_DRAG_BOX:
		/* we can't assume the "lowerleft" corner is actually in the lower left,
		   since the cairo transformation matrix may be mirrored,etc */
		minX = MIN(corner1X,corner2X);
		maxX = MAX(corner1X,corner2X);
		minY = MIN(corner1Y,corner2Y);
		maxY = MAX(corner1Y,corner2Y);

		if (isStroke)
			cairo_stroke_extents (cairoTarget, &x1, &y1, &x2, &y2);
		else
			cairo_fill_extents (cairoTarget, &x1, &y1, &x2, &y2);

		if ((minX < x1) && (minY < y1) && (maxX > x2) && (maxY > y2)) {
			if (!draw_net_is_in_selection_buffer_remove (net,
					selectionInfo,
					(drawMode == FIND_SELECTIONS_TOGGLE))) {
				selection_add_item (selectionInfo, &sItem);
			}
		}
		break;
	default:
		break;
	}
	/* clear the path, since we didn't actually draw it and cairo
		 doesn't reset it after the previous calls */
	cairo_new_path (cairoTarget);
}
Exemplo n.º 19
0
	bool lime_cairo_in_fill (value handle, double x, double y) {
		
		return cairo_in_fill ((cairo_t*)val_data (handle), x, y);
		
	}
Exemplo n.º 20
0
bool
gfxContext::PointInFill(const gfxPoint& pt)
{
    return cairo_in_fill(mCairo, pt.x, pt.y);
}
Exemplo n.º 21
0
	bool lime_cairo_in_fill (double handle, double x, double y) {
		
		return cairo_in_fill ((cairo_t*)(intptr_t)handle, x, y);
		
	}
Exemplo n.º 22
0
static cairo_test_status_t
preamble (cairo_test_context_t *ctx)
{
    cairo_test_status_t ret = CAIRO_TEST_SUCCESS;
    cairo_surface_t *surface;
    cairo_t *cr;

    surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 0, 0);
    cr = cairo_create (surface);
    cairo_surface_destroy (surface);

    cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);

    /* simple rectangle */
    cairo_new_path (cr);
    cairo_rectangle (cr, -10, -10, 20, 20);
    if (! cairo_in_fill (cr, 0, 0)) {
	cairo_test_log (ctx, "Error: Failed to find point inside rectangle\n");
	ret = CAIRO_TEST_FAILURE;
    }

    /* rectangular boundary tests */
    if (! cairo_in_fill (cr, -10, -10)) {
	cairo_test_log (ctx, "Error: Failed to find top-left vertex inside rectangle\n");
	ret = CAIRO_TEST_FAILURE;
    }
    if (! cairo_in_fill (cr, -10, 10)) {
	cairo_test_log (ctx, "Error: Failed to find bottom-left vertex inside rectangle\n");
	ret = CAIRO_TEST_FAILURE;
    }
    if (! cairo_in_fill (cr, 10, -10)) {
	cairo_test_log (ctx, "Error: Failed to find top-right vertex inside rectangle\n");
	ret = CAIRO_TEST_FAILURE;
    }
    if (! cairo_in_fill (cr, 10, 10)) {
	cairo_test_log (ctx, "Error: Failed to find bottom-right vertex inside rectangle\n");
	ret = CAIRO_TEST_FAILURE;
    }
    if (! cairo_in_fill (cr, -10, 0)) {
	cairo_test_log (ctx, "Error: Failed to find left edge inside rectangle\n");
	ret = CAIRO_TEST_FAILURE;
    }
    if (! cairo_in_fill (cr, 0, -10)) {
	cairo_test_log (ctx, "Error: Failed to find top edge inside rectangle\n");
	ret = CAIRO_TEST_FAILURE;
    }
    if (! cairo_in_fill (cr, 10, 0)) {
	cairo_test_log (ctx, "Error: Failed to find right edge inside rectangle\n");
	ret = CAIRO_TEST_FAILURE;
    }
    if (! cairo_in_fill (cr, 0, 10)) {
	cairo_test_log (ctx, "Error: Failed to find bottom edge inside rectangle\n");
	ret = CAIRO_TEST_FAILURE;
    }

    /* simple circle */
    cairo_new_path (cr);
    cairo_arc (cr, 0, 0, 10, 0, 2 * M_PI);
    if (! cairo_in_fill (cr, 0, 0)) {
	cairo_test_log (ctx, "Error: Failed to find point inside circle [even-odd]\n");
	ret = CAIRO_TEST_FAILURE;
    }

    /* holey rectangle */
    cairo_new_path (cr);
    cairo_rectangle (cr, -10, -10, 20, 20);
    cairo_rectangle (cr, -5, -5, 10, 10);
    if (cairo_in_fill (cr, 0, 0)) {
	cairo_test_log (ctx, "Error: Found an unexpected point inside rectangular eo-hole\n");
	ret = CAIRO_TEST_FAILURE;
    }

    /* holey circle */
    cairo_new_path (cr);
    cairo_arc (cr, 0, 0, 10, 0, 2 * M_PI);
    cairo_arc (cr, 0, 0, 5, 0, 2 * M_PI);
    if (cairo_in_fill (cr, 0, 0)) {
	cairo_test_log (ctx, "Error: Found an unexpected point inside circular eo-hole\n");
	ret = CAIRO_TEST_FAILURE;
    }


    cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING);

    /* simple rectangle */
    cairo_new_path (cr);
    cairo_rectangle (cr, -10, -10, 20, 20);
    if (! cairo_in_fill (cr, 0, 0)) {
	cairo_test_log (ctx, "Error: Failed to find point inside rectangle\n");
	ret = CAIRO_TEST_FAILURE;
    }

    /* simple circle */
    cairo_new_path (cr);
    cairo_arc (cr, 0, 0, 10, 0, 2 * M_PI);
    if (! cairo_in_fill (cr, 0, 0)) {
	cairo_test_log (ctx, "Error: Failed to find point inside circle [nonzero]\n");
	ret = CAIRO_TEST_FAILURE;
    }

    /* overlapping circle/rectangle */
    cairo_new_path (cr);
    cairo_rectangle (cr, -10, -10, 20, 20);
    cairo_new_sub_path (cr);
    cairo_arc (cr, 0, 0, 10, 0, 2 * M_PI);
    if (! cairo_in_fill (cr, 0, 0)) {
	cairo_test_log (ctx, "Error: Failed to find point inside circle+rectangle\n");
	ret = CAIRO_TEST_FAILURE;
    }

    /* holey rectangle */
    cairo_new_path (cr);
    cairo_rectangle (cr, -10, -10, 20, 20);
    cairo_rectangle (cr, 5, -5, -10, 10);
    if (cairo_in_fill (cr, 0, 0)) {
	cairo_test_log (ctx, "Error: Found an unexpected point inside rectangular non-zero-hole\n");
	ret = CAIRO_TEST_FAILURE;
    }

    /* holey circle */
    cairo_new_path (cr);
    cairo_arc (cr, 0, 0, 10, 0, 2 * M_PI);
    cairo_arc_negative (cr, 0, 0, 5, 0, -2 * M_PI);
    if (cairo_in_fill (cr, 0, 0)) {
	cairo_test_log (ctx, "Error: Found an unexpected point inside circular non-zero-hole\n");
	ret = CAIRO_TEST_FAILURE;
    }

    /* not a holey circle */
    cairo_new_path (cr);
    cairo_arc (cr, 0, 0, 10, 0, 2 * M_PI);
    cairo_arc (cr, 0, 0, 5, 0, 2 * M_PI);
    if (! cairo_in_fill (cr, 0, 0)) {
	cairo_test_log (ctx, "Error: Failed to find point inside two circles\n");
	ret = CAIRO_TEST_FAILURE;
    }

    /* check off-centre */
    cairo_new_path (cr);
    cairo_arc (cr, 7.5, 0, 10, 0, 2 * M_PI);
    cairo_arc_negative (cr, 7.5, 0, 5, 0, -2 * M_PI);
    if (cairo_in_fill (cr, 7.5, 0)) {
	cairo_test_log (ctx, "Error: Found an unexpected point inside off-centre-x circular non-zero-hole\n");
	ret = CAIRO_TEST_FAILURE;
    }
    cairo_new_path (cr);
    cairo_arc (cr, 0, 7.5, 10, 0, 2 * M_PI);
    cairo_arc_negative (cr, 0, 7.5, 5, 0, -2 * M_PI);
    if (cairo_in_fill (cr, 0, 7.5)) {
	cairo_test_log (ctx, "Error: Found an unexpected point inside off-centre-y circular non-zero-hole\n");
	ret = CAIRO_TEST_FAILURE;
    }
    cairo_new_path (cr);
    cairo_arc (cr, 15, 0, 10, 0, 2 * M_PI);
    if (! cairo_in_fill (cr, 15, 0)) {
	cairo_test_log (ctx, "Error: Failed to find point inside off-centre-x circle\n");
	ret = CAIRO_TEST_FAILURE;
    }
    cairo_new_path (cr);
    cairo_arc (cr, 0, 15, 10, 0, 2 * M_PI);
    if (! cairo_in_fill (cr, 0, 15)) {
	cairo_test_log (ctx, "Error: Failed to find point inside off-centre-y circle\n");
	ret = CAIRO_TEST_FAILURE;
    }

    /* simple rectangle */
    cairo_new_path (cr);
    cairo_rectangle (cr, 10, 0, 5, 5);
    if (cairo_in_fill (cr, 0, 0)) {
	cairo_test_log (ctx, "Error: Found an unexpected point outside rectangle\n");
	ret = CAIRO_TEST_FAILURE;
    }
    if (cairo_in_fill (cr, 20, 20)) {
	cairo_test_log (ctx, "Error: Found an unexpected point outside rectangle\n");
	ret = CAIRO_TEST_FAILURE;
    }
    if (! cairo_in_fill (cr, 12.5, 2.5)) {
	cairo_test_log (ctx, "Error: Failed to find point inside rectangle\n");
	ret = CAIRO_TEST_FAILURE;
    }

    /* off-centre triangle */
    cairo_new_path (cr);
    cairo_move_to (cr, 10, 0);
    cairo_line_to (cr, 15, 5);
    cairo_line_to (cr, 5, 5);
    cairo_close_path (cr);
    if (cairo_in_fill (cr, 0, 0) ||
	cairo_in_fill (cr, 5, 0) ||
	cairo_in_fill (cr, 15, 0) ||
	cairo_in_fill (cr, 20, 0) ||
	cairo_in_fill (cr, 0, 10) ||
	cairo_in_fill (cr, 10, 10) ||
	cairo_in_fill (cr, 20, 10) ||
	cairo_in_fill (cr, 7, 2.5) ||
	cairo_in_fill (cr, 13, 2.5))
    {
	cairo_test_log (ctx,
			"Error: Found an unexpected point outside triangle\n"
			"\t(0, 0) -> %s\n"
			"\t(5, 0) -> %s\n"
			"\t(15, 0) -> %s\n"
			"\t(20, 0) -> %s\n"
			"\t(0, 10) -> %s\n"
			"\t(10, 10) -> %s\n"
			"\t(20, 10) -> %s\n"
			"\t(7, 2.5) -> %s\n"
			"\t(13, 2.5) -> %s\n",
			cairo_in_fill (cr, 0, 0) ? "inside" : "outside",
			cairo_in_fill (cr, 5, 0) ? "inside" : "outside",
			cairo_in_fill (cr, 15, 0) ? "inside" : "outside",
			cairo_in_fill (cr, 20, 0) ? "inside" : "outside",
			cairo_in_fill (cr, 0, 10) ? "inside" : "outside",
			cairo_in_fill (cr, 10, 10) ? "inside" : "outside",
			cairo_in_fill (cr, 20, 10) ? "inside" : "outside",
			cairo_in_fill (cr, 7, 2.5) ? "inside" : "outside",
			cairo_in_fill (cr, 13, 2.5) ? "inside" : "outside");
	ret = CAIRO_TEST_FAILURE;
    }
    if (! cairo_in_fill (cr, 7.5, 2.5) ||
	! cairo_in_fill (cr, 12.5, 2.5) ||
	! cairo_in_fill (cr, 10, 5))
    {
	cairo_test_log (ctx,
			"Error: Failed to find point on triangle edge\n"
			"\t(7.5, 2.5) -> %s\n"
			"\t(12.5, 2.5) -> %s\n"
			"\t(10, 5) -> %s\n",
			cairo_in_fill (cr, 7.5, 2.5) ? "inside" : "outside",
			cairo_in_fill (cr, 12.5, 2.5) ? "inside" : "outside",
			cairo_in_fill (cr, 10, 5) ? "inside" : "outside");
	ret = CAIRO_TEST_FAILURE;
    }
    if (! cairo_in_fill (cr, 8, 2.5) ||
	! cairo_in_fill (cr, 12, 2.5))
    {
	cairo_test_log (ctx, "Error: Failed to find point inside triangle\n");
	ret = CAIRO_TEST_FAILURE;
    }

    cairo_destroy (cr);

    return ret;
}
Exemplo n.º 23
0
bool Context::inFill( double x, double y )
{
	return static_cast<bool>( cairo_in_fill( mCairo, x, y ) != 0 );
}