This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@supports (background: paint(id)) { | |
/* good to go! */ | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ('paintWorklet' in CSS) { | |
// good to go! | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Matter.Events.on(engine, 'beforeUpdate', function(event) { | |
if (pinball.position.x > 450 && pinball.velocity.y > 0) { | |
Matter.Body.setVelocity(pinball, { x: 0, y: -10 }); | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Matter.Events.on(engine, 'collisionStart', function(event) { | |
let a = event.pairs.bodyA; | |
let b = event.pairs.bodyB; | |
// check bodies, do whatever... | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const CUSTOM_PATH = '425.6 327 273.8 315.6...'; | |
function customShape(x, y) { | |
let vertices = Matter.Vertices.fromPath(CUSTOM_PATH); | |
return Matter.Bodies.fromVertices(x, y, vertices, { | |
// set options if you need them... | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<polygon points="425.6 327 273.8 315.6..."/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function wall(x, y, width, height) { | |
return Matter.Bodies.rectangle(x, y, width, height, { | |
chamfer: { radius: 10 }, | |
// other options here... | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// wrong | |
square.setAngularVelocity(0.1); | |
// correct | |
Matter.Body.setAngularVelocity(square, 0.1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function rect(x, y, width, height, color) { | |
return Matter.Bodies.rectangle(x, y, width, height, { | |
isStatic: true, | |
restitution: 1, | |
render: { fillStyle: color } | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// params: x, y, width, height, options | |
let square = Matter.Bodies.rectangle(200, 100, 50, 50, { | |
// specify options here | |
}); | |
Matter.World.add(engine.world, square); |