22#include <glibmm/i18n.h>
45 this->
arg[0] = this->
arg[1] = 0.0;
67 if ((flags & SP_OBJECT_WRITE_BUILD) && !
repr) {
71 if (flags & SP_OBJECT_WRITE_EXT) {
104 this->
sides = atoi (value);
160 this->
arg[0] = g_ascii_strtod (value,
nullptr);
170 this->
arg[1] = g_ascii_strtod (value,
nullptr);
179 if (value && !strcmp(value,
"true")) {
191 this->
rounded = g_ascii_strtod (value,
nullptr);
201 this->
randomized = g_ascii_strtod (value,
nullptr);
217 if (flags & (SP_OBJECT_MODIFIED_FLAG |
218 SP_OBJECT_STYLE_MODIFIED_FLAG |
219 SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
244 return g_strdup_printf (ngettext(
"with %d vertex",
"with %d vertices",
282 return (
guint32) ( 69069 * prev + 1 );
291 for (; steps > 0; steps --)
294 return ( lcg / 4294967296. ) - 0.5;
322 gdouble prev_len =
Geom::L2 (prev - o);
323 gdouble next_len =
Geom::L2 (next - o);
331 ret = (star->
rounded * prev_len) * rot;
333 ret = (star->
rounded * next_len * -1) * rot;
350 return o_randomized + ret;
367 bool not_rounded = (fabs (this->
rounded) < 1e-4);
386 for (gint i = 1; i <
sides; i++) {
434 g_return_if_fail (star !=
nullptr);
438 star->
r[0] =
MAX (r1, 0.001);
440 if (isflat ==
false) {
441 star->
sides = CLAMP(sides, 2, 1024);
442 star->
r[1] = CLAMP(r2, 0.0, star->
r[0]);
444 star->
sides = CLAMP(sides, 3, 1024);
445 star->
r[1] = CLAMP( r1*cos(M_PI/sides) ,0.0, star->
r[0] );
487 gdouble
const s = hypot(ret[0], ret[1]);
504 pos = pos * ret.inverse();
537 double totalLength = 0.0;
540 for (gint i = 0; i <
sides; i++) {
551 return totalLength / (2 *
sides);
554 double diameter = 0.0;
556 for (gint i = 0; i <
sides; i++) {
560 return diameter /
sides;
573 if (currentLength <= 0 || length <= 0) {
577 double scale = length / currentLength;
606 gdouble darg = 2.0 * M_PI / (double) star->
sides;
608 double arg = star->
arg[point];
620 double range = 2 *
MAX (star->
r[0], star->
r[1]);
Lookup dictionary for attributes/properties.
3x3 matrix representing an affine transformation.
bool isUniformScale(Coord eps=EPSILON) const
Check whether this matrix represents pure uniform scaling.
Affine inverse() const
Compute the inverse matrix.
Affine withoutTranslation() const
Two-dimensional point that doubles as a vector.
constexpr Point ccw() const
Return a point like this point but rotated -90 degrees.
Rotation around the origin.
Storing of snapping preferences.
void setTargetSnappable(Inkscape::SnapTargetType const target, bool enabled)
bool isTargetSnappable(Inkscape::SnapTargetType const target) const
Interface for refcounted XML nodes.
void setAttribute(Util::const_char_ptr key, Util::const_char_ptr value)
Change an attribute of this node.
bool setAttributeInt(Util::const_char_ptr key, int val)
void removeAttribute(Inkscape::Util::const_char_ptr key)
Remove an attribute of this node.
bool setAttributeBoolean(Util::const_char_ptr key, bool val)
bool setAttributeSvgDouble(Util::const_char_ptr key, double val)
For attributes where an exponent is allowed.
Wrapper around a Geom::PathVector object.
void moveto(Geom::Point const &p)
Perform a moveto to a point, thus starting a new subpath.
void curveto(Geom::Point const &p0, Geom::Point const &p1, Geom::Point const &p2)
Adds a bezier segment to the current subpath.
Typed SVG document implementation.
Geom::Affine i2dt_affine() const
Returns the transformation from item to desktop coords.
void adjust_gradient(Geom::Affine const &postmul, bool set=false)
void adjust_pattern(Geom::Affine const &postmul, bool set=false, PaintServerTransform=TRANSFORM_BOTH)
void adjust_stroke(double ex)
Geom::Affine i2doc_affine() const
Returns the accumulated transformation of the item and all its ancestors, including root's viewport.
bool pathEffectsEnabled() const
bool optimizeTransforms()
returns false when LPE write unoptimiced
Inkscape::XML::Node * repr
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.
void update(SPCtx *ctx, unsigned int flags) override
void snappoints(std::vector< Inkscape::SnapCandidatePoint > &p, Inkscape::SnapPreferences const *snapprefs) const override
bool prepareShapeForLPE(SPCurve const *c)
void set(SPAttr key, char const *value) override
void build(SPDocument *document, Inkscape::XML::Node *repr) override
void update_patheffect(bool write) override
std::shared_ptr< SPCurve const > _curve
Inkscape::XML::Node * write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags) override
bool checkBrokenPathEffect()
void set(SPAttr key, char const *value) override
void update(SPCtx *ctx, unsigned int flags) override
char * description() const override
const char * typeName() const override
The item's type name, not node tag name.
void set_shape() override
void snappoints(std::vector< Inkscape::SnapCandidatePoint > &p, Inkscape::SnapPreferences const *snapprefs) const override
const char * displayName() const override
The item's type name as a translated human string.
void update_patheffect(bool write) override
Geom::Affine set_transform(Geom::Affine const &xform) override
void build(SPDocument *document, Inkscape::XML::Node *repr) override
Inkscape::XML::Node * write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags) override
double getSideLength() const
Calculate the average side length of the polygon.
void setSideLength(double length)
Set the average side length of the polygon.
auto floor(Geom::Rect const &rect)
void shift(T &a, T &b, T const &c)
Angle distance(Angle const &a, Angle const &b)
SBasis L2(D2< SBasis > const &a, unsigned k)
@ SNAPSOURCE_OBJECT_MIDPOINT
@ SNAPTARGET_OBJECT_MIDPOINT
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...
static guint32 point_unique_int(Geom::Point o)
Returns a unique 32 bit int for a given point.
static Geom::Point sp_star_get_curvepoint(SPStar *star, SPStarPoint point, gint index, bool previ)
static guint32 lcg_next(guint32 const prev)
Returns the next pseudorandom value using the Linear Congruential Generator algorithm (LCG) with the ...
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...
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.
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)
Geom::Point sp_star_get_xy(SPStar const *star, SPStarPoint point, int index, bool randomized=false)
Interface for XML documents.
virtual Node * createElement(char const *name)=0
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)
Interface for XML documents.