Productions

Javascript : load external settings

Load editable settings from an external text file inside an Isadora scene.

In response to an Isadora forum thread, this tutorial demonstrates one method for using the Javascript actor to load externally stored and editable settings.

This is useful for settings that may change from night to night or venue to venue. It lets the operator adjust a show without editing the Isadora file.

For this tutorial, the scene outputs text through the Text Draw actor and uses a coloured background. Eight X and Y settings, as well as the displayed text, control a Rectangle Map quad-distort effect. The values are loaded from an external text file with Javascript.

This tutorial was written for Isadora V2. The actor names and interface may differ in newer releases.

Back to Tools & code

An Isadora scene loading external data to display text and control quad-map values.

Get started

Isadora patch with the Javascript, Text Draw, Projector and Envelope Generator actors.

  1. Open Isadora V2.
  2. Add a Javascript actor, a Text Draw actor, and a Projector to the scene.
  3. Connect Javascript output 1 to the Text Draw text input.
  4. Connect the Text Draw video output to the Projector video input.
  5. Add a Background Color actor and connect its output to the Text Draw video input. Adjust the color input to suit the scene.
  6. Create a text file beside the Isadora file and rename it data.js.
  7. Edit data.js so its only text is // data file. In Javascript, // begins a comment.
  8. Open the stage to confirm the basic scene is in place.

Add some code

Add include('data.js'); as the first line of the Javascript actor.

  • The quotes contain the path and filename. A bare filename means the file sits beside the Isadora file.
  • The external file must be plain text. A .txt extension works, while .js can also be useful in editors such as Notepad++.
  • The file must exist and must not be empty. Otherwise Isadora can raise an error.

Inside the external file

Everything in the external file is parsed as Javascript. A working example can define the displayed name and eight quad offsets:

dx_name = "Loading External Data";

dx_quad_tl_x = 0.20;
dx_quad_tl_y = -0.25;

dx_quad_tr_x = -0.33;
dx_quad_tr_y = -0.05;

dx_quad_br_x = -0.03;
dx_quad_br_y = 0.32;

dx_quad_bl_x = 0.07;
dx_quad_bl_y = 0.07;

These values may represent top-left, top-right, bottom-right, and bottom-left X/Y offsets.

Output the values

Set the Javascript actor to 9 outputs, then use main() to return the name and eight values:

include('data.js');

function main() {
  var data = [];

  data[0] = dx_name;
  data[1] = dx_quad_tl_x;
  data[2] = dx_quad_tl_y;
  data[3] = dx_quad_tr_x;
  data[4] = dx_quad_tr_y;
  data[5] = dx_quad_br_x;
  data[6] = dx_quad_br_y;
  data[7] = dx_quad_bl_x;
  data[8] = dx_quad_bl_y;

  return data;
}

Exit and re-enter the scene so the Javascript actor updates and begins reading the external values.

JSON or other data structures can also be used in the external file. That approach can provide more advanced parsing and settings management.

Control video mapping

Publishing the X and Y offsets for the Rectangle Map involves the following steps:

  1. Double-click the Projector and open its Izzy Map view.
  2. Switch to the Output view.
  3. Select the slice.
  4. Right-click each corner and publish X and Y, in top-left, top-right, bottom-right, bottom-left order.
  5. Close Izzy Map.
  6. Link the nine Javascript outputs to the Text Draw and published corner parameters.

The scene should now use externally editable text and quad-distort values.

The tutorial example was finished with animated text and corner-pin values. With an enter-scene trigger, it can animate those values whenever the scene is entered.