Vecci graphics user export script

Started by Astrosynthesist, December 28, 2017, 07:40:53 PM

Previous topic - Next topic

Astrosynthesist

Hi everyone.

I got tired of manually writing my own vector lists after fleshing them out in vecci (the vide vector drawing utility), so I wrote my own script to manually output the vectorlists in user export mode. The only issue is that it does not account for lists longer than 200 characters. I'm not super familiar with working in what I assume is javascript (this is javascript, right?) I just wrote this based on the other exports as examples.
StringBuffer b = new StringBuffer();
Vector allvectors = vecci.getVectors();
GFXVector onvector =(GFXVector)  allvectors.elementAt(0);
Vertex start = onvector.start;
b.append("{{MoveTo,"+(int)start.x()+","+(int)start.y()+"}");
Vertex old_end = start;
for (int i=0; i<allvectors.size(); i++)
{
  onvector =(GFXVector)  allvectors.elementAt(i);
  start = onvector.start;
  Vertex end = onvector.end;
  if ( start.x() != old_end.x() || start.y() != old_end.y() )
  {
    b.append(",{MoveTo,"+(int)start.x()+","+(int)start.y()+"}");
  }
  b.append(",{DrawTo,"+(int)end.x()+","+(int)end.y()+"}");
  old_end = end;
}
b.append("}");
  out += b.toString();


If anyone wants to add the 200 character correction (adds an underscore and newline for every 170 characters) I would be very grateful if you reply to this post with it but this as it is is still much more convenient. Enjoy!

Astrosynthesist

#1
Here it is with end of line correction.
StringBuffer buffer = new StringBuffer();
StringBuffer line = new StringBuffer();
Vector allvectors = vecci.getVectors();
GFXVector onvector =(GFXVector)  allvectors.elementAt(0);
Vertex start = onvector.start;
int linelength = 100;
line.append("{{MoveTo,"+(int)start.x()+","+(int)start.y()+"}");
Vertex old_end = start;
for (int i=0; i<allvectors.size(); i++)
{
  onvector =(GFXVector)  allvectors.elementAt(i);
  start = onvector.start;
  Vertex end = onvector.end;
  if ( start.x() != old_end.x() || start.y() != old_end.y() )
  {    if (line.length() >= linelength )
    {
      buffer.append(line + ",_\n    ");
      line.setLength(0);
      linelength = 179;
    }
    else
    {
      line.append(",");
    }
    line.append("{MoveTo,"+(int)start.x()+","+(int)start.y()+"}");
  }
  if (line.length() >= linelength)
  {
    buffer.append(line + ",_\n    ");
    line.setLength(0);
    linelength = 179;
  }
  else
  {
    line.append(",");
  }
  line.append("{DrawTo,"+(int)end.x()+","+(int)end.y()+"}");
  old_end = end;
}
buffer.append(line + "}");
out += buffer.toString();

Malban

Hi,
Actually - there is a small checkbox next to the "Vectorlist export button" - Draw_VL_mode.

If that checkbox is checked - the outbut is done in Vec32 BASIC syntax.

But having a script is certainly more versatile...
Malban