1 // SPDX-License-Identifier: GPL-2.0-or-later 2 #ifndef SEEN_SP_STAR_H 3 #define SEEN_SP_STAR_H 4 5 /* 6 * <sodipodi:star> implementation 7 * 8 * Authors: 9 * Mitsuru Oka <oka326@parkcity.ne.jp> 10 * Lauris Kaplinski <lauris@kaplinski.com> 11 * 12 * Copyright (C) 1999-2002 Lauris Kaplinski 13 * Copyright (C) 2000-2001 Ximian, Inc. 14 * 15 * Released under GNU GPL v2+, read the file 'COPYING' for more information. 16 */ 17 18 #include "sp-polygon.h" 19 20 21 #define SP_STAR(obj) (dynamic_cast<SPStar*>((SPObject*)obj)) 22 #define SP_IS_STAR(obj) (dynamic_cast<const SPStar*>((SPObject*)obj) != NULL) 23 24 enum SPStarPoint { 25 SP_STAR_POINT_KNOT1, 26 SP_STAR_POINT_KNOT2 27 }; 28 29 class SPStar : public SPPolygon { 30 public: 31 SPStar(); 32 ~SPStar() override; 33 34 int sides; 35 36 Geom::Point center; 37 double r[2]; 38 double arg[2]; 39 bool flatsided; 40 41 double rounded; 42 double randomized; 43 44 // CPPIFY: This derivation is a bit weird. 45 // parent_class = reinterpret_cast<SPShapeClass *>(g_type_class_ref(SP_TYPE_SHAPE)); 46 // So shouldn't star be derived from shape instead of polygon? 47 // What does polygon have that shape doesn't? 48 49 void build(SPDocument *document, Inkscape::XML::Node *repr) override; 50 Inkscape::XML::Node* write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, unsigned int flags) override; 51 void set(SPAttr key, char const* value) override; 52 void update(SPCtx* ctx, unsigned int flags) override; 53 54 const char* displayName() const override; 55 char* description() const override; 56 void snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const override; 57 void update_patheffect(bool write) override; 58 void set_shape() override; 59 Geom::Affine set_transform(Geom::Affine const& xform) override; 60 }; 61 62 void sp_star_position_set (SPStar *star, int sides, Geom::Point center, double r1, double r2, double arg1, double arg2, bool isflat, double rounded, double randomized); 63 64 Geom::Point sp_star_get_xy (SPStar const *star, SPStarPoint point, int index, bool randomized = false); 65 66 67 68 #endif 69