@code-dot-org/dance-party
Advanced tools
Comparing version 0.0.52 to 1.0.0
{ | ||
"name": "@code-dot-org/dance-party", | ||
"version": "0.0.52", | ||
"version": "1.0.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/main.js", |
@@ -640,2 +640,53 @@ /* eslint-disable no-unused-vars, curly, eqeqeq */ | ||
/** | ||
* Sets the x & y positions of a group of sprites in order to arrange them | ||
* in a vertical column. | ||
* @param {array<sprite>} group - The group of sprites to arrange | ||
* @param {int} xLocation - The xLocation to set for all sprites | ||
*/ | ||
function createColumn(group, xLocation) { | ||
let count = group.length; | ||
for (let i=0; i<count; i++) { | ||
const sprite = group[i]; | ||
sprite.x = xLocation; | ||
sprite.y = (i+1) * (400 / (count + 1)); | ||
sprite.rotation = 0; | ||
} | ||
} | ||
/** | ||
* Sets the x & y positions of a group of sprites in order to arrange them | ||
* in a horizontal row. | ||
* @param {array<sprite>} group - The group of sprites to arrange | ||
* @param {int} yLocation - The yLocation to set for all sprites | ||
*/ | ||
function createRow(group, yLocation) { | ||
let count = group.length; | ||
for (let i=0; i<count; i++) { | ||
const sprite = group[i]; | ||
sprite.x = (i+1) * (400 / (count + 1)); | ||
sprite.y = yLocation; | ||
sprite.rotation = 0; | ||
} | ||
} | ||
/** | ||
* Sets the x & y positions of a group of sprites in order to arrange them | ||
* in a solid square. | ||
* @param {array<sprite>} group - The group of sprites to arrange | ||
*/ | ||
let createSquare = group => { | ||
let count = group.length; | ||
const pct = this.p5_.constrain(count / 10, 0, 1); | ||
const radius = this.p5_.lerp(0, 100, pct); | ||
const size = Math.ceil(Math.sqrt(count)); | ||
group.forEach((sprite, i) => { | ||
const row = Math.floor(i / size); | ||
const col = i % size; | ||
sprite.x = this.p5_.lerp(200 - radius, 200 + radius, col / (size - 1)); | ||
sprite.y = this.p5_.lerp(200 - radius, 200 + radius, row / (size - 1)); | ||
sprite.rotation = 0; | ||
}); | ||
}; | ||
if (format === "circle") { | ||
@@ -710,26 +761,27 @@ // Adjust radius of circle and size of the sprite according to number of | ||
} else if (format === "inner") { | ||
const pct = this.p5_.constrain(count / 10, 0, 1); | ||
const radius = this.p5_.lerp(0, 100, pct); | ||
const size = Math.ceil(Math.sqrt(count)); | ||
createSquare(group); | ||
} else if (format === "diamond") { | ||
createSquare(group); | ||
// Tilt the square 45° to create a diamond. | ||
group.forEach((sprite, i) => { | ||
const row = Math.floor(i / size); | ||
const col = i % size; | ||
sprite.x = this.p5_.lerp(200 - radius, 200 + radius, col / (size - 1)); | ||
sprite.y = this.p5_.lerp(200 - radius, 200 + radius, row / (size - 1)); | ||
sprite.rotation = 0; | ||
const x = sprite.x; | ||
const y = sprite.y; | ||
// Math.<sin,cos> expects degrees in radians. | ||
sprite.x = (x - 200) * Math.cos(Math.PI/4) - (y - 200) * Math.sin(Math.PI/4) + 200; | ||
sprite.y = (x - 200) * Math.sin(Math.PI/4) + (y - 200) * Math.cos(Math.PI/4) + 200; | ||
}); | ||
} else if (format === "left") { | ||
createColumn(group, 100); | ||
} else if (format === "column") { | ||
createColumn(group, 200); | ||
} else if (format === "right") { | ||
createColumn(group, 300); | ||
} else if (format === "top") { | ||
createRow(group, 100); | ||
} else if (format === "row") { | ||
for (let i=0; i<count; i++) { | ||
const sprite = group[i]; | ||
sprite.x = (i+1) * (400 / (count + 1)); | ||
sprite.y = 200; | ||
sprite.rotation = 0; | ||
} | ||
} else if (format === "column") { | ||
for (let i=0; i<count; i++) { | ||
const sprite = group[i]; | ||
sprite.x = 200; | ||
sprite.y = (i+1) * (400 / (count + 1)); | ||
sprite.rotation = 0; | ||
} | ||
createRow(group, 200); | ||
} else if (format === "bottom") { | ||
createRow(group, 300); | ||
} else if (format === "border") { | ||
@@ -736,0 +788,0 @@ // First fill the four corners. |
@@ -261,3 +261,3 @@ const helpers = require('../helpers/createDanceAPI'); | ||
['circle', 'plus', 'x', 'grid', 'inner', 'row', 'column', 'border', 'random'].forEach(layout => { | ||
['circle', 'plus', 'x', 'grid', 'inner', 'diamond', 'top', 'row', 'bottom', 'left', 'column', 'right', 'border', 'random'].forEach(layout => { | ||
nativeAPI.layoutSprites('BEAR', layout); | ||
@@ -264,0 +264,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
16449123
166
112196
4