# Exporting lines drawn by mouse to SVG

**URL:** <https://discourse.processing.org/t/exporting-lines-drawn-by-mouse-to-svg/43586>\
**Category:** Coding Questions\
**Created:** [December 30, 2023, 5:36pm UTC](https://discourse.processing.org/t/exporting-lines-drawn-by-mouse-to-svg/43586 "2023-12-30T17:36:49Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [December 30, 2023, 10:59pm UTC](https://discourse.processing.org/t/exporting-lines-drawn-by-mouse-to-svg/43586/7 "2023-12-30T22:59:00Z")

</div>

> [@aFewScrewsLoose](#):
>
> Any thoughts on this syntax?

Take a look here:  
_[ArrayList of objects / Examples / Processing.org](https://processing.org/examples/arraylistclass.html)_

Instead of balls create an empty _ArrayList_ of _PVectors_ in _setup()_.

> [@aFewScrewsLoose](#):
>
> ` line.add(new PVector()); //add a new PVector containing the mouse_pos coordinates to an Array List ('line')`

You don’t have the co-ordinates in the PVector.

I always start simple and build on that.  
Consider just storing the _PVectors_ for now and drawing lines in a for loop.

```auto
void svgRecord() 
  {
  PGraphics svg = createGraphics(width, height, SVG, "output.svg");
  svg.beginDraw();
  svg.stroke(255, 0, 0);
  svg.line(0, 0, width, height); // This works!
  for (int j = 1; j < line.size(); j++)       
    {
    // Your line
    }
  svg.endDraw();
  }

```

Later you can deal with shapes or create a _PShape_.

Your approach with shape may very well work… it did not initially when testing.  
I throttled back to simply first to get a working example to build on first

Example here of drawing lines from last point to current point:  
_[Vertex Trail with fading alpha possible?](https://discourse.processing.org/t/vertex-trail-with-fading-alpha-possible/43522)_

`:)`

---

_[View the full topic](https://discourse.processing.org/t/exporting-lines-drawn-by-mouse-to-svg/43586)._
