Exemplo n.º 1
0
static PyObject *
vectors_remove_stroke(PyGimpVectors *self, PyObject *args, PyObject *kwargs)
{
    int stroke_id ;
    /* PyGimpVectorsStroke *stroke; */
    PyObject *stroke = NULL;

    static char *kwlist[] = { "stroke", NULL };

    PyArg_ParseTupleAndKeywords(args, kwargs, "O:remove_stroke", kwlist, &stroke);

    if (PyInt_Check(stroke))
        stroke_id = PyInt_AsLong(stroke);
    else if (PyObject_IsInstance(stroke, (PyObject *) &PyGimpVectorsStroke_Type))
        stroke_id = ((PyGimpVectorsStroke *) stroke)->stroke;
    else  {
        PyErr_SetString(PyExc_TypeError, "stroke must be a gimp.VectorsBezierStroke object or an Integer");
        return NULL;
    }

    gimp_vectors_remove_stroke(self->ID, stroke_id);

    Py_INCREF(Py_None);
    return Py_None;
}
Exemplo n.º 2
0
/* -------------------------------
 * p_set_2_vector_points
 * -------------------------------
 * remove all strokes from the active path vectors
 * and set a new stroke containing targetCoords (one or 2 depend on the valid flag)
 * For better visualisation set guide lines crossing at the first target coords.
 */
static void
p_set_2_vector_points(gint32 imageId, PixelCoords *targetCoords, PixelCoords *targetCoords2)
{
    gint32  activeVectorsId;
    /* gint    newStrokeId; */

    gdouble  *points;
    gint      num_points;
    gboolean  closed;
    GimpVectorsStrokeType type;


    gimp_image_add_hguide(imageId, targetCoords->py);
    gimp_image_add_vguide(imageId, targetCoords->px);


    activeVectorsId = gimp_image_get_active_vectors(imageId);
    if(activeVectorsId >= 0)
    {
        gint num_strokes;
        gint *strokes;

        strokes = gimp_vectors_get_strokes (activeVectorsId, &num_strokes);
        if(strokes)
        {
            if(num_strokes > 0)
            {
                gint ii;
                for(ii=0; ii < num_strokes; ii++)
                {
                    gimp_vectors_remove_stroke(activeVectorsId, strokes[ii]);
                }
            }
            g_free(strokes);

        }

        if (targetCoords->valid)
        {
            closed = FALSE;
            num_points = 6;
            if (targetCoords2->valid)
            {
                num_points = 12;
            }
            points = g_new (gdouble, num_points);
            points[0] = targetCoords->px;
            points[1] = targetCoords->py;
            points[2] = targetCoords->px;
            points[3] = targetCoords->py;
            points[4] = targetCoords->px;
            points[5] = targetCoords->py;
            if(targetCoords2->valid)
            {
                points[6] = targetCoords2->px;
                points[7] = targetCoords2->py;
                points[8] = targetCoords2->px;
                points[9] = targetCoords2->py;
                points[10] = targetCoords2->px;
                points[11] = targetCoords2->py;
            }

            type = GIMP_VECTORS_STROKE_TYPE_BEZIER;
            /* newStrokeId = */ gimp_vectors_stroke_new_from_points (activeVectorsId
                    , type
                    , num_points
                    , points
                    , closed
                                                                    );
            g_free(points);
        }


    }

}  /* end p_set_2_vector_points */