siteswap-generator v0.2.0
siteswap-generator
Siteswap introduction
Siteswap is a juggling notation used to describe or represent juggling patterns. It encodes the number of beats of each throw, which is related to their height, and the hand to which the throw is to be made. However, it does not describe body movements such as behind-the-back and under-the-leg.
A siteswap pattern can be expressed through number sequence that represent a cycle of throws with different heights. These heights must meet certain mathematical rules. For more information, see siteswap entry in wikipedia.
Description
This module allow to compute the whole patterns with specific number of balls, length of cycle (also called period) and heights. Siteswap generator does not compute patterns that are the same except rotations or repetitions. For example, 5,3,1, 3,1,5 and 1,5,3 are the same except rotations and 3,3,3, 3,3 and 3 are the same except repetitions.
Version
0.2.0
Installation
npm install siteswap-generatorExample:
var siteswap = require('siteswap-generator')
var patterns = siteswap.Generator({
balls : 3,
period: {min: 2, max: 3},
height: 5
})
console.log(patterns)
/*
[ [ 5, 3, 1 ],
[ 5, 2, 2 ],
[ 5, 0, 4 ],
[ 4, 4, 1 ],
[ 4, 2, 3 ],
[ 5, 1 ],
[ 4, 2 ] ]
*/API
siteswap === module.exports
Type: Object
siteswap.Generator (options)
Type: Function
Returns all of patterns required by options object parameter.
options.balls
Type: Object | Integer
If options.balls is an object, this mean the interval of balls of computed patterns.
options.balls.maxis maximum number of balls.options.balls.minis minimum number of balls of patterns. If it is not defined the minimum number of balls is the same thatoptions.balls.max.
If options.balls is an integer, it is the same that options.balls takes value {min: options.balls, max: options.balls}.
options.period
Type: Object | Integer
If options.period is an object, this mean the interval of periods which are computed.
options.period.maxis maximum period.options.period.minis minimum period. It takes value 1 by default.
If options.period is an integer, it is the same that options.period takes value {min: 1, max: options.period}.
options.height
Type: Object | integer | undefined
If options.period is an object:
options.height.maxmean that computed patterns have heights less than or equal to this.options.height.maxisoptions.balls.max*options.period.maxby default.options.height.minmean that computed patterns have at least one height greater than or equal to this. The default value is 0.
If options.height is an integer, this mean the same that options.height takes value {min: 0, max: options.height}.
If options.height is undefined, this mean the same that options.height takes value {min: 0, max: options.balls.max * options.period.max}
Example:
var patterns = siteswap.Generator({
balls : {min: 1, max: 3},
period: 3,
height: {min: 5}
}) /* [
[ 9, 0, 0 ],
[ 8, 0, 1 ],
[ 7, 2, 0 ],
[ 7, 1, 1 ],
[ 6, 3, 0 ],
[ 6, 1, 2 ],
[ 6, 0, 3 ],
[ 5, 3, 1 ],
[ 5, 2, 2 ],
[ 5, 0, 4 ],
[ 6, 0 ],
[ 5, 1 ],
[ 6, 0, 0 ],
[ 5, 0, 1 ]
] */siteswap.Buffer (options)
Type: function
It is a constructor that creates a buffer object. This allow to get the same patterns than siteswap.Generator but these patterns can be get lazily with .slice method.
siteswap.Buffer#slice (begin, end)
It gets slice of patterns generated by siteswap.Generator function.
begin
Type: Integer
zero-based index at which to begin extraction
end
Type: Integer
zero-based index at which to end extraction.
Considerations:
slice method get patterns sequentially. If buffer object is created and after got from 11th to 20th pattenrs (.slice(11,20)), internally .slice compute from first to 20th patterns and returns slice from 11th to 20th requested. Then, if is requested 1st to 10th patterns, these are not computed and only are returned because was previously computed.
Example:
var buffer = siteswap.Buffer({
balls : {min: 1, max: 3},
period: 3,
height: {min: 5}
})
buffer.slice(0, 5) /* [
[ 9, 0, 0 ],
[ 8, 0, 1 ],
[ 7, 2, 0 ],
[ 7, 1, 1 ],
[ 6, 3, 0 ],
]*/
buffer.slice(5, 10) /* [
[ 6, 1, 2 ],
[ 6, 0, 3 ],
[ 5, 3, 1 ],
[ 5, 2, 2 ],
[ 5, 0, 4 ],
]*/siteswap.Buffer#length
Type: integer | undefined
length of patterns if all patterns was computed with slice method or undefined if not.
siteswap.Buffer#maxLength
maximum of length of patterns list.
siteswap.Buffer#minLength
minimum of length of patterns list.
CLI (Comand Line Interface)
Install
$ npm install -g siteswap-generatorUsage
$ siteswap [balls.min:]balls.max [period.min:]period.max [[height.min:]height.max]Examples
$ siteswap 3 3 5
[ [ 5, 3, 1 ],
[ 5, 2, 2 ],
[ 5, 0, 4 ],
[ 4, 4, 1 ],
[ 4, 2, 3 ],
[ 5, 1 ],
[ 4, 2 ],
[ 3 ] ]$ siteswap 1:3 3:3 5:5
[ [ 5, 3, 1 ], [ 5, 2, 2 ], [ 5, 0, 4 ], [ 5, 0, 1 ] ]License
MIT