Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request- export voronoi cell as svg #7

Open
Tungee opened this issue Dec 12, 2016 · 1 comment
Open

Feature request- export voronoi cell as svg #7

Tungee opened this issue Dec 12, 2016 · 1 comment

Comments

@Tungee
Copy link

Tungee commented Dec 12, 2016

It would be also usable, to be able to export the voronoi cells as a svg.
Best regards

@Ferrous256
Copy link

I would also be interested in this functionality. I attempted to create a vector output for the voronoi cells by making the following changes to the end of the draw function.

  if (saveNow) {
    statusDisplay = "Saving SVG File";
    saveNow = false;

    fileOutput = loadStrings("header.txt");

    String rowTemp;

    float SVGscale = (800.0 / (float) mainheight);
    int xOffset = (int)(1600 - (SVGscale * mainwidth / 2));
    int yOffset = (int)(400 - (SVGscale * mainheight / 2));

    if (fileModeTSP) { // Plot the PATH between the points only.
      println("Save TSP File (SVG)");

    for (Polygon2D poly : voronoi.getRegions()) {
        // Path header::
        rowTemp = "<path style=\"fill:none;stroke:black;stroke-width:2px;stroke-linejoin:round;stroke-linecap:round;\" d=\"M ";
        fileOutput = append(fileOutput, rowTemp);
        
        
            for (Vec2D v : poly.vertices) {
              float xTemp = v.x;
              float yTemp = v.y;
              rowTemp = xTemp + " " + yTemp + "\r";
              fileOutput = append(fileOutput, rowTemp);
            }
            rowTemp = "Z";
        fileOutput = append(fileOutput, rowTemp);
        fileOutput = append(fileOutput, "\" />"); // End path description
    }
      
    } else {
      println("Save Stipple File (SVG)");

This seems to only output a less "evolved" version of the voronoi cells, But I dont know exactly what im doing here so perhaps you could offer some assistance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants