Matter-js: Change style of Bodies

Created on 12 Nov 2017  路  4Comments  路  Source: liabru/matter-js

I am trying to create a stack of Circles, that are filled blue. However I can't get rid of the stroke or set a new fill.

This is my code:

var width = window.innerWidth,
     height = window.innerHeight;

var render = Render.create({
    element: document.getElementById('wrapper'),
    engine: engine,
    width: width,
    height: height,
    wireframes: false
});

render.canvas.width = width;
render.canvas.height = height;
render.options.wireframeBackground = 'transparent';
render.options.background = 'transparent';

Render.run(render);

// x, y, amt x, amt y, gap x, gap y
var stack = Composites.stack(0, 0, 20, 10, 10, 10, function(x, y) {
    return Bodies.circle(x, y, 6, {
        friction: 0.1 ,
        fillStyle: "0045FF",
        render: {
             lineWidth: 0
        }
    });
});
question

All 4 comments

Try this:

  render: {
    fillStyle: '#0045FF'
  }

Yes, works, thanks! Also had to add:
render.options.wireframes = false;

It is kinda weird. It seems like when I create the render the options are not being accepted and I have to override them after creation.

Ah yes that's because you need to put that into options when creating:

var render = Render.create({
    element: document.getElementById('wrapper'),
    engine: engine,
    width: width,
    height: height,
    options: {
      wireframes: false
    }
});

hi

Was this page helpful?
0 / 5 - 0 ratings

Related issues

drachehavoc picture drachehavoc  路  4Comments

cluber22 picture cluber22  路  3Comments

mrspeaker picture mrspeaker  路  3Comments

Zhaopengyang picture Zhaopengyang  路  3Comments

christianmalek picture christianmalek  路  4Comments