Ejemplo n.º 1
0
static int
settings_get (cairo_t *cr, settings_t *settings)
{
    int count;

    settings->op = cairo_get_operator (cr);
    settings->tolerance = cairo_get_tolerance (cr);
    settings->fill_rule = cairo_get_fill_rule (cr);
    settings->line_width = cairo_get_line_width (cr);
    settings->line_cap = cairo_get_line_cap (cr);
    settings->line_join = cairo_get_line_join (cr);
    settings->miter_limit = cairo_get_miter_limit (cr);
    cairo_get_matrix (cr, &settings->matrix);

    count = cairo_get_dash_count (cr);
    if (count != 5)
	return -1;

    cairo_get_dash (cr, settings->dash, &settings->dash_offset);

    return 0;
}
Ejemplo n.º 2
0
static cairo_path_t *
_cairo_path_create_internal (cairo_path_fixed_t *path_fixed,
			     cairo_t		*cr,
			     cairo_bool_t	 flatten)
{
    cairo_path_t *path;

    path = xmemory_alloc (sizeof (cairo_path_t));
    if (unlikely (path == XNULL)) {
	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
	return (cairo_path_t*) &_cairo_path_nil;
    }

    path->num_data = _cairo_path_count (path, path_fixed,
					cairo_get_tolerance (cr),
					flatten);
    if (path->num_data < 0) {
	xmemory_free (path);
	return (cairo_path_t*) &_cairo_path_nil;
    }

    if (path->num_data) {
	path->data = _cairo_malloc_ab (path->num_data,
				       sizeof (cairo_path_data_t));
	if (unlikely (path->data == XNULL)) {
	    xmemory_free (path);
	    _cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
	    return (cairo_path_t*) &_cairo_path_nil;
	}

	path->status = _cairo_path_populate (path, path_fixed, cr, flatten);
    } else {
	path->data = XNULL;
	path->status = CAIRO_STATUS_SUCCESS;
    }

    return path;
}
Ejemplo n.º 3
0
static cairo_status_t
_cairo_path_populate (cairo_path_t		*path,
		      cairo_path_fixed_t	*path_fixed,
		      cairo_t			*cr,
		      cairo_bool_t		 flatten)
{
    cairo_status_t status;
    cpp_t cpp;

    cpp.data = path->data;
    cpp.cr = cr;

    if (flatten) {
	status = _cairo_path_fixed_interpret_flat (path_fixed,
						   _cpp_move_to,
						   _cpp_line_to,
						   _cpp_close_path,
						   &cpp,
						   cairo_get_tolerance (cr));
    } else {
	status = _cairo_path_fixed_interpret (path_fixed,
					  _cpp_move_to,
					  _cpp_line_to,
					  _cpp_curve_to,
					  _cpp_close_path,
					  &cpp);
    }

    if (unlikely (status))
	return status;

    /* Sanity check the count */
    XASSERT (cpp.data - path->data == path->num_data);

    return CAIRO_STATUS_SUCCESS;
}
Ejemplo n.º 4
0
	double lime_cairo_get_tolerance (value handle) {
		
		return cairo_get_tolerance ((cairo_t*)val_data (handle));
		
	}
Ejemplo n.º 5
0
	double lime_cairo_get_tolerance (double handle) {
		
		return cairo_get_tolerance ((cairo_t*)(intptr_t)handle);
		
	}
static PyObject *
pycairo_get_tolerance (PycairoContext *o)
{
    return PyFloat_FromDouble (cairo_get_tolerance (o->ctx));
}
Ejemplo n.º 7
0
double Context::getTolerance() const
{
	return cairo_get_tolerance( mCairo );
}
Ejemplo n.º 8
0
static VALUE
cr_get_tolerance (VALUE self)
{
  return rb_float_new (cairo_get_tolerance (_SELF));
}
Ejemplo n.º 9
0
static void
_cairo_arc_in_direction (cairo_t	  *cr,
			 double		   xc,
			 double		   yc,
			 double		   radius,
			 double		   angle_min,
			 double		   angle_max,
			 cairo_direction_t dir)
{
    if (cairo_status (cr))
        return;

    XASSERT (angle_max >= angle_min);

    if (angle_max - angle_min > 2 * M_PI * MAX_FULL_CIRCLES) {
	angle_max = fmod (angle_max - angle_min, 2 * M_PI);
	angle_min = fmod (angle_min, 2 * M_PI);
	angle_max += angle_min + 2 * M_PI * MAX_FULL_CIRCLES;
    }

    /* Recurse if drawing arc larger than pi */
    if (angle_max - angle_min > M_PI) {
	double angle_mid = angle_min + (angle_max - angle_min) / 2.0;
	if (dir == CAIRO_DIRECTION_FORWARD) {
	    _cairo_arc_in_direction (cr, xc, yc, radius,
				     angle_min, angle_mid,
				     dir);

	    _cairo_arc_in_direction (cr, xc, yc, radius,
				     angle_mid, angle_max,
				     dir);
	} else {
	    _cairo_arc_in_direction (cr, xc, yc, radius,
				     angle_mid, angle_max,
				     dir);

	    _cairo_arc_in_direction (cr, xc, yc, radius,
				     angle_min, angle_mid,
				     dir);
	}
    } else if (angle_max != angle_min) {
	cairo_matrix_t ctm;
	int i, segments;
	double step;

	cairo_get_matrix (cr, &ctm);
	segments = _arc_segments_needed (angle_max - angle_min,
					 radius, &ctm,
					 cairo_get_tolerance (cr));
	step = (angle_max - angle_min) / segments;
	segments -= 1;

	if (dir == CAIRO_DIRECTION_REVERSE) {
	    double t;

	    t = angle_min;
	    angle_min = angle_max;
	    angle_max = t;

	    step = -step;
	}

	for (i = 0; i < segments; i++, angle_min += step) {
	    _cairo_arc_segment (cr, xc, yc, radius,
				angle_min, angle_min + step);
	}

	_cairo_arc_segment (cr, xc, yc, radius,
			    angle_min, angle_max);
    } else {
	cairo_line_to (cr,
		       xc + radius * cos (angle_min),
		       yc + radius * sin (angle_min));
    }
}
Ejemplo n.º 10
0
static int
cr_get_tolerance (lua_State *L) {
    cairo_t **obj = luaL_checkudata(L, 1, OOCAIRO_MT_NAME_CONTEXT);
    lua_pushnumber(L, cairo_get_tolerance(*obj));
    return 1;
}