Esempio n. 1
0
static void
_cpml_method_get_n_points(void)
{
    CpmlSegment segment;
    CpmlPrimitive primitive;
    size_t n_points;

    cpml_segment_from_cairo(&segment, (cairo_path_t *) adg_test_path());

    /* Line */
    cpml_primitive_from_segment(&primitive, &segment);
    n_points = cpml_primitive_get_n_points(&primitive);
    g_assert_cmpuint(n_points, ==, 2);

    /* Arc */
    cpml_primitive_next(&primitive);
    n_points = cpml_primitive_get_n_points(&primitive);
    g_assert_cmpuint(n_points, ==, 3);

    /* Curve */
    cpml_primitive_next(&primitive);
    n_points = cpml_primitive_get_n_points(&primitive);
    g_assert_cmpuint(n_points, ==, 4);

    /* Close: although the end point is not needed, the CPML API
     * returns 2 points to treat this primitive as a CPML_LINE */
    cpml_primitive_next(&primitive);
    n_points = cpml_primitive_get_n_points(&primitive);
    g_assert_cmpuint(n_points, ==, 2);
}
Esempio n. 2
0
static void
_cpml_sanity_get_n_points(gint i)
{
    switch (i) {
    case 1:
        cpml_primitive_get_n_points(NULL);
        break;
    default:
        g_test_trap_assert_failed();
        break;
    }
}
Esempio n. 3
0
/**
 * cpml_segment_transform:
 * @segment: a #CpmlSegment
 * @matrix: the matrix to be applied
 *
 * Applies @matrix on all the points of @segment.
 *
 * Since: 1.0
 **/
void
cpml_segment_transform(CpmlSegment *segment, const cairo_matrix_t *matrix)
{
    CpmlPrimitive primitive;
    cairo_path_data_t *data;
    size_t n_points;

    cpml_primitive_from_segment(&primitive, segment);
    cairo_matrix_transform_point(matrix, &(primitive.org)->point.x,
                                 &(primitive.org)->point.y);

    do {
        data = primitive.data;
        if (data->header.type != CPML_CLOSE) {
            n_points = cpml_primitive_get_n_points(&primitive);

            while (--n_points > 0) {
                ++data;
                cairo_matrix_transform_point(matrix,
                                             &data->point.x, &data->point.y);
            }
        }
    } while (cpml_primitive_next(&primitive));
}