Exemple #1
0
static PyObject *
pycairo_has_current_point (PycairoContext *o) {
  PyObject *b = cairo_has_current_point (o->ctx) ? Py_True : Py_False;
  RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
  Py_INCREF(b);
  return b;
}
Exemple #2
0
static void
relative_move(cairo_t *cr, double x, double y)
{
  if (cairo_has_current_point(cr)) {
    cairo_rel_move_to(cr, x, y);
  } else {
    cairo_move_to(cr, x, y);
  }
}
Exemple #3
0
cairo_t *
gsk_cairo_blur_start_drawing (cairo_t         *cr,
                              float            radius,
                              GskBlurFlags     blur_flags)
{
  cairo_rectangle_int_t clip_rect;
  cairo_surface_t *surface;
  cairo_t *blur_cr;
  gdouble clip_radius;
  gdouble x_scale, y_scale;
  gboolean blur_x = (blur_flags & GSK_BLUR_X) != 0;
  gboolean blur_y = (blur_flags & GSK_BLUR_Y) != 0;

  if (!needs_blur (radius))
    return cr;

  gdk_cairo_get_clip_rectangle (cr, &clip_rect);

  clip_radius = gsk_cairo_blur_compute_pixels (radius);

  x_scale = y_scale = 1;
  cairo_surface_get_device_scale (cairo_get_target (cr), &x_scale, &y_scale);

  if (blur_flags & GSK_BLUR_REPEAT)
    {
      if (!blur_x)
        clip_rect.width = 1;
      if (!blur_y)
        clip_rect.height = 1;
    }

  /* Create a larger surface to center the blur. */
  surface = cairo_surface_create_similar_image (cairo_get_target (cr),
                                                CAIRO_FORMAT_A8,
                                                x_scale * (clip_rect.width + (blur_x ? 2 * clip_radius : 0)),
                                                y_scale * (clip_rect.height + (blur_y ? 2 * clip_radius : 0)));
  cairo_surface_set_device_scale (surface, x_scale, y_scale);
  cairo_surface_set_device_offset (surface,
                                    x_scale * ((blur_x ? clip_radius : 0) - clip_rect.x),
                                    y_scale * ((blur_y ? clip_radius : 0) - clip_rect.y));

  blur_cr = cairo_create (surface);
  cairo_set_user_data (blur_cr, &original_cr_key, cairo_reference (cr), (cairo_destroy_func_t) cairo_destroy);

  if (cairo_has_current_point (cr))
    {
      double x, y;

      cairo_get_current_point (cr, &x, &y);
      cairo_move_to (blur_cr, x, y);
    }

  return blur_cr;
}
Exemple #4
0
static int
cr_get_current_point (lua_State *L) {
    cairo_t **obj = luaL_checkudata(L, 1, OOCAIRO_MT_NAME_CONTEXT);
    double x, y;
    if (!cairo_has_current_point(*obj))
        return 0;
    cairo_get_current_point(*obj, &x, &y);
    lua_pushnumber(L, x);
    lua_pushnumber(L, y);
    return 2;
}
Exemple #5
0
bool Path::isEmpty() const
{
    cairo_t* cr = platformPath()->m_cr;
#if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1,5,10)
    return !cairo_has_current_point(cr);
#else
    cairo_path_t* p = cairo_copy_path(cr);
    bool hasData = p->num_data;
    cairo_path_destroy(p);
    return !hasData;
#endif
}
Exemple #6
0
	bool lime_cairo_has_current_point (value handle) {
		
		return cairo_has_current_point ((cairo_t*)val_data (handle));
		
	}
Exemple #7
0
	bool lime_cairo_has_current_point (double handle) {
		
		return cairo_has_current_point ((cairo_t*)(intptr_t)handle);
		
	}
static VALUE
cr_has_current_point(VALUE self)
{
  return RTEST (cairo_has_current_point (_SELF));
}
Exemple #9
0
bool Path::isEmpty() const
{
    return !cairo_has_current_point(platformPath()->context());
}
Exemple #10
0
void
lsm_cairo_emit_svg_path (cairo_t *cr, char const *path)
{
	LsmSvgPathContext ctxt;

	g_return_if_fail (cr != NULL);

	if (path == NULL)
		return;

	ctxt.cr = cr;
	ctxt.ptr = (char *) path;
	ctxt.last_command = '\0';
	cairo_get_current_point (cr,
				 &ctxt.values[0],
				 &ctxt.values[1]);
	ctxt.values[2] = ctxt.values[4] = ctxt.values[0];
	ctxt.values[3] = ctxt.values[5] = ctxt.values[1];

	lsm_str_skip_spaces (&ctxt.ptr);

	while (*ctxt.ptr != '\0') {
		char command;

		command = *ctxt.ptr;
		ctxt.ptr++;
		lsm_str_skip_spaces (&ctxt.ptr);

		if (!cairo_has_current_point (cr)) {
			cairo_move_to (cr, 0, 0);
			ctxt.values[2] = ctxt.values[4] = ctxt.values[0] = 0;
			ctxt.values[3] = ctxt.values[5] = ctxt.values[1] = 0;
		}

		switch (command) {
			case 'M': _emit_function_2 (&ctxt, cairo_move_to, cairo_line_to); break;
			case 'm': _emit_function_2 (&ctxt, cairo_rel_move_to, cairo_rel_line_to); break;
			case 'L': _emit_function_2 (&ctxt, cairo_line_to, cairo_line_to); break;
			case 'l': _emit_function_2 (&ctxt, cairo_rel_line_to, cairo_rel_line_to); break;
			case 'C': _emit_function_6 (&ctxt, cairo_curve_to); break;
			case 'c': _emit_function_6 (&ctxt, cairo_rel_curve_to); break;
			case 'S': _emit_smooth_curve (&ctxt, FALSE); break;
			case 's': _emit_smooth_curve (&ctxt, TRUE); break;
			case 'V': _emit_function_1 (&ctxt, lsm_cairo_vertical); break;
			case 'v': _emit_function_1 (&ctxt, lsm_cairo_rel_vertical); break;
			case 'H': _emit_function_1 (&ctxt, lsm_cairo_horizontal); break;
			case 'h': _emit_function_1 (&ctxt, lsm_cairo_rel_horizontal); break;
			case 'Q': _emit_function_4 (&ctxt, lsm_cairo_quadratic_curve_to); break;
			case 'q': _emit_function_4 (&ctxt, lsm_cairo_rel_quadratic_curve_to); break;
			case 'T': _emit_smooth_quadratic_curve (&ctxt, FALSE); break;
			case 't': _emit_smooth_quadratic_curve (&ctxt, TRUE); break;
			case 'A': _emit_function_7 (&ctxt, lsm_cairo_elliptical_arc); break;
			case 'a': _emit_function_7 (&ctxt, lsm_cairo_rel_elliptical_arc); break;
			case 'Z':
			case 'z': cairo_close_path (cr); break;
			default: break;
		}

		ctxt.last_command = command;
	}
}
Exemple #11
0
static int
cr_has_current_point (lua_State *L) {
    cairo_t **obj = luaL_checkudata(L, 1, OOCAIRO_MT_NAME_CONTEXT);
    lua_pushboolean(L, cairo_has_current_point(*obj));
    return 1;
}