@code-dot-org/dance-party
Advanced tools
Comparing version 0.0.44 to 0.0.45
{ | ||
"name": "@code-dot-org/dance-party", | ||
"version": "0.0.44", | ||
"version": "0.0.45", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/main.js", |
const constants = require('./constants'); | ||
const drawHeart = require('./shapes/heart'); | ||
const drawLovestruck = require('./shapes/lovestruck'); | ||
const drawMusicNote = require('./shapes/musicNote'); | ||
@@ -11,4 +12,7 @@ const drawPineapple = require('./shapes/pineapple'); | ||
const drawSpiral = require('./shapes/spiral'); | ||
const drawStarstruck = require('./shapes/starstruck'); | ||
const drawSwirl = require('./shapes/swirl'); | ||
const drawTaco = require('./shapes/taco'); | ||
const drawTickled = require('./shapes/tickled'); | ||
const drawWink = require('./shapes/wink'); | ||
@@ -1449,2 +1453,82 @@ module.exports = class Effects { | ||
}; | ||
this.music_wave = { | ||
inc: 360/15, | ||
heightFactor: 1, | ||
heightDivider: 200, | ||
yLoc: 300, | ||
lineWidth: p5.width/80, | ||
draw: function (context) { | ||
const centroid = context.centroid; | ||
let scale = p5.map(centroid, 5000, 8000, 0, 250); | ||
let angle = 0; | ||
p5.background('black'); | ||
for (let i = 0; i < p5.width; i+=this.lineWidth) { | ||
p5.stroke(lerpColorFromPalette(i/p5.width)); | ||
let amplitude = Math.abs(scale * (this.heightFactor/this.heightDivider) * p5.cos(angle)); | ||
let yInitial = this.yLoc - amplitude; | ||
let yFinal = this.yLoc + amplitude; | ||
p5.line(i, yInitial, i, yFinal); | ||
if ( i < p5.width/2) { | ||
this.heightFactor++; | ||
} else { | ||
this.heightFactor--; | ||
} | ||
angle += this.inc; | ||
} | ||
} | ||
}; | ||
this.emojis = { | ||
emojiList : [], | ||
emojiTypes : [], | ||
init : function () { | ||
this.imageLovestruck = p5.createGraphics(100, 100); | ||
this.imageLovestruck.scale(3); | ||
drawLovestruck(this.imageLovestruck.drawingContext); | ||
this.emojiTypes.push(this.imageLovestruck); | ||
this.imageSmiley = p5.createGraphics(100, 100); | ||
this.imageSmiley.scale(3); | ||
drawSmiley(this.imageSmiley.drawingContext); | ||
this.emojiTypes.push(this.imageSmiley); | ||
this.imageStarstruck = p5.createGraphics(100, 100); | ||
this.imageStarstruck.scale(3); | ||
drawStarstruck(this.imageStarstruck.drawingContext); | ||
this.emojiTypes.push(this.imageStarstruck); | ||
this.imageTickled = p5.createGraphics(100, 100); | ||
this.imageTickled.scale(3); | ||
drawTickled(this.imageTickled.drawingContext); | ||
this.emojiTypes.push(this.imageTickled); | ||
this.imageWink = p5.createGraphics(100, 100); | ||
this.imageWink.scale(3); | ||
drawWink(this.imageWink.drawingContext); | ||
this.emojiTypes.push(this.imageWink); | ||
}, | ||
draw : function () { | ||
if (p5.frameCount % 10 === 0) { // generate new emoji every 10 frames | ||
this.emojiList.push({ | ||
x: randomNumber(0, 350), | ||
y: -50, | ||
size: randomNumber(25, 50), | ||
image: this.emojiTypes[randomNumber(0, 4)], | ||
}); | ||
} | ||
for (let i = 0; i < this.emojiList.length; ++i) { | ||
const emoji = this.emojiList[i]; | ||
emoji.y += p5.pow(emoji.size, 0.25); // emoji falls at a rate fourth root to its size | ||
if (emoji.y > p5.height * 1.2) { // if the emoji has fallen past 120% of the screen | ||
this.emojiList.splice(i, 1); | ||
} | ||
p5.push(); | ||
p5.image(emoji.image, emoji.x, emoji.y, emoji.size, emoji.size); | ||
p5.pop(); | ||
} | ||
}, | ||
}; | ||
} | ||
@@ -1451,0 +1535,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
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
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
24427861
162
112762