Code

Merge and cleanup of GSoC C++-ification project.
[inkscape.git] / src / sp-star.cpp
1 /*
2  * <sodipodi:star> implementation
3  *
4  * Authors:
5  *   Mitsuru Oka <oka326@parkcity.ne.jp>
6  *   Lauris Kaplinski <lauris@kaplinski.com>
7  *   bulia byak <buliabyak@users.sf.net>
8  *   Abhishek Sharma
9  *
10  * Copyright (C) 1999-2002 Lauris Kaplinski
11  * Copyright (C) 2000-2001 Ximian, Inc.
12  *
13  * Released under GNU GPL, read the file 'COPYING' for more information
14  */
16 #ifdef HAVE_CONFIG_H
17 # include "config.h"
18 #endif
20 #include <cstring>
21 #include <string>
22 #include <glibmm/i18n.h>
24 #include "svg/svg.h"
25 #include "attributes.h"
26 #include "display/curve.h"
27 #include "xml/repr.h"
28 #include "document.h"
30 #include <2geom/pathvector.h>
32 #include "sp-star.h"
34 static void sp_star_class_init (SPStarClass *klass);
35 static void sp_star_init (SPStar *star);
37 static void sp_star_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr);
38 static Inkscape::XML::Node *sp_star_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
39 static void sp_star_set (SPObject *object, unsigned int key, const gchar *value);
40 static void sp_star_update (SPObject *object, SPCtx *ctx, guint flags);
42 static gchar * sp_star_description (SPItem * item);
43 static void sp_star_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs);
45 static void sp_star_set_shape (SPShape *shape);
46 static void sp_star_update_patheffect (SPLPEItem *lpeitem, bool write);
48 static SPShapeClass *parent_class;
50 GType
51 sp_star_get_type (void)
52 {
53     static GType type = 0;
55     if (!type) {
56         GTypeInfo info = {
57             sizeof (SPStarClass),
58             NULL, NULL,
59             (GClassInitFunc) sp_star_class_init,
60             NULL, NULL,
61             sizeof (SPStar),
62             16,
63             (GInstanceInitFunc) sp_star_init,
64             NULL,    /* value_table */
65         };
66         type = g_type_register_static (SP_TYPE_SHAPE, "SPStar", &info, (GTypeFlags)0);
67     }
68     return type;
69 }
71 static void
72 sp_star_class_init (SPStarClass *klass)
73 {
74     GObjectClass * gobject_class;
75     SPObjectClass * sp_object_class;
76     SPItemClass * item_class;
77     SPLPEItemClass * lpe_item_class;
78     SPShapeClass * shape_class;
80     gobject_class = (GObjectClass *) klass;
81     sp_object_class = (SPObjectClass *) klass;
82     item_class = (SPItemClass *) klass;
83     lpe_item_class = (SPLPEItemClass *) klass;
84     shape_class = (SPShapeClass *) klass;
86     parent_class = (SPShapeClass *)g_type_class_ref (SP_TYPE_SHAPE);
88     sp_object_class->build = sp_star_build;
89     sp_object_class->write = sp_star_write;
90     sp_object_class->set = sp_star_set;
91     sp_object_class->update = sp_star_update;
93     item_class->description = sp_star_description;
94     item_class->snappoints = sp_star_snappoints;
96     lpe_item_class->update_patheffect = sp_star_update_patheffect;
98     shape_class->set_shape = sp_star_set_shape;
99 }
101 static void
102 sp_star_init (SPStar * star)
104     star->sides = 5;
105     star->center = Geom::Point(0, 0);
106     star->r[0] = 1.0;
107     star->r[1] = 0.001;
108     star->arg[0] = star->arg[1] = 0.0;
109     star->flatsided = 0;
110     star->rounded = 0.0;
111     star->randomized = 0.0;
114 static void
115 sp_star_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr)
117     if (((SPObjectClass *) parent_class)->build)
118         ((SPObjectClass *) parent_class)->build (object, document, repr);
120     object->readAttr( "sodipodi:cx" );
121     object->readAttr( "sodipodi:cy" );
122     object->readAttr( "sodipodi:sides" );
123     object->readAttr( "sodipodi:r1" );
124     object->readAttr( "sodipodi:r2" );
125     object->readAttr( "sodipodi:arg1" );
126     object->readAttr( "sodipodi:arg2" );
127     object->readAttr( "inkscape:flatsided" );
128     object->readAttr( "inkscape:rounded" );
129     object->readAttr( "inkscape:randomized" );
132 static Inkscape::XML::Node *
133 sp_star_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
135     SPStar *star = SP_STAR (object);
137     if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
138         repr = xml_doc->createElement("svg:path");
139     }
141     if (flags & SP_OBJECT_WRITE_EXT) {
142         repr->setAttribute("sodipodi:type", "star");
143         sp_repr_set_int (repr, "sodipodi:sides", star->sides);
144         sp_repr_set_svg_double(repr, "sodipodi:cx", star->center[Geom::X]);
145         sp_repr_set_svg_double(repr, "sodipodi:cy", star->center[Geom::Y]);
146         sp_repr_set_svg_double(repr, "sodipodi:r1", star->r[0]);
147         sp_repr_set_svg_double(repr, "sodipodi:r2", star->r[1]);
148         sp_repr_set_svg_double(repr, "sodipodi:arg1", star->arg[0]);
149         sp_repr_set_svg_double(repr, "sodipodi:arg2", star->arg[1]);
150         sp_repr_set_boolean (repr, "inkscape:flatsided", star->flatsided);
151         sp_repr_set_svg_double(repr, "inkscape:rounded", star->rounded);
152         sp_repr_set_svg_double(repr, "inkscape:randomized", star->randomized);
153     }
155     sp_star_set_shape ((SPShape *) star);
156     char *d = sp_svg_write_path (((SPShape *) star)->curve->get_pathvector());
157     repr->setAttribute("d", d);
158     g_free (d);
160     if (((SPObjectClass *) (parent_class))->write)
161         ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags);
163     return repr;
166 static void
167 sp_star_set (SPObject *object, unsigned int key, const gchar *value)
169     SVGLength::Unit unit;
171     SPStar *star = SP_STAR (object);
173     /* fixme: we should really collect updates */
174     switch (key) {
175     case SP_ATTR_SODIPODI_SIDES:
176         if (value) {
177             star->sides = atoi (value);
178             star->sides = NR_CLAMP(star->sides, 3, 1024);
179         } else {
180             star->sides = 5;
181         }
182         object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
183         break;
184     case SP_ATTR_SODIPODI_CX:
185         if (!sp_svg_length_read_ldd (value, &unit, NULL, &star->center[Geom::X]) ||
186             (unit == SVGLength::EM) ||
187             (unit == SVGLength::EX) ||
188             (unit == SVGLength::PERCENT)) {
189             star->center[Geom::X] = 0.0;
190         }
191         object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
192         break;
193     case SP_ATTR_SODIPODI_CY:
194         if (!sp_svg_length_read_ldd (value, &unit, NULL, &star->center[Geom::Y]) ||
195             (unit == SVGLength::EM) ||
196             (unit == SVGLength::EX) ||
197             (unit == SVGLength::PERCENT)) {
198             star->center[Geom::Y] = 0.0;
199         }
200         object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
201         break;
202     case SP_ATTR_SODIPODI_R1:
203         if (!sp_svg_length_read_ldd (value, &unit, NULL, &star->r[0]) ||
204             (unit == SVGLength::EM) ||
205             (unit == SVGLength::EX) ||
206             (unit == SVGLength::PERCENT)) {
207             star->r[0] = 1.0;
208         }
209         /* fixme: Need CLAMP (Lauris) */
210         object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
211         break;
212     case SP_ATTR_SODIPODI_R2:
213         if (!sp_svg_length_read_ldd (value, &unit, NULL, &star->r[1]) ||
214             (unit == SVGLength::EM) ||
215             (unit == SVGLength::EX) ||
216             (unit == SVGLength::PERCENT)) {
217             star->r[1] = 0.0;
218         }
219         object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
220         return;
221     case SP_ATTR_SODIPODI_ARG1:
222         if (value) {
223             star->arg[0] = g_ascii_strtod (value, NULL);
224         } else {
225             star->arg[0] = 0.0;
226         }
227         object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
228         break;
229     case SP_ATTR_SODIPODI_ARG2:
230         if (value) {
231             star->arg[1] = g_ascii_strtod (value, NULL);
232         } else {
233             star->arg[1] = 0.0;
234         }
235         object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
236         break;
237     case SP_ATTR_INKSCAPE_FLATSIDED:
238         if (value && !strcmp (value, "true"))
239             star->flatsided = true;
240         else star->flatsided = false;
241         object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
242         break;
243     case SP_ATTR_INKSCAPE_ROUNDED:
244         if (value) {
245             star->rounded = g_ascii_strtod (value, NULL);
246         } else {
247             star->rounded = 0.0;
248         }
249         object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
250         break;
251     case SP_ATTR_INKSCAPE_RANDOMIZED:
252         if (value) {
253             star->randomized = g_ascii_strtod (value, NULL);
254         } else {
255             star->randomized = 0.0;
256         }
257         object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
258         break;
259     default:
260         if (((SPObjectClass *) parent_class)->set)
261             ((SPObjectClass *) parent_class)->set (object, key, value);
262         break;
263     }
266 static void
267 sp_star_update (SPObject *object, SPCtx *ctx, guint flags)
269     if (flags & (SP_OBJECT_MODIFIED_FLAG |
270              SP_OBJECT_STYLE_MODIFIED_FLAG |
271              SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
272         ((SPShape *) object)->setShape ();
273     }
275     if (((SPObjectClass *) parent_class)->update)
276         ((SPObjectClass *) parent_class)->update (object, ctx, flags);
279 static void
280 sp_star_update_patheffect(SPLPEItem *lpeitem, bool write)
282     SPShape *shape = (SPShape *) lpeitem;
283     sp_star_set_shape(shape);
285     if (write) {
286         Inkscape::XML::Node *repr = SP_OBJECT_REPR(shape);
287         if ( shape->curve != NULL ) {
288             gchar *str = sp_svg_write_path(shape->curve->get_pathvector());
289             repr->setAttribute("d", str);
290             g_free(str);
291         } else {
292             repr->setAttribute("d", NULL);
293         }
294     }
296     ((SPObject *)shape)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
299 static gchar *
300 sp_star_description (SPItem *item)
302     SPStar *star = SP_STAR (item);
304     // while there will never be less than 3 vertices, we still need to
305     // make calls to ngettext because the pluralization may be different
306     // for various numbers >=3.  The singular form is used as the index.
307     if (star->flatsided == false )
308     return g_strdup_printf (ngettext("<b>Star</b> with %d vertex",
309                          "<b>Star</b> with %d vertices",
310                      star->sides), star->sides);
311     else
312         return g_strdup_printf (ngettext("<b>Polygon</b> with %d vertex",
313                          "<b>Polygon</b> with %d vertices",
314                      star->sides), star->sides);
317 /**
318 Returns a unit-length vector at 90 degrees to the direction from o to n
319  */
320 static Geom::Point
321 rot90_rel (Geom::Point o, Geom::Point n)
323     return ((1/Geom::L2(n - o)) * Geom::Point ((n - o)[Geom::Y],  (o - n)[Geom::X]));
326 /**
327 Returns a unique 32 bit int for a given point.
328 Obvious (but acceptable for my purposes) limits to uniqueness:
329 - returned value for x,y repeats for x+n*1024,y+n*1024
330 - returned value is unchanged when the point is moved by less than 1/1024 of px
331 */
332 static guint32
333 point_unique_int (Geom::Point o)
335     return ((guint32)
336     65536 *
337         (((int) floor (o[Geom::X] * 64)) % 1024 + ((int) floor (o[Geom::X] * 1024)) % 64)
338     +
339              (((int) floor (o[Geom::Y] * 64)) % 1024 + ((int) floor (o[Geom::Y] * 1024)) % 64)
340     );
343 /**
344 Returns the next pseudorandom value using the Linear Congruential Generator algorithm (LCG)
345 with the parameters (m = 2^32, a = 69069, b = 1). These parameters give a full-period generator,
346 i.e. it is guaranteed to go through all integers < 2^32 (see http://random.mat.sbg.ac.at/~charly/server/server.html)
347 */
348 static inline guint32
349 lcg_next(guint32 const prev)
351     return (guint32) ( 69069 * prev + 1 );
354 /**
355 Returns a random number in the range [-0.5, 0.5) from the given seed, stepping the given number of steps from the seed.
356 */
357 static double
358 rnd (guint32 const seed, unsigned steps) {
359     guint32 lcg = seed;
360     for (; steps > 0; steps --)
361         lcg = lcg_next (lcg);
363     return ( lcg / 4294967296. ) - 0.5;
366 static Geom::Point
367 sp_star_get_curvepoint (SPStar *star, SPStarPoint point, gint index, bool previ)
369     // the point whose neighboring curve handle we're calculating
370     Geom::Point o = sp_star_get_xy (star, point, index);
372     // indices of previous and next points
373     gint pi = (index > 0)? (index - 1) : (star->sides - 1);
374     gint ni = (index < star->sides - 1)? (index + 1) : 0;
376     // the other point type
377     SPStarPoint other = (point == SP_STAR_POINT_KNOT2? SP_STAR_POINT_KNOT1 : SP_STAR_POINT_KNOT2);
379     // the neighbors of o; depending on flatsided, they're either the same type (polygon) or the other type (star)
380     Geom::Point prev = (star->flatsided? sp_star_get_xy (star, point, pi) : sp_star_get_xy (star, other, point == SP_STAR_POINT_KNOT2? index : pi));
381     Geom::Point next = (star->flatsided? sp_star_get_xy (star, point, ni) : sp_star_get_xy (star, other, point == SP_STAR_POINT_KNOT1? index : ni));
383     // prev-next midpoint
384     Geom::Point mid =  0.5 * (prev + next);
386     // point to which we direct the bissector of the curve handles;
387     // it's far enough outside the star on the perpendicular to prev-next through mid
388     Geom::Point biss =  mid + 100000 * rot90_rel (mid, next);
390     // lengths of vectors to prev and next
391     gdouble prev_len = Geom::L2 (prev - o);
392     gdouble next_len = Geom::L2 (next - o);
394     // unit-length vector perpendicular to o-biss
395     Geom::Point rot = rot90_rel (o, biss);
397     // multiply rot by star->rounded coefficient and the distance to the star point; flip for next
398     Geom::Point ret;
399     if (previ) {
400         ret = (star->rounded * prev_len) * rot;
401     } else {
402         ret = (star->rounded * next_len * -1) * rot;
403     }
405     if (star->randomized == 0) {
406         // add the vector to o to get the final curvepoint
407         return o + ret;
408     } else {
409         // the seed corresponding to the exact point
410         guint32 seed = point_unique_int (o);
412         // randomly rotate (by step 3 from the seed) and scale (by step 4) the vector
413         ret = ret * Geom::Matrix (Geom::Rotate (star->randomized * M_PI * rnd (seed, 3)));
414         ret *= ( 1 + star->randomized * rnd (seed, 4));
416         // the randomized corner point
417         Geom::Point o_randomized = sp_star_get_xy (star, point, index, true);
419         return o_randomized + ret;
420     }
424 #define NEXT false
425 #define PREV true
427 static void
428 sp_star_set_shape (SPShape *shape)
430     SPStar *star = SP_STAR (shape);
432     // perhaps we should convert all our shapes into LPEs without source path
433     // and with knotholders for parameters, then this situation will be handled automatically
434     // by disabling the entire stack (including the shape LPE)
435     if (sp_lpe_item_has_broken_path_effect(SP_LPE_ITEM(shape))) {
436         g_warning ("The star shape has unknown LPE on it! Convert to path to make it editable preserving the appearance; editing it as star will remove the bad LPE");
437         if (SP_OBJECT_REPR(shape)->attribute("d")) {
438             // unconditionally read the curve from d, if any, to preserve appearance
439             Geom::PathVector pv = sp_svg_read_pathv(SP_OBJECT_REPR(shape)->attribute("d"));
440             SPCurve *cold = new SPCurve(pv);
441             shape->setCurveInsync( cold, TRUE);
442             cold->unref();
443         }
444         return;
445     }
447     SPCurve *c = new SPCurve ();
449     gint sides = star->sides;
450     bool not_rounded = (fabs (star->rounded) < 1e-4);
452     // note that we pass randomized=true to sp_star_get_xy, because the curve must be randomized;
453     // other places that call that function (e.g. the knotholder) need the exact point
455     // draw 1st segment
456     c->moveto(sp_star_get_xy (star, SP_STAR_POINT_KNOT1, 0, true));
457     if (star->flatsided == false) {
458         if (not_rounded) {
459             c->lineto(sp_star_get_xy (star, SP_STAR_POINT_KNOT2, 0, true));
460         } else {
461             c->curveto(sp_star_get_curvepoint (star, SP_STAR_POINT_KNOT1, 0, NEXT),
462                 sp_star_get_curvepoint (star, SP_STAR_POINT_KNOT2, 0, PREV),
463                 sp_star_get_xy (star, SP_STAR_POINT_KNOT2, 0, true));
464         }
465     }
467     // draw all middle segments
468     for (gint i = 1; i < sides; i++) {
469         if (not_rounded) {
470             c->lineto(sp_star_get_xy (star, SP_STAR_POINT_KNOT1, i, true));
471         } else {
472             if (star->flatsided == false) {
473                 c->curveto(sp_star_get_curvepoint (star, SP_STAR_POINT_KNOT2, i - 1, NEXT),
474                         sp_star_get_curvepoint (star, SP_STAR_POINT_KNOT1, i, PREV),
475                         sp_star_get_xy (star, SP_STAR_POINT_KNOT1, i, true));
476             } else {
477                 c->curveto(sp_star_get_curvepoint (star, SP_STAR_POINT_KNOT1, i - 1, NEXT),
478                         sp_star_get_curvepoint (star, SP_STAR_POINT_KNOT1, i, PREV),
479                         sp_star_get_xy (star, SP_STAR_POINT_KNOT1, i, true));
480             }
481         }
482         if (star->flatsided == false) {
484             if (not_rounded) {
485                        c->lineto(sp_star_get_xy (star, SP_STAR_POINT_KNOT2, i, true));
486             } else {
487                 c->curveto(sp_star_get_curvepoint (star, SP_STAR_POINT_KNOT1, i, NEXT),
488                     sp_star_get_curvepoint (star, SP_STAR_POINT_KNOT2, i, PREV),
489                     sp_star_get_xy (star, SP_STAR_POINT_KNOT2, i, true));
490             }
491         }
492     }
494     // draw last segment
495         if (!not_rounded) {
496             if (star->flatsided == false) {
497             c->curveto(sp_star_get_curvepoint (star, SP_STAR_POINT_KNOT2, sides - 1, NEXT),
498                 sp_star_get_curvepoint (star, SP_STAR_POINT_KNOT1, 0, PREV),
499                 sp_star_get_xy (star, SP_STAR_POINT_KNOT1, 0, true));
500             } else {
501             c->curveto(sp_star_get_curvepoint (star, SP_STAR_POINT_KNOT1, sides - 1, NEXT),
502                 sp_star_get_curvepoint (star, SP_STAR_POINT_KNOT1, 0, PREV),
503                 sp_star_get_xy (star, SP_STAR_POINT_KNOT1, 0, true));
504             }
505         }
507     c->closepath();
509     /* Reset the shape'scurve to the "original_curve"
510      * This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/
511     shape->setCurveInsync( c, TRUE);
512     if (sp_lpe_item_has_path_effect(SP_LPE_ITEM(shape)) && sp_lpe_item_path_effects_enabled(SP_LPE_ITEM(shape))) {
513         SPCurve *c_lpe = c->copy();
514         bool success = sp_lpe_item_perform_path_effect(SP_LPE_ITEM (shape), c_lpe);
515         if (success) {
516             shape->setCurveInsync( c_lpe, TRUE);
517         } 
518         c_lpe->unref();
519     }
520     c->unref();
523 void
524 sp_star_position_set (SPStar *star, gint sides, Geom::Point center, gdouble r1, gdouble r2, gdouble arg1, gdouble arg2, bool isflat, double rounded, double randomized)
526     g_return_if_fail (star != NULL);
527     g_return_if_fail (SP_IS_STAR (star));
529     star->sides = NR_CLAMP(sides, 3, 1024);
530     star->center = center;
531     star->r[0] = MAX (r1, 0.001);
532     if (isflat == false) {
533         star->r[1] = NR_CLAMP(r2, 0.0, star->r[0]);
534     } else {
535         star->r[1] = NR_CLAMP( r1*cos(M_PI/sides) ,0.0, star->r[0] );
536     }
537     star->arg[0] = arg1;
538     star->arg[1] = arg2;
539     star->flatsided = isflat;
540     star->rounded = rounded;
541     star->randomized = randomized;
542     SP_OBJECT(star)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
545 static void sp_star_snappoints(SPItem const *item, std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs)
547     // We will determine the star's midpoint ourselves, instead of trusting on the base class
548     // Therefore setSnapObjectMidpoints() is set to false temporarily
549     Inkscape::SnapPreferences local_snapprefs = *snapprefs;
550     local_snapprefs.setSnapObjectMidpoints(false);
552     if (((SPItemClass *) parent_class)->snappoints) {
553         ((SPItemClass *) parent_class)->snappoints (item, p, &local_snapprefs);
554     }
556     // Help enforcing strict snapping, i.e. only return nodes when we're snapping nodes to nodes or a guide to nodes
557     if (!(snapprefs->getSnapModeNode() || snapprefs->getSnapModeGuide())) {
558         return;
559     }
561     if (snapprefs->getSnapObjectMidpoints()) {
562         Geom::Matrix const i2d (item->i2d_affine ());
563         p.push_back(Inkscape::SnapCandidatePoint(SP_STAR(item)->center * i2d,Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT));
564     }
567 /**
568  * sp_star_get_xy: Get X-Y value as item coordinate system
569  * @star: star item
570  * @point: point type to obtain X-Y value
571  * @index: index of vertex
572  * @p: pointer to store X-Y value
573  * @randomized: false (default) if you want to get exact, not randomized point
574  *
575  * Initial item coordinate system is same as document coordinate system.
576  */
578 Geom::Point
579 sp_star_get_xy (SPStar *star, SPStarPoint point, gint index, bool randomized)
581     gdouble darg = 2.0 * M_PI / (double) star->sides;
583     double arg = star->arg[point];
584     arg += index * darg;
586     Geom::Point xy = star->r[point] * Geom::Point(cos(arg), sin(arg)) + star->center;
588     if (!randomized || star->randomized == 0) {
589         // return the exact point
590         return xy;
591     } else { // randomize the point
592         // find out the seed, unique for this point so that randomization is the same so long as the original point is stationary
593         guint32 seed = point_unique_int (xy);
594         // the full range (corresponding to star->randomized == 1.0) is equal to the star's diameter
595         double range = 2 * MAX (star->r[0], star->r[1]);
596         // find out the random displacement; x is controlled by step 1 from the seed, y by the step 2
597         Geom::Point shift (star->randomized * range * rnd (seed, 1), star->randomized * range * rnd (seed, 2));
598         // add the shift to the exact point
599         return xy + shift;
600     }
603 /*
604   Local Variables:
605   mode:c++
606   c-file-style:"stroustrup"
607   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
608   indent-tabs-mode:nil
609   fill-column:99
610   End:
611 */
612 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :