Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
sp-star.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * <sodipodi:star> implementation
4 *
5 * Authors:
6 * Mitsuru Oka <oka326@parkcity.ne.jp>
7 * Lauris Kaplinski <lauris@kaplinski.com>
8 * bulia byak <buliabyak@users.sf.net>
9 * Abhishek Sharma
10 *
11 * Copyright (C) 1999-2002 Lauris Kaplinski
12 * Copyright (C) 2000-2001 Ximian, Inc.
13 *
14 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
15 */
16
17#include "sp-star.h"
18
19#include <cstring>
20
21#include <glib.h>
22#include <glibmm/i18n.h>
23
24#include "attributes.h"
25#include "snap-candidate.h" // for SnapCandidatePoint
26#include "snap-enums.h" // for SnapTargetType, SnapSourceType
27#include "snap-preferences.h" // for SnapPreferences
28
29#include "display/curve.h"
30#include "svg/svg.h"
31#include "xml/document.h" // for Document
32#include "xml/node.h" // for Node
33
34class SPDocument;
35
37 sides(5),
38 center(0, 0),
39 flatsided(false),
40 rounded(0.0),
41 randomized(0.0)
42{
43 this->r[0] = 1.0;
44 this->r[1] = 0.001;
45 this->arg[0] = this->arg[1] = 0.0;
46}
47
48SPStar::~SPStar() = default;
49
65
67 if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
68 repr = xml_doc->createElement("svg:path");
69 }
70
71 if (flags & SP_OBJECT_WRITE_EXT) {
72 repr->setAttribute("sodipodi:type", "star");
73 repr->setAttributeBoolean("inkscape:flatsided", this->flatsided);
74 repr->setAttributeInt("sodipodi:sides", this->sides);
75 repr->setAttributeSvgDouble("sodipodi:cx", this->center[Geom::X]);
76 repr->setAttributeSvgDouble("sodipodi:cy", this->center[Geom::Y]);
77 repr->setAttributeSvgDouble("sodipodi:r1", this->r[0]);
78 repr->setAttributeSvgDouble("sodipodi:r2", this->r[1]);
79 repr->setAttributeSvgDouble("sodipodi:arg1", this->arg[0]);
80 repr->setAttributeSvgDouble("sodipodi:arg2", this->arg[1]);
81 repr->setAttributeSvgDouble("inkscape:rounded", this->rounded);
82 repr->setAttributeSvgDouble("inkscape:randomized", this->randomized);
83 }
84
85 this->set_shape();
86 if (this->_curve) {
87 repr->setAttribute("d", sp_svg_write_path(this->_curve->get_pathvector()));
88 } else {
89 repr->removeAttribute("d");
90 }
91 // CPPIFY: see header file
92 SPShape::write(xml_doc, repr, flags);
93
94 return repr;
95}
96
97void SPStar::set(SPAttr key, const gchar* value) {
98 SVGLength::Unit unit;
99
100 /* fixme: we should really collect updates */
101 switch (key) {
103 if (value) {
104 this->sides = atoi (value);
105 this->sides = CLAMP(this->sides, this->flatsided ? 3 : 2, 1024);
106 } else {
107 this->sides = 5;
108 }
109
110 this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
111 break;
112
114 if (!sp_svg_length_read_ldd (value, &unit, nullptr, &this->center[Geom::X]) ||
115 (unit == SVGLength::EM) ||
116 (unit == SVGLength::EX) ||
117 (unit == SVGLength::PERCENT)) {
118 this->center[Geom::X] = 0.0;
119 }
120
121 this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
122 break;
123
125 if (!sp_svg_length_read_ldd (value, &unit, nullptr, &this->center[Geom::Y]) ||
126 (unit == SVGLength::EM) ||
127 (unit == SVGLength::EX) ||
128 (unit == SVGLength::PERCENT)) {
129 this->center[Geom::Y] = 0.0;
130 }
131
132 this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
133 break;
134
136 if (!sp_svg_length_read_ldd (value, &unit, nullptr, &this->r[0]) ||
137 (unit == SVGLength::EM) ||
138 (unit == SVGLength::EX) ||
139 (unit == SVGLength::PERCENT)) {
140 this->r[0] = 1.0;
141 }
142
143 /* fixme: Need CLAMP (Lauris) */
144 this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
145 break;
146
148 if (!sp_svg_length_read_ldd (value, &unit, nullptr, &this->r[1]) ||
149 (unit == SVGLength::EM) ||
150 (unit == SVGLength::EX) ||
151 (unit == SVGLength::PERCENT)) {
152 this->r[1] = 0.0;
153 }
154
155 this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
156 return;
157
159 if (value) {
160 this->arg[0] = g_ascii_strtod (value, nullptr);
161 } else {
162 this->arg[0] = 0.0;
163 }
164
165 this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
166 break;
167
169 if (value) {
170 this->arg[1] = g_ascii_strtod (value, nullptr);
171 } else {
172 this->arg[1] = 0.0;
173 }
174
175 this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
176 break;
177
179 if (value && !strcmp(value, "true")) {
180 this->flatsided = true;
181 this->sides = MAX(this->sides, 3);
182 } else {
183 this->flatsided = false;
184 }
185
186 this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
187 break;
188
190 if (value) {
191 this->rounded = g_ascii_strtod (value, nullptr);
192 } else {
193 this->rounded = 0.0;
194 }
195
196 this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
197 break;
198
200 if (value) {
201 this->randomized = g_ascii_strtod (value, nullptr);
202 } else {
203 this->randomized = 0.0;
204 }
205
206 this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
207 break;
208
209 default:
210 // CPPIFY: see header file
211 SPShape::set(key, value);
212 break;
213 }
214}
215
216void SPStar::update(SPCtx *ctx, guint flags) {
217 if (flags & (SP_OBJECT_MODIFIED_FLAG |
218 SP_OBJECT_STYLE_MODIFIED_FLAG |
219 SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
220
221 this->set_shape();
222 }
223
224 // CPPIFY: see header file
225 SPShape::update(ctx, flags);
226}
227
228const char* SPStar::typeName() const {
229 if (this->flatsided == false)
230 return "star";
231 return "polygon";
232}
233
234const char* SPStar::displayName() const {
235 if (this->flatsided == false)
236 return _("Star");
237 return _("Polygon");
238}
239
240gchar* SPStar::description() const {
241 // while there will never be less than 2 or 3 vertices, we still need to
242 // make calls to ngettext because the pluralization may be different
243 // for various numbers >=3. The singular form is used as the index.
244 return g_strdup_printf (ngettext("with %d vertex", "with %d vertices",
245 this->sides), this->sides);
246}
247
251static Geom::Point
253{
254 return (n-o).ccw().normalized();
255}
256
263static guint32
265{
266 return ((guint32)
267 65536 *
268 (((int) floor (o[Geom::X] * 64)) % 1024 + ((int) floor (o[Geom::X] * 1024)) % 64)
269 +
270 (((int) floor (o[Geom::Y] * 64)) % 1024 + ((int) floor (o[Geom::Y] * 1024)) % 64)
271 );
272}
273
279static inline guint32
280lcg_next(guint32 const prev)
281{
282 return (guint32) ( 69069 * prev + 1 );
283}
284
288static double
289rnd (guint32 const seed, unsigned steps) {
290 guint32 lcg = seed;
291 for (; steps > 0; steps --)
292 lcg = lcg_next (lcg);
293
294 return ( lcg / 4294967296. ) - 0.5;
295}
296
297static Geom::Point
298sp_star_get_curvepoint (SPStar *star, SPStarPoint point, gint index, bool previ)
299{
300 // the point whose neighboring curve handle we're calculating
301 Geom::Point o = sp_star_get_xy (star, point, index);
302
303 // indices of previous and next points
304 gint pi = (index > 0)? (index - 1) : (star->sides - 1);
305 gint ni = (index < star->sides - 1)? (index + 1) : 0;
306
307 // the other point type
309
310 // the neighbors of o; depending on flatsided, they're either the same type (polygon) or the other type (star)
311 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));
312 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));
313
314 // prev-next midpoint
315 Geom::Point mid = 0.5 * (prev + next);
316
317 // point to which we direct the bissector of the curve handles;
318 // it's far enough outside the star on the perpendicular to prev-next through mid
319 Geom::Point biss = mid + 100000 * rot90_rel (mid, next);
320
321 // lengths of vectors to prev and next
322 gdouble prev_len = Geom::L2 (prev - o);
323 gdouble next_len = Geom::L2 (next - o);
324
325 // unit-length vector perpendicular to o-biss
326 Geom::Point rot = rot90_rel (o, biss);
327
328 // multiply rot by star->rounded coefficient and the distance to the star point; flip for next
329 Geom::Point ret;
330 if (previ) {
331 ret = (star->rounded * prev_len) * rot;
332 } else {
333 ret = (star->rounded * next_len * -1) * rot;
334 }
335
336 if (star->randomized == 0) {
337 // add the vector to o to get the final curvepoint
338 return o + ret;
339 } else {
340 // the seed corresponding to the exact point
341 guint32 seed = point_unique_int (o);
342
343 // randomly rotate (by step 3 from the seed) and scale (by step 4) the vector
344 ret = ret * Geom::Affine (Geom::Rotate (star->randomized * M_PI * rnd (seed, 3)));
345 ret *= ( 1 + star->randomized * rnd (seed, 4));
346
347 // the randomized corner point
348 Geom::Point o_randomized = sp_star_get_xy (star, point, index, true);
349
350 return o_randomized + ret;
351 }
352}
353
354#define NEXT false
355#define PREV true
356
358 // perhaps we should convert all our shapes into LPEs without source path
359 // and with knotholders for parameters, then this situation will be handled automatically
360 // by disabling the entire stack (including the shape LPE)
361 if (checkBrokenPathEffect()) {
362 return;
363 }
364
365 SPCurve c;
366
367 bool not_rounded = (fabs (this->rounded) < 1e-4);
368
369 // note that we pass randomized=true to sp_star_get_xy, because the curve must be randomized;
370 // other places that call that function (e.g. the knotholder) need the exact point
371
372 // draw 1st segment
373 c.moveto(sp_star_get_xy (this, SP_STAR_POINT_KNOT1, 0, true));
374
375 if (this->flatsided == false) {
376 if (not_rounded) {
377 c.lineto(sp_star_get_xy (this, SP_STAR_POINT_KNOT2, 0, true));
378 } else {
379 c.curveto(sp_star_get_curvepoint (this, SP_STAR_POINT_KNOT1, 0, NEXT),
381 sp_star_get_xy (this, SP_STAR_POINT_KNOT2, 0, true));
382 }
383 }
384
385 // draw all middle segments
386 for (gint i = 1; i < sides; i++) {
387 if (not_rounded) {
388 c.lineto(sp_star_get_xy (this, SP_STAR_POINT_KNOT1, i, true));
389 } else {
390 if (this->flatsided == false) {
393 sp_star_get_xy (this, SP_STAR_POINT_KNOT1, i, true));
394 } else {
395 c.curveto(sp_star_get_curvepoint (this, SP_STAR_POINT_KNOT1, i - 1, NEXT),
397 sp_star_get_xy (this, SP_STAR_POINT_KNOT1, i, true));
398 }
399 }
400
401 if (this->flatsided == false) {
402 if (not_rounded) {
403 c.lineto(sp_star_get_xy (this, SP_STAR_POINT_KNOT2, i, true));
404 } else {
405 c.curveto(sp_star_get_curvepoint (this, SP_STAR_POINT_KNOT1, i, NEXT),
407 sp_star_get_xy (this, SP_STAR_POINT_KNOT2, i, true));
408 }
409 }
410 }
411
412 // draw last segment
413 if (!not_rounded) {
414 if (this->flatsided == false) {
417 sp_star_get_xy (this, SP_STAR_POINT_KNOT1, 0, true));
418 } else {
419 c.curveto(sp_star_get_curvepoint (this, SP_STAR_POINT_KNOT1, sides - 1, NEXT),
421 sp_star_get_xy (this, SP_STAR_POINT_KNOT1, 0, true));
422 }
423 }
424
425 c.closepath();
426
428
429}
430
431void
432sp_star_position_set (SPStar *star, gint sides, Geom::Point center, gdouble r1, gdouble r2, gdouble arg1, gdouble arg2, bool isflat, double rounded, double randomized)
433{
434 g_return_if_fail (star != nullptr);
435
436 star->flatsided = isflat;
437 star->center = center;
438 star->r[0] = MAX (r1, 0.001);
439
440 if (isflat == false) {
441 star->sides = CLAMP(sides, 2, 1024);
442 star->r[1] = CLAMP(r2, 0.0, star->r[0]);
443 } else {
444 star->sides = CLAMP(sides, 3, 1024);
445 star->r[1] = CLAMP( r1*cos(M_PI/sides) ,0.0, star->r[0] );
446 }
447
448 star->arg[0] = arg1;
449 star->arg[1] = arg2;
450 star->rounded = rounded;
451 star->randomized = randomized;
452 star->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
453}
454
455void SPStar::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const {
456 // We will determine the star's midpoint ourselves, instead of trusting on the base class
457 // Therefore snapping to object midpoints is temporarily disabled
458 Inkscape::SnapPreferences local_snapprefs = *snapprefs;
460
461 // CPPIFY: see header file
462 SPShape::snappoints(p, &local_snapprefs);
463
465 Geom::Affine const i2dt (this->i2dt_affine ());
467 }
468}
469
471{
472 bool opt_trans = (randomized == 0);
474 return xform;
475 }
476 // Only set transform with proportional scaling
477 if (!xform.withoutTranslation().isUniformScale()) {
478 return xform;
479 }
480
481 /* Calculate star start in parent coords. */
482 Geom::Point pos( this->center * xform );
483
484 /* This function takes care of translation and scaling, we return whatever parts we can't
485 handle. */
486 Geom::Affine ret(opt_trans ? xform.withoutTranslation() : xform);
487 gdouble const s = hypot(ret[0], ret[1]);
488 if (s > 1e-9) {
489 ret[0] /= s;
490 ret[1] /= s;
491 ret[2] /= s;
492 ret[3] /= s;
493 } else {
494 ret[0] = 1.0;
495 ret[1] = 0.0;
496 ret[2] = 0.0;
497 ret[3] = 1.0;
498 }
499
500 this->r[0] *= s;
501 this->r[1] *= s;
502
503 /* Find start in item coords */
504 pos = pos * ret.inverse();
505 this->center = pos;
506
507 this->set_shape();
508
509 // Adjust stroke width
510 this->adjust_stroke(s);
511
512 // Adjust pattern fill
513 this->adjust_pattern(xform * ret.inverse());
514
515 // Adjust gradient fill
516 this->adjust_gradient(xform * ret.inverse());
517
518 return ret;
519}
520
524
534{
535 if (!flatsided) {
536 // Pointy star
537 double totalLength = 0.0;
538 auto tr = i2doc_affine();
539
540 for (gint i = 0; i < sides; i++) {
541 Geom::Point outer1 = sp_star_get_xy(this, SP_STAR_POINT_KNOT1, i, false) * tr;
542 Geom::Point inner1 = sp_star_get_xy(this, SP_STAR_POINT_KNOT2, i, false) * tr;
543
544 totalLength += Geom::distance(outer1, inner1);
545
546 Geom::Point outer2 = sp_star_get_xy(this, SP_STAR_POINT_KNOT1, (i + 1) % sides, false) * tr;
547 totalLength += Geom::distance(inner1, outer2);
548 }
549
550 // Return the average side length (since we have 2 * sides distances, divide by 2 * sides)
551 return totalLength / (2 * sides);
552 }
553
554 double diameter = 0.0;
555 auto tr = i2doc_affine();
556 for (gint i = 0; i < sides; i++) {
557 diameter += Geom::distance(sp_star_get_xy(this, SP_STAR_POINT_KNOT1, i, false) * tr,
558 sp_star_get_xy(this, SP_STAR_POINT_KNOT1, (i + 1) % sides, false) * tr);
559 }
560 return diameter / sides;
561}
562
571void SPStar::setSideLength(double length) {
572 double currentLength = getSideLength();
573 if (currentLength <= 0 || length <= 0) {
574 return; // Prevent division by zero or invalid scaling
575 }
576
577 double scale = length / currentLength;
578
579 if (!flatsided) {
580 // Pointy star
581 r[0] *= scale;
582 r[1] *= scale;
583 } else {
584 // Flat star
585 r[0] *= scale;
586 }
587
588 this -> set_shape();
589
590 requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
591}
592
604sp_star_get_xy (SPStar const *star, SPStarPoint point, gint index, bool randomized)
605{
606 gdouble darg = 2.0 * M_PI / (double) star->sides;
607
608 double arg = star->arg[point];
609 arg += index * darg;
610
611 Geom::Point xy = star->r[point] * Geom::Point(cos(arg), sin(arg)) + star->center;
612
613 if (!randomized || star->randomized == 0) {
614 // return the exact point
615 return xy;
616 } else { // randomize the point
617 // find out the seed, unique for this point so that randomization is the same so long as the original point is stationary
618 guint32 seed = point_unique_int (xy);
619 // the full range (corresponding to star->randomized == 1.0) is equal to the star's diameter
620 double range = 2 * MAX (star->r[0], star->r[1]);
621 // find out the random displacement; x is controlled by step 1 from the seed, y by the step 2
622 Geom::Point shift (star->randomized * range * rnd (seed, 1), star->randomized * range * rnd (seed, 2));
623 // add the shift to the exact point
624 return xy + shift;
625 }
626}
627
628/*
629 Local Variables:
630 mode:c++
631 c-file-style:"stroustrup"
632 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
633 indent-tabs-mode:nil
634 fill-column:99
635 End:
636*/
637// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
double scale
Definition aa.cpp:228
Lookup dictionary for attributes/properties.
SPAttr
Definition attributes.h:27
@ INKSCAPE_RANDOMIZED
@ SODIPODI_R2
@ SODIPODI_CY
@ SODIPODI_SIDES
@ SODIPODI_ARG1
@ SODIPODI_ARG2
@ SODIPODI_CX
@ INKSCAPE_FLATSIDED
@ SODIPODI_R1
@ INKSCAPE_ROUNDED
3x3 matrix representing an affine transformation.
Definition affine.h:70
bool isUniformScale(Coord eps=EPSILON) const
Check whether this matrix represents pure uniform scaling.
Definition affine.cpp:174
Affine inverse() const
Compute the inverse matrix.
Definition affine.cpp:388
Affine withoutTranslation() const
Definition affine.h:169
Two-dimensional point that doubles as a vector.
Definition point.h:66
Point normalized() const
Definition point.h:121
constexpr Point ccw() const
Return a point like this point but rotated -90 degrees.
Definition point.h:130
Rotation around the origin.
Definition transforms.h:187
Storing of snapping preferences.
void setTargetSnappable(Inkscape::SnapTargetType const target, bool enabled)
bool isTargetSnappable(Inkscape::SnapTargetType const target) const
Interface for refcounted XML nodes.
Definition node.h:80
void setAttribute(Util::const_char_ptr key, Util::const_char_ptr value)
Change an attribute of this node.
Definition node.cpp:25
bool setAttributeInt(Util::const_char_ptr key, int val)
Definition node.cpp:92
void removeAttribute(Inkscape::Util::const_char_ptr key)
Remove an attribute of this node.
Definition node.h:280
bool setAttributeBoolean(Util::const_char_ptr key, bool val)
Definition node.cpp:86
bool setAttributeSvgDouble(Util::const_char_ptr key, double val)
For attributes where an exponent is allowed.
Definition node.cpp:111
Wrapper around a Geom::PathVector object.
Definition curve.h:26
void moveto(Geom::Point const &p)
Perform a moveto to a point, thus starting a new subpath.
Definition curve.cpp:138
void curveto(Geom::Point const &p0, Geom::Point const &p1, Geom::Point const &p2)
Adds a bezier segment to the current subpath.
Definition curve.cpp:190
Typed SVG document implementation.
Definition document.h:103
Geom::Affine i2dt_affine() const
Returns the transformation from item to desktop coords.
Definition sp-item.cpp:1828
void adjust_gradient(Geom::Affine const &postmul, bool set=false)
Definition sp-item.cpp:1433
void adjust_pattern(Geom::Affine const &postmul, bool set=false, PaintServerTransform=TRANSFORM_BOTH)
Definition sp-item.cpp:1387
void adjust_stroke(double ex)
Definition sp-item.cpp:1479
Geom::Affine i2doc_affine() const
Returns the accumulated transformation of the item and all its ancestors, including root's viewport.
Definition sp-item.cpp:1823
bool pathEffectsEnabled() const
bool optimizeTransforms()
returns false when LPE write unoptimiced
Inkscape::XML::Node * repr
Definition sp-object.h:193
SPDocument * document
Definition sp-object.h:188
void readAttr(char const *key)
Read value of key attribute from XML node into object.
void requestDisplayUpdate(unsigned int flags)
Queues an deferred update of this object's display.
Base class for shapes, including <path> element.
Definition sp-shape.h:38
void update(SPCtx *ctx, unsigned int flags) override
Definition sp-shape.cpp:125
void snappoints(std::vector< Inkscape::SnapCandidatePoint > &p, Inkscape::SnapPreferences const *snapprefs) const override
Definition sp-shape.cpp:991
bool prepareShapeForLPE(SPCurve const *c)
Definition sp-shape.cpp:479
void set(SPAttr key, char const *value) override
Definition sp-shape.cpp:115
void build(SPDocument *document, Inkscape::XML::Node *repr) override
Definition sp-shape.cpp:63
void update_patheffect(bool write) override
Definition sp-shape.cpp:650
std::shared_ptr< SPCurve const > _curve
Definition sp-shape.h:70
Inkscape::XML::Node * write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags) override
Definition sp-shape.cpp:120
bool checkBrokenPathEffect()
Definition sp-shape.cpp:459
void set(SPAttr key, char const *value) override
Definition sp-star.cpp:97
void update(SPCtx *ctx, unsigned int flags) override
Definition sp-star.cpp:216
Geom::Point center
Definition sp-star.h:33
double rounded
Definition sp-star.h:38
char * description() const override
Definition sp-star.cpp:240
const char * typeName() const override
The item's type name, not node tag name.
Definition sp-star.cpp:228
void set_shape() override
Definition sp-star.cpp:357
void snappoints(std::vector< Inkscape::SnapCandidatePoint > &p, Inkscape::SnapPreferences const *snapprefs) const override
Definition sp-star.cpp:455
const char * displayName() const override
The item's type name as a translated human string.
Definition sp-star.cpp:234
void update_patheffect(bool write) override
Definition sp-star.cpp:521
double r[2]
Definition sp-star.h:34
bool flatsided
Definition sp-star.h:36
~SPStar() override
Geom::Affine set_transform(Geom::Affine const &xform) override
Definition sp-star.cpp:470
double arg[2]
Definition sp-star.h:35
void build(SPDocument *document, Inkscape::XML::Node *repr) override
Definition sp-star.cpp:50
Inkscape::XML::Node * write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags) override
Definition sp-star.cpp:66
double randomized
Definition sp-star.h:39
int sides
Definition sp-star.h:31
double getSideLength() const
Calculate the average side length of the polygon.
Definition sp-star.cpp:533
void setSideLength(double length)
Set the average side length of the polygon.
Definition sp-star.cpp:571
SPStar()
Definition sp-star.cpp:36
double c[8][4]
unsigned int guint32
@ Y
Definition coord.h:48
@ X
Definition coord.h:48
auto floor(Geom::Rect const &rect)
Definition geom.h:130
void shift(T &a, T &b, T const &c)
Angle distance(Angle const &a, Angle const &b)
Definition angle.h:163
SBasis L2(D2< SBasis > const &a, unsigned k)
Definition d2-sbasis.cpp:42
@ SNAPSOURCE_OBJECT_MIDPOINT
Definition snap-enums.h:53
@ SNAPTARGET_OBJECT_MIDPOINT
Definition snap-enums.h:115
static cairo_user_data_key_t key
Some utility classes to store various kinds of snap candidates.
static double rnd(guint32 const seed, unsigned steps)
Returns a random number in the range [-0.5, 0.5) from the given seed, stepping the given number of st...
Definition sp-star.cpp:289
static guint32 point_unique_int(Geom::Point o)
Returns a unique 32 bit int for a given point.
Definition sp-star.cpp:264
static Geom::Point sp_star_get_curvepoint(SPStar *star, SPStarPoint point, gint index, bool previ)
Definition sp-star.cpp:298
static guint32 lcg_next(guint32 const prev)
Returns the next pseudorandom value using the Linear Congruential Generator algorithm (LCG) with the ...
Definition sp-star.cpp:280
Geom::Point sp_star_get_xy(SPStar const *star, SPStarPoint point, gint index, bool randomized)
sp_star_get_xy: Get X-Y value as item coordinate system @star: star item @point: point type to obtain...
Definition sp-star.cpp:604
static Geom::Point rot90_rel(Geom::Point o, Geom::Point n)
Returns a unit-length vector at 90 degrees to the direction from o to n.
Definition sp-star.cpp:252
void 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)
Definition sp-star.cpp:432
Geom::Point sp_star_get_xy(SPStar const *star, SPStarPoint point, int index, bool randomized=false)
SPStarPoint
Definition sp-star.h:20
@ SP_STAR_POINT_KNOT2
Definition sp-star.h:22
@ SP_STAR_POINT_KNOT1
Definition sp-star.h:21
Interface for XML documents.
Definition document.h:43
virtual Node * createElement(char const *name)=0
Unused.
Definition sp-object.h:94
unsigned int sp_svg_length_read_ldd(gchar const *str, SVGLength::Unit *unit, double *value, double *computed)
static void sp_svg_write_path(Inkscape::SVG::PathString &str, Geom::Path const &p, bool normalize=false)
Definition svg-path.cpp:109
int index
Interface for XML documents.
Interface for XML nodes.