Skip to content

The Config object

When we create a new vwRtx instance we can give the intance a range of information describing how we initially want it to look, and behave. We do that with the config object.

All about the Config object

The configuration object passed into a new vwRtx instance at instantiation sets its initial appearance, behaviour and contents. The API is then used in code to change the configuration as needed by your app.

The config object is passed into the vwRtx as follows

js
// Make a Konva custom shape and add it to the layer
const hostShape = new Konva.Shape();

// !Important - must happen before rtx is created.
layer.add(hostShape); 

// Example of minimal rtx config
const config = {
  host: hostShape,
  text: "Hello world - it's a traditional kinda thing"
}

const rtx = new vwRtx(config);

Shape of the config object

It is handy to have an awareness of the shape of the config object.

js
const config = {
  host: <host konva shape>,
  ...
  text: <simple, single-style text>,
  textDef: {
    ...
    definition of multi-style text and fonts
    ...
  },
  font: {
    ...
    attributes describing initial font styling 
  },
  shape: {
    ...
    attributes describing initial shape-specific properties
    ...
  },
  para: {
    ...
    attributes describing initial paragraph-specific properties
    ...
  }
}

Optional or Mandatory attributes?

Only the config.host attribute is mandatory. You will have seen that, via the config.font object you can tell the vwRtx the intial font which will be used for all new text unless more styling instructions are provided via the API. It is worth mentioning here that if the font is partly or entirely omitted then the internal defaults are used (see font fallbacks).

A Vanquished Wombat creation.