mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-19 06:14:03 +00:00
fixed the default spacing, so that lines actually look like 1 pixel
2002-09-30 Simon Budig <simon@gimp.org> * data/brushes/1circle.gbr: fixed the default spacing, so that lines actually look like 1 pixel lines... * themes/Default/images/tools/.cvsignore: Added some files. * app/vectors/gimpanchor.h * app/vectors/gimpbezierstroke.[ch] * app/vectors/gimpstroke.h * app/vectors/gimpvectors.h: Added some stuff, mostly unused code that otherwise would just rot on my harddisk. Mitch: I need to discuss the data structures with you...
This commit is contained in:
parent
6aee6f94bb
commit
8e64f969a2
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2002-09-30 Simon Budig <simon@gimp.org>
|
||||
|
||||
* data/brushes/1circle.gbr: fixed the default spacing, so that
|
||||
lines actually look like 1 pixel lines...
|
||||
|
||||
* themes/Default/images/tools/.cvsignore: Added some files.
|
||||
|
||||
* app/vectors/gimpanchor.h
|
||||
* app/vectors/gimpbezierstroke.[ch]
|
||||
* app/vectors/gimpstroke.h
|
||||
* app/vectors/gimpvectors.h: Added some stuff, mostly unused
|
||||
code that otherwise would just rot on my harddisk. Mitch: I
|
||||
need to discuss the data structures with you...
|
||||
|
||||
2002-09-27 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* app/display/gimpdisplayshell.[ch]: added new signal "reconnect"
|
||||
|
|
|
@ -27,7 +27,7 @@ struct _GimpAnchor
|
|||
{
|
||||
GimpCoords position;
|
||||
|
||||
gint type;
|
||||
gint type; /* Interpretation dependant on GimpStroke type */
|
||||
};
|
||||
|
||||
#endif /* __GIMP_ANCHOR_H__ */
|
||||
|
|
|
@ -42,6 +42,14 @@ static void gimp_bezier_stroke_init (GimpBezierStroke *bezier_stroke)
|
|||
|
||||
static void gimp_bezier_stroke_finalize (GObject *object);
|
||||
|
||||
static void gimp_bezier_coords_average (GimpCoords *a,
|
||||
GimpCoords *b,
|
||||
GimpCoords *ret_average);
|
||||
|
||||
static void gimp_bezier_coords_subdivide (GimpCoords *beziercoords,
|
||||
const gdouble precision,
|
||||
gint *ret_ncoords,
|
||||
GimpCoords *ret_coords);
|
||||
|
||||
GType
|
||||
gimp_bezier_stroke_get_type (void)
|
||||
|
@ -128,9 +136,39 @@ gimp_bezier_stroke_new (const GimpCoords *start)
|
|||
}
|
||||
|
||||
|
||||
GimpStroke *
|
||||
gimp_bezier_stroke_new_from_coords (const GimpCoords *coords,
|
||||
const gint ncoords)
|
||||
{
|
||||
GimpBezierStroke *bezier_stroke;
|
||||
GimpStroke *stroke = NULL;
|
||||
GimpAnchor *last_anchor;
|
||||
|
||||
gint count;
|
||||
|
||||
if (ncoords >= 1)
|
||||
{
|
||||
stroke = gimp_bezier_stroke_new (coords);
|
||||
bezier_stroke = GIMP_BEZIER_STROKE (stroke);
|
||||
last_anchor = (GimpAnchor *) (stroke->anchors->data);
|
||||
|
||||
count = 1;
|
||||
while (count < ncoords)
|
||||
{
|
||||
last_anchor = gimp_bezier_stroke_extend (bezier_stroke,
|
||||
&(coords[count]),
|
||||
last_anchor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return stroke;
|
||||
}
|
||||
|
||||
|
||||
GimpAnchor *
|
||||
gimp_bezier_stroke_extend (GimpBezierStroke *bezier_stroke,
|
||||
GimpCoords *coords,
|
||||
const GimpCoords *coords,
|
||||
GimpAnchor *neighbor)
|
||||
{
|
||||
GimpAnchor *anchor;
|
||||
|
@ -191,6 +229,7 @@ gimp_bezier_stroke_extend (GimpBezierStroke *bezier_stroke,
|
|||
return anchor;
|
||||
}
|
||||
|
||||
|
||||
GimpCoords *
|
||||
gimp_bezier_stroke_interpolate (const GimpStroke *stroke,
|
||||
gdouble precision,
|
||||
|
@ -233,3 +272,101 @@ gimp_bezier_stroke_interpolate (const GimpStroke *stroke,
|
|||
}
|
||||
|
||||
|
||||
/* local helper functions for bezier subdivision */
|
||||
|
||||
static void
|
||||
gimp_bezier_coords_average (GimpCoords *a,
|
||||
GimpCoords *b,
|
||||
GimpCoords *ret_average)
|
||||
{
|
||||
ret_average->x = (a->x + b->x ) / 2.0;
|
||||
ret_average->y = (a->y + b->y ) / 2.0;
|
||||
ret_average->pressure = (a->pressure + b->pressure) / 2.0;
|
||||
ret_average->xtilt = (a->xtilt + b->xtilt ) / 2.0;
|
||||
ret_average->ytilt = (a->ytilt + b->ytilt ) / 2.0;
|
||||
ret_average->wheel = (a->wheel + b->wheel ) / 2.0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gimp_bezier_coords_subdivide (GimpCoords *beziercoords,
|
||||
const gdouble precision,
|
||||
gint *ret_ncoords,
|
||||
GimpCoords *ret_coords)
|
||||
{
|
||||
/*
|
||||
* beziercoords has to contain four GimpCoords with the four control points
|
||||
* of the bezier segment. We subdivide it at the parameter 0.5.
|
||||
*/
|
||||
|
||||
GimpCoords subdivided[8];
|
||||
gint i, good_enough = 1;
|
||||
|
||||
subdivided[0] = beziercoords[0];
|
||||
subdivided[6] = beziercoords[3];
|
||||
|
||||
gimp_bezier_coords_average (&(beziercoords[0]), &(beziercoords[1]),
|
||||
&(subdivided[1]));
|
||||
|
||||
gimp_bezier_coords_average (&(beziercoords[1]), &(beziercoords[2]),
|
||||
&(subdivided[7]));
|
||||
|
||||
gimp_bezier_coords_average (&(beziercoords[2]), &(beziercoords[3]),
|
||||
&(subdivided[5]));
|
||||
|
||||
gimp_bezier_coords_average (&(subdivided[1]), &(subdivided[7]),
|
||||
&(subdivided[2]));
|
||||
|
||||
gimp_bezier_coords_average (&(subdivided[7]), &(subdivided[5]),
|
||||
&(subdivided[4]));
|
||||
|
||||
gimp_bezier_coords_average (&(subdivided[2]), &(subdivided[4]),
|
||||
&(subdivided[3]));
|
||||
|
||||
/*
|
||||
* We now have the coordinates of the two bezier segments in
|
||||
* subdivided [0-3] and subdivided [3-6]
|
||||
*/
|
||||
|
||||
/*
|
||||
* Here we need to check, if we have sufficiently subdivided, i.e.
|
||||
* if the stroke is sufficiently close to a straight line.
|
||||
*/
|
||||
|
||||
if ( good_enough /* stroke 1 */ )
|
||||
{
|
||||
for (i=0; i < 3; i++)
|
||||
{
|
||||
/* if necessary, allocate new memory for return coords */
|
||||
ret_coords[*ret_ncoords] = subdivided[i];
|
||||
(*ret_ncoords)++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_bezier_coords_subdivide (&(subdivided[0]), precision,
|
||||
ret_ncoords, ret_coords);
|
||||
}
|
||||
|
||||
if ( good_enough /* stroke 2 */ )
|
||||
{
|
||||
for (i=0; i < 3; i++)
|
||||
{
|
||||
/* if necessary, allocate new memory for return coords */
|
||||
ret_coords[*ret_ncoords] = subdivided[i+3];
|
||||
(*ret_ncoords)++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_bezier_coords_subdivide (&(subdivided[3]), precision,
|
||||
ret_ncoords, ret_coords);
|
||||
}
|
||||
|
||||
if ( /* last iteration */ 0)
|
||||
{
|
||||
/* if necessary, allocate new memory for return coords */
|
||||
ret_coords[*ret_ncoords] = subdivided[6];
|
||||
(*ret_ncoords)++;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,9 +58,11 @@ GType gimp_bezier_stroke_get_type (void) G_GNUC_CONST;
|
|||
|
||||
GimpStroke * gimp_bezier_stroke_new (const GimpCoords *start);
|
||||
|
||||
GimpStroke * gimp_bezier_stroke_new_from_coords (const GimpCoords *coords,
|
||||
const gint ncoords);
|
||||
|
||||
GimpAnchor * gimp_bezier_stroke_extend (GimpBezierStroke *bezier_stroke,
|
||||
GimpCoords *coords,
|
||||
const GimpCoords *coords,
|
||||
GimpAnchor *neighbor);
|
||||
|
||||
GimpCoords * gimp_bezier_stroke_interpolate (const GimpStroke *stroke,
|
||||
|
|
|
@ -38,7 +38,10 @@ struct _GimpStroke
|
|||
GList *anchors;
|
||||
|
||||
GimpStroke *next;
|
||||
/* Stuff missing */
|
||||
|
||||
GimpAnchor *temp_anchor;
|
||||
|
||||
/* Stuff missing? */
|
||||
};
|
||||
|
||||
|
||||
|
@ -87,6 +90,7 @@ struct _GimpStrokeClass
|
|||
const GimpCoords *coord);
|
||||
|
||||
gboolean (* temp_anchor_fix) (GimpStroke *stroke);
|
||||
|
||||
GimpStroke * (* make_bezier) (const GimpStroke *stroke);
|
||||
|
||||
};
|
||||
|
@ -111,49 +115,49 @@ GimpAnchor * gimp_stroke_anchor_get_next (const GimpStroke *stroke,
|
|||
* VECTORS_NONE, VECTORS_FIX_ANGLE, VECTORS_FIX_RATIO, VECTORS_RESTRICT_ANGLE
|
||||
* or so.
|
||||
*/
|
||||
void gimp_stroke_anchor_move_relative (GimpStroke *stroke,
|
||||
void gimp_stroke_anchor_move_relative (GimpStroke *stroke,
|
||||
GimpAnchor *anchor,
|
||||
const GimpCoords *deltacoord,
|
||||
const gint type);
|
||||
|
||||
void gimp_stroke_anchor_move_absolute (GimpStroke *stroke,
|
||||
void gimp_stroke_anchor_move_absolute (GimpStroke *stroke,
|
||||
GimpAnchor *anchor,
|
||||
const GimpCoords *coord,
|
||||
const gint type);
|
||||
|
||||
void gimp_stroke_anchor_delete (GimpStroke *stroke,
|
||||
GimpAnchor *anchor);
|
||||
void gimp_stroke_anchor_delete (GimpStroke *stroke,
|
||||
GimpAnchor *anchor);
|
||||
|
||||
|
||||
/* accessing the shape of the curve */
|
||||
|
||||
gdouble gimp_stroke_get_length (const GimpStroke *stroke);
|
||||
gdouble gimp_stroke_get_length (const GimpStroke *stroke);
|
||||
|
||||
gdouble gimp_stroke_get_distance (const GimpStroke *stroke,
|
||||
const GimpCoords *coord);
|
||||
gdouble gimp_stroke_get_distance (const GimpStroke *stroke,
|
||||
const GimpCoords *coord);
|
||||
|
||||
/* returns the number of valid coordinates */
|
||||
GimpCoords * gimp_stroke_interpolate (const GimpStroke *stroke,
|
||||
gdouble precision,
|
||||
gint *ret_numcoords,
|
||||
gboolean *ret_closed);
|
||||
GimpCoords * gimp_stroke_interpolate (const GimpStroke *stroke,
|
||||
gdouble precision,
|
||||
gint *ret_numcoords,
|
||||
gboolean *ret_closed);
|
||||
|
||||
|
||||
/* Allow a singular temorary anchor (marking the "working point")? */
|
||||
|
||||
GimpAnchor * gimp_stroke_temp_anchor_get (const GimpStroke *stroke);
|
||||
GimpAnchor * gimp_stroke_temp_anchor_get (const GimpStroke *stroke);
|
||||
|
||||
GimpAnchor * gimp_stroke_temp_anchor_set (GimpStroke *stroke,
|
||||
const GimpCoords *coord);
|
||||
GimpAnchor * gimp_stroke_temp_anchor_set (GimpStroke *stroke,
|
||||
const GimpCoords *coord);
|
||||
|
||||
gboolean gimp_stroke_temp_anchor_fix (GimpStroke *stroke);
|
||||
gboolean gimp_stroke_temp_anchor_fix (GimpStroke *stroke);
|
||||
|
||||
|
||||
/* usually overloaded */
|
||||
|
||||
/* creates a bezier approximation. */
|
||||
|
||||
GimpStroke * gimp_stroke_make_bezier (const GimpStroke *stroke);
|
||||
GimpStroke * gimp_stroke_make_bezier (const GimpStroke *stroke);
|
||||
|
||||
|
||||
#endif /* __GIMP_STROKE_H__ */
|
||||
|
|
|
@ -40,6 +40,7 @@ struct _GimpVectors
|
|||
gboolean visible; /* controls visibility */
|
||||
gboolean locked; /* transformation locking */
|
||||
|
||||
/* Should the following be a GList of GimpStrokes? */
|
||||
GimpStroke * strokes; /* The first stroke */
|
||||
|
||||
/* Stuff missing */
|
||||
|
|
Binary file not shown.
|
@ -1,2 +1,4 @@
|
|||
Makefile
|
||||
Makefile.in
|
||||
.xvpics
|
||||
.thumbnails
|
||||
|
|
Loading…
Reference in a new issue