예제 #1
0
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
    double x1, y1, x2, y2;

    cairo_move_to (cr, 0.0, 0.0);
    cairo_line_to (cr, 100.0, 100.0);
    cairo_set_line_width (cr, 0.0);

    cairo_set_line_cap (cr, CAIRO_LINE_CAP_BUTT);
    cairo_set_line_join (cr, CAIRO_LINE_JOIN_MITER);
    cairo_stroke_extents (cr, &x1, &y1, &x2, &y2);
    cairo_in_stroke (cr, 50, 50);
    cairo_stroke_preserve (cr);

    cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
    cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
    cairo_stroke_extents (cr, &x1, &y1, &x2, &y2);
    cairo_in_stroke (cr, 50, 50);
    cairo_stroke_preserve (cr);

    cairo_set_line_cap (cr, CAIRO_LINE_CAP_SQUARE);
    cairo_set_line_join (cr, CAIRO_LINE_JOIN_BEVEL);
    cairo_stroke_extents (cr, &x1, &y1, &x2, &y2);
    cairo_in_stroke (cr, 50, 50);
    cairo_stroke (cr);

    return CAIRO_TEST_SUCCESS;
}
예제 #2
0
static double
goc_polyline_distance (GocItem *item, double x, double y, GocItem **near_item)
{
	GocPolyline *polyline = GOC_POLYLINE (item);
	GOStyle *style = go_style_dup (go_styled_object_get_style (GO_STYLED_OBJECT (item)));
	double tmp_width = 0;
	double res = 20;
	double ppu = goc_canvas_get_pixels_per_unit (item->canvas);
	cairo_surface_t *surface;
	cairo_t *cr;

	if (polyline->nb_points == 0)
		return res;

	*near_item = item;
	tmp_width = style->line.width;
	if (style->line.width * ppu < 5)
		style->line.width = 5. / (ppu * ppu);
	else
		style->line.width /= ppu;
	surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
	cr = cairo_create (surface);

	if (goc_polyline_prepare_draw (item, cr, 0)) {
		if (cairo_in_stroke (cr, x, y))
			res = 0;
	}

	g_object_unref (style);
	cairo_destroy (cr);
	cairo_surface_destroy (surface);
	style->line.width = tmp_width;
	return res;
}
예제 #3
0
static int
cr_in_stroke (lua_State *L) {
    cairo_t **obj = luaL_checkudata(L, 1, OOCAIRO_MT_NAME_CONTEXT);
    lua_pushboolean(L,
        cairo_in_stroke(*obj, luaL_checknumber(L, 2), luaL_checknumber(L, 3)));
    return 1;
}
예제 #4
0
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);
  cairo_set_line_width (cr, o->width);


  if (o->width > 0.1 && o->opacity > 0.0001)
    result = cairo_in_stroke (cr, x, y);

  cairo_destroy (cr);

  if (result)
    return operation->node;

  return NULL;
}
예제 #5
0
파일: ml_cairo.c 프로젝트: DMClambo/pfff
CAMLprim value
ml_cairo_in_stroke (value v_cr, value p)
{
  cairo_bool_t c_ret;
  c_ret =
    cairo_in_stroke (cairo_t_val (v_cr), Double_field (p, 0), Double_field (p, 1));
  check_cairo_status (v_cr);
  return Val_bool (c_ret);
}
예제 #6
0
파일: PathCairo.cpp 프로젝트: bearmingo/UI
bool Path::strokeContains(StrokeStyleApplier* applier, const FloatPoint& point) const
{
    ASSERT(applier);
    cairo_t* cr = platformPath()->context();
    GraphicsContext gc(cr);
    applier->strokeStyle(&gc);

    return cairo_in_stroke(cr, point.x(), point.y());
}
예제 #7
0
bool RenderPath::strokeContains(const FloatPoint& point, bool requiresStroke) const
{
    if (requiresStroke && !KSVGPainterFactory::strokePaintServer(style(), this))
        return false;

    cairo_t* cr = path().platformPath()->m_cr;

    // TODO: set stroke properties
    return cairo_in_stroke(cr, point.x(), point.y());
}
예제 #8
0
static int cairo_in_stroke_l( lua_State* L )
{
  lua_cairo_t* lc = lua_cairo_check( L, 1 );

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

  return( 1 );
}
예제 #9
0
/* Insideness testing */
static VALUE
cr_in_stroke (VALUE self, VALUE x, VALUE y)
{
  if (rb_block_given_p ())
    {
      cr_new_path (self);
      rb_yield (self);
    }
  return CBOOL2RVAL (cairo_in_stroke (_SELF, NUM2DBL (x), NUM2DBL (y)));
}
예제 #10
0
static PyObject *
pycairo_in_stroke (PycairoContext *o, PyObject *args) {
  double x, y;
  PyObject *result;

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

  result = cairo_in_stroke (o->ctx, x, y) ? Py_True : Py_False;
  RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
  Py_INCREF(result);
  return result;
}
예제 #11
0
bool
PathCairo::StrokeContainsPoint(const StrokeOptions &aStrokeOptions,
                               const Point &aPoint,
                               const Matrix &aTransform) const
{
  CairoTempMatrix(*mPathContext, mTransform);

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

  SetCairoStrokeOptions(*mPathContext, aStrokeOptions);
  return cairo_in_stroke(*mPathContext, transformed.x, transformed.y);
}
예제 #12
0
bool
PathCairo::StrokeContainsPoint(const StrokeOptions &aStrokeOptions,
                               const Point &aPoint,
                               const Matrix &aTransform) const
{
  Matrix inverse = aTransform;
  inverse.Invert();
  Point transformed = inverse * aPoint;

  EnsureContainingContext();

  SetCairoStrokeOptions(mContainingContext, aStrokeOptions);

  return cairo_in_stroke(mContainingContext, transformed.x, transformed.y);
}
static PyObject *
pycairo_in_stroke (PycairoContext *o, PyObject *args)
{
    double x, y;
    PyObject *result;

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

    result = cairo_in_stroke (o->ctx, x, y) ? Py_True : Py_False;
    if (Pycairo_Check_Status (cairo_status (o->ctx)))
	return NULL;
    Py_INCREF(result);
    return result;
}
예제 #14
0
파일: draw.c 프로젝트: SayCV/geda-gerbv
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);
}
예제 #15
0
	bool lime_cairo_in_stroke (value handle, double x, double y) {
		
		return cairo_in_stroke ((cairo_t*)val_data (handle), x, y);
		
	}
예제 #16
0
	bool lime_cairo_in_stroke (double handle, double x, double y) {
		
		return cairo_in_stroke ((cairo_t*)(intptr_t)handle, x, y);
		
	}
예제 #17
0
bool Context::inStroke( double x, double y )
{
	return static_cast<bool>( cairo_in_stroke( mCairo, x, y ) != 0 );
}
예제 #18
0
bool
gfxContext::PointInStroke(const gfxPoint& pt)
{
    return cairo_in_stroke(mCairo, pt.x, pt.y);
}