Skip to content

Instantly share code, notes, and snippets.

@tec27
Created November 23, 2018 21:46
Show Gist options
  • Save tec27/8882abb081229f5db29a5f37999a2b00 to your computer and use it in GitHub Desktop.
Save tec27/8882abb081229f5db29a5f37999a2b00 to your computer and use it in GitHub Desktop.
Transparent Streamlabs Tip Jar
// Enable Custom HTML/CSS here: https://streamlabs.com/dashboard#/jar
// Then copy-paste this into the JS tab (you probably want to replace all the existing content there)
// Adjust these to change the cup size
var CUP_WIDTH = 160;
var CUP_HEIGHT = 160;
// Transparent cup
jarEl.src = `data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs%3D`;
var EDGE_SIZE = 30;
boxBody = new p2.Body({ mass: 0, position: [cupBase[0], cupBase[1]] });
// bottom edge
boxShape = new p2.Box({ width: CUP_WIDTH, height: EDGE_SIZE });
boxShape.material = this.materials.wall;
boxBody.addShape(boxShape);
this.world.addBody(boxBody);
// left edge
this.world.addBody(this.createRectangleBody([cupBase[0] - Math.ceil((CUP_WIDTH + EDGE_SIZE) / 2), cupBase[1] + Math.floor((CUP_HEIGHT + EDGE_SIZE) / 2)],
EDGE_SIZE, CUP_HEIGHT, 0));
// right edge
this.world.addBody(this.createRectangleBody([cupBase[0] + Math.floor((CUP_WIDTH + EDGE_SIZE) / 2), cupBase[1] + Math.floor((CUP_HEIGHT + EDGE_SIZE) / 2)],
EDGE_SIZE, CUP_HEIGHT, 0));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment