Author Topic: Improve Image Scripting: Use Processing  (Read 2377 times)

Nicole Tedesco

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
  • I don't think that's a good idea...
    • View Profile
Improve Image Scripting: Use Processing
« on: July 24, 2008, 12:25:27 am »
Sparx Systems has been very kind to give us the option of scripting custom images for diagram entities in addition to specifying a metafile alternate image.  Unfortunately, I find their scripting language too limited[ch8213]I have yet to be able to use it to create images of the types my clients have actually needed.  In the past I have suggested that Sparx dump their proprietary script in favor of something well known and more expressive like JavaScript (which also opens up a whole realm of other possibilities).  Over time I have rethought my previous position slightly, as there are a few downsides associated with a JavaScript implementation (for instance it would increase the complexity of the product which Sparx Systems would have to support).  However I have just found an alternative expression which Sparx could cozy up to instead, and that is the open source language called "Processing."

http://www.processing.org/

Processing is a language (currently implemented in Java) that was developed primarily to express visual patterns and simple animation, and it reminds me a lot of what Sparx already provides in their existing scripting capabilities. For instance, check out an example from the Processing site for a two-circle object that looks like a smooth abstraction of a Mandelbrot set:

http://www.processing.org/learning/basics/multipleconstructors.html

Code: [Select]
Spot sp1, sp2;
void setup()
{
  size(200, 200);
  background(204);
  smooth();
  noLoop();
  // Run the constructor without parameters
  sp1 = new Spot();
  // Run the constructor with three parameters
  sp2 = new Spot(122, 100, 40);
}

void draw() {
  sp1.display();
  sp2.display();
}

class Spot {
  float x, y, radius;
  // First version of the Spot constructor;
  // the fields are assigned default values
  Spot() {
    x = 66;
    y = 100;
    radius = 16;
  }
  // Second version of the Spot constructor;
  // the fields are assigned with parameters
  Spot(float xpos, float ypos, float r) {
    x = xpos;
    y = ypos;
    radius = r;
  }
  void display() {
    ellipse(x, y, radius*2, radius*2);
  }
}

Processing seems to match Sparx's scripting goals a little closer, such as keeping complexity low by providing expressive image construction without introducing scope-killing generalizations.

So Sparx, how about it?  Could you give us more visual expression capabilities?  You could use Processing as a guide, if not as an outright implementation contract, and it would end up being a natural extension of the direction you have already taken!  Provide a few built-in classes and functions and, viola!  We are ready to go.

So Sparx, how about it?
« Last Edit: July 24, 2008, 12:34:08 am by NicoleTedesco »
Nicole C Tedesco