Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@code-dot-org/dance-party

Package Overview
Dependencies
Maintainers
14
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@code-dot-org/dance-party - npm Package Compare versions

Comparing version 0.0.52 to 1.0.0

2

package.json
{
"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 @@ });

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc