jenniferemshepherd / dawn

procedurally generated socio-genetic simulation
2 stars 1 forks source link

RenderInheritor #134

Open rcvink opened 6 years ago

rcvink commented 6 years ago

Dear sirs/madams/others - please specify:

Currently when we create a new cell from parents we do it like this:

var cell = new Cell(this._bodyModule.fromVertices(
      this._positionInheritor.x(parent1, parent2),
      this._positionInheritor.y(parent1, parent2),
      this._shapeInheritor.childVertices(parent1, parent2),
      { render: {fillStyle: this._colourInheritor.colourMixer(parent1, parent2) }}),
                        new Gait(),
                        new Age(time),
                        new Voice()
                       );

It could be cleaner if we had a RenderInheritor which returned a more useful object, cleaning up our code into something like this:

var cell = new Cell(this._bodyModule.fromVertices(
      this._positionInheritor.x(parent1, parent2),
      this._positionInheritor.y(parent1, parent2),
      this._shapeInheritor.childVertices(parent1, parent2),
      this._renderInheritor.childRender(parent1, parent2)
      ),
                        new Gait(),
                        new Age(time),
                        new Voice()
                       );

For anyone who might be thinking 'Roland you're trying to remove our code from the project!' It is not so.

The render inheritor would still need a colourInheritor to mix the parents' colours! It could be instantiated like this:

var colourInheritor = new ColourInheritor(rgbFormatter, mutator);
var renderInheritor = new RenderInheritor(colourInheritor);

Thoughts comments feedback?