void gimp_drawable_stroke_boundary (GimpDrawable *drawable, GimpStrokeOptions *options, const GimpBoundSeg *bound_segs, gint n_bound_segs, gint offset_x, gint offset_y, gboolean push_undo) { GimpScanConvert *scan_convert; g_return_if_fail (GIMP_IS_DRAWABLE (drawable)); g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable))); g_return_if_fail (GIMP_IS_STROKE_OPTIONS (options)); g_return_if_fail (bound_segs == NULL || n_bound_segs != 0); g_return_if_fail (gimp_fill_options_get_style (GIMP_FILL_OPTIONS (options)) != GIMP_FILL_STYLE_PATTERN || gimp_context_get_pattern (GIMP_CONTEXT (options)) != NULL); scan_convert = gimp_scan_convert_new_from_boundary (bound_segs, n_bound_segs, offset_x, offset_y); if (scan_convert) { gimp_drawable_stroke_scan_convert (drawable, options, scan_convert, push_undo); gimp_scan_convert_free (scan_convert); } }
void gimp_drawable_stroke_vectors (GimpDrawable *drawable, GimpStrokeOptions *options, GimpVectors *vectors) { GimpScanConvert *scan_convert; GimpStroke *stroke; gint num_coords = 0; g_return_if_fail (GIMP_IS_DRAWABLE (drawable)); g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable))); g_return_if_fail (GIMP_IS_STROKE_OPTIONS (options)); g_return_if_fail (GIMP_IS_VECTORS (vectors)); scan_convert = gimp_scan_convert_new (); /* For each Stroke in the vector, interpolate it, and add it to the * ScanConvert */ for (stroke = gimp_vectors_stroke_get_next (vectors, NULL); stroke; stroke = gimp_vectors_stroke_get_next (vectors, stroke)) { GArray *coords; gboolean closed; /* Get the interpolated version of this stroke, and add it to our * scanconvert. */ coords = gimp_stroke_interpolate (stroke, 0.2, &closed); if (coords && coords->len) { GimpVector2 *points = g_new0 (GimpVector2, coords->len); gint i; for (i = 0; i < coords->len; i++) { points[i].x = g_array_index (coords, GimpCoords, i).x; points[i].y = g_array_index (coords, GimpCoords, i).y; num_coords++; } gimp_scan_convert_add_polyline (scan_convert, coords->len, points, closed); g_free (points); } if (coords) g_array_free (coords, TRUE); } if (num_coords > 0) gimp_drawable_stroke_scan_convert (drawable, options, scan_convert); gimp_scan_convert_free (scan_convert); }
gboolean gimp_drawable_stroke_vectors (GimpDrawable *drawable, GimpStrokeOptions *options, GimpVectors *vectors, gboolean push_undo, GError **error) { const GimpBezierDesc *bezier; g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE); g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), FALSE); g_return_val_if_fail (GIMP_IS_STROKE_OPTIONS (options), FALSE); g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE); g_return_val_if_fail (gimp_fill_options_get_style (GIMP_FILL_OPTIONS (options)) != GIMP_FILL_STYLE_PATTERN || gimp_context_get_pattern (GIMP_CONTEXT (options)) != NULL, FALSE); g_return_val_if_fail (error == NULL || *error == NULL, FALSE); bezier = gimp_vectors_get_bezier (vectors); if (bezier && bezier->num_data >= 2) { GimpScanConvert *scan_convert = gimp_scan_convert_new (); gimp_scan_convert_add_bezier (scan_convert, bezier); gimp_drawable_stroke_scan_convert (drawable, options, scan_convert, push_undo); gimp_scan_convert_free (scan_convert); return TRUE; } g_set_error_literal (error, GIMP_ERROR, GIMP_FAILED, _("Not enough points to stroke")); return FALSE; }
void gimp_drawable_stroke_boundary (GimpDrawable *drawable, GimpStrokeOptions *options, const BoundSeg *bound_segs, gint n_bound_segs, gint offset_x, gint offset_y) { GimpScanConvert *scan_convert; BoundSeg *stroke_segs; gint n_stroke_segs; GimpVector2 *points; gint n_points; gint seg; gint i; g_return_if_fail (GIMP_IS_DRAWABLE (drawable)); g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable))); g_return_if_fail (GIMP_IS_STROKE_OPTIONS (options)); if (n_bound_segs == 0) return; g_return_if_fail (bound_segs != NULL); stroke_segs = boundary_sort (bound_segs, n_bound_segs, &n_stroke_segs); if (n_stroke_segs == 0) return; scan_convert = gimp_scan_convert_new (); points = g_new0 (GimpVector2, n_bound_segs + 4); seg = 0; n_points = 0; points[n_points].x = (gdouble) (stroke_segs[0].x1 + offset_x); points[n_points].y = (gdouble) (stroke_segs[0].y1 + offset_y); n_points++; for (i = 0; i < n_stroke_segs; i++) { while (stroke_segs[seg].x1 != -1 || stroke_segs[seg].x2 != -1 || stroke_segs[seg].y1 != -1 || stroke_segs[seg].y2 != -1) { points[n_points].x = (gdouble) (stroke_segs[seg].x1 + offset_x); points[n_points].y = (gdouble) (stroke_segs[seg].y1 + offset_y); n_points++; seg++; } /* Close the stroke points up */ points[n_points] = points[0]; n_points++; gimp_scan_convert_add_polyline (scan_convert, n_points, points, TRUE); n_points = 0; seg++; points[n_points].x = (gdouble) (stroke_segs[seg].x1 + offset_x); points[n_points].y = (gdouble) (stroke_segs[seg].y1 + offset_y); n_points++; } g_free (points); g_free (stroke_segs); gimp_drawable_stroke_scan_convert (drawable, options, scan_convert); gimp_scan_convert_free (scan_convert); }