Exemple #1
0
static int
cr_get_dash (lua_State *L) {
    cairo_t **obj = luaL_checkudata(L, 1, OOCAIRO_MT_NAME_CONTEXT);
    int cnt, i;
    double *dashes = 0, offset;

    cnt = cairo_get_dash_count(*obj);
    if (cnt > 0) {
        dashes = malloc(sizeof(double) * cnt);
        assert(dashes);
    }

    cairo_get_dash(*obj, dashes, &offset);

    lua_createtable(L, cnt, 0);
    for (i = 0; i < cnt; ++i) {
        lua_pushnumber(L, dashes[i]);
        lua_rawseti(L, -2, i + 1);
    }
    lua_pushnumber(L, offset);

    if (cnt > 0)
        free(dashes);
    return 2;
}
Exemple #2
0
static PyObject *
pycairo_get_dash (PycairoContext *o) {
  double *dashes = NULL, offset;
  int count, i;
  PyObject *py_dashes = NULL, *rv = NULL;

  count = cairo_get_dash_count (o->ctx);
  dashes = PyMem_Malloc (count * sizeof(double));
  if (dashes == NULL)
    return PyErr_NoMemory();

  cairo_get_dash (o->ctx, dashes, &offset);
  py_dashes = PyTuple_New(count);
  if (py_dashes == NULL)
    goto exit;

  for (i = 0; i < count; i++) {
    PyObject *dash = PyFloat_FromDouble(dashes[i]);
    if (dash == NULL)
      goto exit;
    PyTuple_SET_ITEM (py_dashes, i, dash);
  }
  rv = Py_BuildValue("(Od)", py_dashes, offset);

 exit:
  PyMem_Free (dashes);
  Py_XDECREF(py_dashes);
  return rv;
}
gfxFloat
gfxContext::CurrentDashOffset() const
{
    if (cairo_get_dash_count(mCairo) <= 0) {
        return 0.0;
    }
    gfxFloat offset;
    cairo_get_dash(mCairo, NULL, &offset);
    return offset;
}
bool
gfxContext::CurrentDash(FallibleTArray<gfxFloat>& dashes, gfxFloat* offset) const
{
    int count = cairo_get_dash_count(mCairo);
    if (count <= 0 || !dashes.SetLength(count)) {
        return false;
    }
    cairo_get_dash(mCairo, dashes.Elements(), offset);
    return true;
}
static VALUE
cr_get_dash (VALUE self)
{
  int count;
  double *dashes, offset;

  count = cairo_get_dash_count (_SELF);
  dashes = ALLOCA_N (double, count);
  cairo_get_dash (_SELF, dashes, &offset);

  return rb_ary_new3 (2,
                      rb_cairo__float_array (dashes, count),
                      rb_float_new (offset));
}
Exemple #6
0
void copyContextProperties(cairo_t* srcCr, cairo_t* dstCr)
{
    cairo_set_antialias(dstCr, cairo_get_antialias(srcCr));

    size_t dashCount = cairo_get_dash_count(srcCr);
    Vector<double> dashes(dashCount);

    double offset;
    cairo_get_dash(srcCr, dashes.data(), &offset);
    cairo_set_dash(dstCr, dashes.data(), dashCount, offset);
    cairo_set_line_cap(dstCr, cairo_get_line_cap(srcCr));
    cairo_set_line_join(dstCr, cairo_get_line_join(srcCr));
    cairo_set_line_width(dstCr, cairo_get_line_width(srcCr));
    cairo_set_miter_limit(dstCr, cairo_get_miter_limit(srcCr));
    cairo_set_fill_rule(dstCr, cairo_get_fill_rule(srcCr));
}
Exemple #7
0
	value lime_cairo_get_dash (value handle) {
		
		int length = cairo_get_dash_count ((cairo_t*)val_data (handle));
		
		double* dashes = new double[length];
		double offset;
		
		cairo_get_dash ((cairo_t*)val_data (handle), dashes, &offset);
		
		value result = alloc_array (length);
		
		for (int i = 0; i < length; i++) {
			
			val_array_set_i (result, i, alloc_float (dashes[i]));
			
		}
		
		delete dashes;
		return result;
		
	}
Exemple #8
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;
}
Exemple #9
0
static int cairo_get_dash_l( lua_State* L )
{
  int index = 0;
  double offset = 0;
  double dashes[64] = {0};
  lua_cairo_t* lc = lua_cairo_check( L, 1 );
  int count = cairo_get_dash_count( lc->cairo );

  if ( 64 < count ) {
    luaL_error( L, "cairo_get_dash_count() returned a value (%d) greater than 64", count );
  }

  if ( lua_checkstack( L, count ) ) {
    luaL_error( L, "lua_checkstack( L, %d ) failed", count );
  }

  cairo_get_dash( lc->cairo, dashes, &offset );

  for ( index = 0; index < count; index++ ) {
    lua_pushnumber( L, dashes[index] );
  }

  return( count );
}
Exemple #10
0
void Context::getDash( double *dashes, double *offset )
{
	return cairo_get_dash( mCairo, dashes, offset );
}