# How to covert vectors to SVG paths?

**URL:** <https://discourse.processing.org/t/how-to-covert-vectors-to-svg-paths/15942>\
**Category:** Coding Questions\
**Created:** [November 29, 2019, 8:20am UTC](https://discourse.processing.org/t/how-to-covert-vectors-to-svg-paths/15942 "2019-11-29T08:20:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![buria](https://avatars.discourse-cdn.com/v4/letter/b/8dc957/32.png) [@buria](https://discourse.processing.org/u/buria)\
**Post date:** [November 29, 2019, 8:20am UTC](https://discourse.processing.org/t/how-to-covert-vectors-to-svg-paths/15942/1 "2019-11-29T08:20:36Z")

</div>

I’m using this sketch made by 郑越升Sen and I’m trying to export the result as PDF to work on it on Illustrator. But the lines are not paths, they’re a bunch of points. Is there a way to export curve lines as svg maintaining them as path?

```auto
import processing.pdf.*;
PImage img;

Paint paint;
//var paint;
int subStep = 400; //800;
float z = 0; // noise
boolean isStop = false;
int count = 0;

void settings() {
  img = loadImage("Marilyn-Monroe-and-Madonna--82260.jpg");
    //img = createImage(width, height,RGB);
  size(img.width,img.height);

}

void setup() {
  beginRecord(PDF, "everything.pdf");
  paint = new Paint(width/2,height/2);
  background(255, 255, 255);
  colorMode(RGB, 255, 255, 255, 255);
  img.loadPixels();
  //println(img.pixels.length);
  //paint.reset();
   // frameRate(1);
}

void draw() {
  if (!isStop) {
    for (int i = 0 ; i < subStep ; i++) {
      paint.update();
      paint.show();
      z+= 0.01;
    }
  }
  count++;
  if (count > width) {
    isStop = true;
  }
  if (count == subStep) {
      endRecord();
    exit(); 
    }
  //background(255);
  //image(img, 0, 0, width, height);
}

void keyPressed() {

  if (key == 's' || key == 'S') {
    isStop = !isStop;
  } 
}

```

```auto
class Paint {
  float x, y; 
  PVector ppos;
  PVector pos;
  Paint (float x, float y) { 
    //ppos.x = x;
    //ppos.y = y;
    ppos = new PVector(x,y);
    pos = new PVector(x,y);
    //PVector pos = new PVector(x,y);

  } 
  
  PVector vel = new PVector(0,0);
  PVector force = new PVector(0,0);

  
  float maxSpeed = 3.0; // κάνει μικρότερες γραμμές ο μικρότερος αριθμός def 3
  float perception = 5; // def 5 
  float bound = 60; // def 60; όριο από τις άκρες
  float boundForceFactor = 0.16; //def .16
  float noiseScale = 100.0;
  float noiseInfluence = 1 / 20.0; // def 1/20
  
  float dropRate = 0.004; // κάθε πότε τελεία //.004
  float dropRange = 40.0;
  float dropAlpha = 150.0;
  float drawAlpha = 50.0;
  color drawColor = color(0, 0, 0, drawAlpha);
  float drawWeight = 1.0;
  int count = 0;
  int maxCount = 100;
  
  void update(){
    ppos = pos.copy();
    force.mult(0); 
    // Add pixels force
    PVector target = new PVector(0,0);
    
    int count = 0;
    for (int i = -floor(perception/2) ; i < perception/2 ; i++ ) { // μια μήτρα από 5/2 =-2 μέχρι 2
      for (int j = -floor(perception/2) ; j < perception/2 ; j++ ) {
        if (i == 0 && j == 0)
          continue; // skip to next iteration
        int x = floor(pos.x+i);
        int y = floor(pos.y+j);
        if (x <= img.width - 1 && x >= 0 && y < img.height-1 && y >= 0) {
          int pxx = int(y) * img.width + int(x);
          color c = img.pixels[pxx];
          float b = brightness(c);
          b = 1 - b/100.0;           
          PVector p = new PVector(i, j);
          target.add(p.normalize().copy().mult(b).div(p.mag())); 
          count++;
        }
      }
    }
    if (count != 0) {
      force.add(target.div(count));
    }
    
    // Add noise force
    float n = noise(pos.x/noiseScale, pos.y/noiseScale, z);
    n = map(n, 0, 1, 0, 5*TWO_PI);
    //var p = p5.Vector.fromAngle(n);
    PVector p = PVector.fromAngle(n); // Calculates and returns a new 2D unit vector from the specified angle value (in radians). 
    if(force.mag() < 0.01)
      force.add(p.mult(noiseInfluence * 5));
    else
      force.add(p.mult(noiseInfluence));
    
    // Add bound force
    PVector boundForce = new PVector(0,0);
    //var boundForce = createVector(0, 0);
    if (pos.x < bound) {
      boundForce.x = (bound-pos.x)/bound;
    } 
    if (pos.x > width - bound) {
      boundForce.x = (pos.x - width)/bound;
    } 
    if (pos.y < bound) {
      boundForce.y = (bound-pos.y)/bound;
    } 
    if (pos.y > height - bound) {
      boundForce.y = (pos.y - height)/bound;
    } 
    force.add(boundForce.mult(boundForceFactor));
    
    
    vel.add(force);
    vel.mult(0.9999);
    if (vel.mag() > maxSpeed) {
      vel.mult(maxSpeed/vel.mag());
    }
    
    pos.add(vel);
    if (pos.x > width || pos.x < 0 || pos.y > height || pos.y < 0) {
      reset();
    }
    
  }

  void reset() {
    img.updatePixels();
    img.loadPixels();

    count = 0;
    //maxCount = 200;
    boolean hasFound = false;
    while (!hasFound) {
      pos.x = random(1)*width;
      pos.y = random(1)*height;
      int pxx = int(pos.y) * img.width + int(pos.x);
      color c = img.pixels[pxx];
      //float c = fget(floor(pos.x), floor(pos.y));
      float b = brightness(int(c));
      if(b < 35)
        hasFound = true;
    }
    int pxx = int(pos.y) * img.width + int(pos.x);
    drawColor = img.pixels[pxx];
    drawColor = color(red(drawColor),green(drawColor),blue(drawColor),drawAlpha);
    ppos = pos.copy();
    vel.mult(0);
  }

  void show() {
    count++;
    if (count > maxCount)
      reset();
    stroke(drawColor);
    strokeWeight(drawWeight);
    if (force.mag() > 0.1 && random(1) < dropRate) {
      //drawColor.setAlpha(dropAlpha);
      stroke(drawColor);
      float boldWeight = drawWeight+random(5);
      strokeWeight(boldWeight);
      //drawColor.setAlpha(drawAlpha);
    } 
    
    line(ppos.x, ppos.y, pos.x, pos.y);
    // doesn't seem to do much from what i saw
   // fadeLineFromImg(ppos.x, ppos.y, pos.x, pos.y);
  }
  

  
}

```

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [December 8, 2019, 7:57pm UTC](https://discourse.processing.org/t/how-to-covert-vectors-to-svg-paths/15942/2 "2019-12-08T19:57:58Z")

</div>

Did you resolve this problem?

Have you tried exporting to SVG rather than to PDF?

[https://processing.org/reference/libraries/svg/index.html](https://processing.org/reference/libraries/svg/index.html)

---

<div class="post-metadata">

**Author:** ![buria](https://avatars.discourse-cdn.com/v4/letter/b/8dc957/32.png) [@buria](https://discourse.processing.org/u/buria)\
**Post date:** [December 12, 2019, 12:33am UTC](https://discourse.processing.org/t/how-to-covert-vectors-to-svg-paths/15942/3 "2019-12-12T00:33:37Z")

</div>

Hi. I didn’t. Maybe I didn’t explain myself very well. When exporting and opened in Illustrator, I can’t select a created line because every point/vector created is on a different layer. When running the code you see each line being created. What I wanted was to have each line on Illustrator.

I tried SVG export and I couldn’t do it either.
