To use it, include an import statement at the top of your program with the following:
import juice from 'https://andy.codehs.me/cdn/juicebox/0.0.3/juice.js';
Importing JuiceBox will cause some automatic changes.
import juice from 'https://andy.codehs.me/cdn/juicebox/0.0.3/juice.js';
Importing JuiceBox will cause some automatic changes.
add()
will be "lazy-added". Rather than all
appearing at once, they'll appear one by one.juice.GROW
juice.GROW = true;
causes elements being drawn to the screen to "bloop" into place with an elastic effect.
juice.SLAM
juice.SLAM = true;
causes elements being drawn to the screen to "slam" into place with a dramatic effect.
juice.OOZE
juice.OOZE = true;
causes elements to "ooze" when they're moved with setPosition
.
juice.SOUND
juice.SOUND = true;
causes sounds to happen! When elements bloop in or slam in you'll hear a sound.juice.GROW
or juice.SLAM
are true.juice.BLEND
juice.BLEND = true;
causes changes in color to be smooth.
juice.LAZY_ADD = false;
juice.LAZY_ADD = false;
causes elements to add immediately (no juice ðŸ˜)
juice.dust()
juice.dust(
// x position of the dust burst
x,
// y position of the dust burst
y,
// the number of dust particles (default 5)
nParticles,
// the initial size of each particle (default 20)
size,
// the rate of shrinking for each particle (default 0.9)
dRadius
);
juice.bonk()
juice.fall()
juice.shake()
juice.shake({
// magnitude of the shake in pixels
intensity: 5,
// duration of the shake in milliseconds
duration: 100,
// amount of shake in the x direction. 0 is none, 1 is full
dx: 1,
// amount of shake in the y direction. 0 is none, 1 is full
dy: 1,
// amount of rotatino shake. 0 is none, 1 is full.
dRotate: 1,
});
Shaking feels better if there's background elements that you can see shaking.
juice.shockwave(x, y)