Code

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