Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
sp-star.cpp File Reference

Go to the source code of this file.

Functions

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.
 
static guint32 point_unique_int (Geom::Point o)
 Returns a unique 32 bit int for a given point.
 
static guint32 lcg_next (guint32 const prev)
 Returns the next pseudorandom value using the Linear Congruential Generator algorithm (LCG) with the parameters (m = 2^32, a = 69069, b = 1).
 
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 steps from the seed.
 
static Geom::Point sp_star_get_curvepoint (SPStar *star, SPStarPoint point, gint index, bool previ)
 
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, gint index, bool randomized)
 sp_star_get_xy: Get X-Y value as item coordinate system @star: star item @point: point type to obtain X-Y value @index: index of vertex : pointer to store X-Y value @randomized: false (default) if you want to get exact, not randomized point
 

Function Documentation

◆ lcg_next()

static guint32 lcg_next ( guint32 const  prev)
inlinestatic

Returns the next pseudorandom value using the Linear Congruential Generator algorithm (LCG) with the parameters (m = 2^32, a = 69069, b = 1).

These parameters give a full-period generator, i.e. it is guaranteed to go through all integers < 2^32 (see http://random.mat.sbg.ac.at/~charly/server/server.html)

Definition at line 280 of file sp-star.cpp.

Referenced by rnd().

◆ point_unique_int()

static guint32 point_unique_int ( Geom::Point  o)
static

Returns a unique 32 bit int for a given point.

Obvious (but acceptable for my purposes) limits to uniqueness:

  • returned value for x,y repeats for x+n*1024,y+n*1024
  • returned value is unchanged when the point is moved by less than 1/1024 of px

Definition at line 264 of file sp-star.cpp.

References floor(), Geom::X, and Geom::Y.

Referenced by sp_star_get_curvepoint(), and sp_star_get_xy().

◆ rnd()

static double rnd ( guint32 const  seed,
unsigned  steps 
)
static

Returns a random number in the range [-0.5, 0.5) from the given seed, stepping the given number of steps from the seed.

Definition at line 289 of file sp-star.cpp.

References lcg_next().

Referenced by sp_star_get_curvepoint(), and sp_star_get_xy().

◆ rot90_rel()

static Geom::Point rot90_rel ( Geom::Point  o,
Geom::Point  n 
)
static

Returns a unit-length vector at 90 degrees to the direction from o to n.

Definition at line 252 of file sp-star.cpp.

References Geom::Point::ccw(), and Geom::Point::normalized().

Referenced by sp_star_get_curvepoint().

◆ sp_star_get_curvepoint()

static Geom::Point sp_star_get_curvepoint ( SPStar star,
SPStarPoint  point,
gint  index,
bool  previ 
)
static

◆ sp_star_get_xy()

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 X-Y value @index: index of vertex : pointer to store X-Y value @randomized: false (default) if you want to get exact, not randomized point

Initial item coordinate system is same as document coordinate system.

Definition at line 604 of file sp-star.cpp.

References SPStar::arg, SPStar::center, index, MAX, point_unique_int(), SPStar::r, SPStar::randomized, rnd(), shift(), and SPStar::sides.

Referenced by SPMeshNodeArray::create(), and sp_star_get_curvepoint().

◆ sp_star_position_set()

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 
)