Matter.Render.create Options in Matter.js

This guide provides a comprehensive overview of the configuration options available in Matter.Render.create() within the Matter.js 2D physics engine. It covers the primary initialization parameters, canvas sizing, visual rendering properties, and built-in visual debugging flags to help you fully customize your physics simulations.


Core Configuration Properties

The Matter.Render.create(options) method initializes a canvas-based renderer for visualizing a physics engine. The options argument accepts the following top-level properties:


Display and Canvas Options (options.options)

The following properties are set inside the nested options object to control the canvas dimension, rendering style, and behavior:


Visual Debugging Options (options.options)

Matter.js includes a wide range of visual diagnostics that can be toggled on to inspect the physics world during runtime:


Implementation Example

const render = Matter.Render.create({
  element: document.getElementById('canvas-container'),
  engine: engine,
  options: {
    width: 1024,
    height: 768,
    pixelRatio: window.devicePixelRatio,
    wireframes: false,
    background: '#f4f4f4',
    showVelocity: true,
    showCollisions: true,
    showAngle: false
  }
});

Matter.Render.run(render);