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

Add first class support for SVG imports and exports #4630

Open
3 of 11 tasks
lostPixels opened this issue Jun 11, 2020 · 15 comments
Open
3 of 11 tasks

Add first class support for SVG imports and exports #4630

lostPixels opened this issue Jun 11, 2020 · 15 comments

Comments

@lostPixels
Copy link

lostPixels commented Jun 11, 2020

Most appropriate sub-area of p5.js?

  • Color
  • [x ] Core/Environment/Rendering
  • Data
  • Dom
  • Events
  • Image
  • IO
  • Math
  • Typography
  • Utilities
  • WebGL
  • Other (specify if possible)

New feature details:

As an artist using p5.js for plotter drawings, I use vector graphics to power my Axidraw. There are very few options for this workflow out there, and p5.js has by far the best API.

Although I am still able to partially use it, the p5js.svg library was abandoned over 5 years ago. It is the only way to draw and export SVGs. It's plagued with many bugs that require a deep understanding to fix.

It would be amazing if p5.js natively supported SVG operations. The 2D API maps perfectly to it, and the only new option that would be nice is loading and manipulating external SVGs.

@welcome
Copy link

welcome bot commented Jun 11, 2020

Welcome! 👋 Thanks for opening your first issue here! And to ensure the community is able to respond to your issue, be sure to follow the issue template if you haven't already.

@brunocastro
Copy link

brunocastro commented Jul 21, 2020

I will need to export svg in my project too. Sometimes, we needed to edit the programmatic art in vector software.

@jimmymorris
Copy link

+1 for this

@bobcgausa
Copy link

https://editor.p5js.org/Bobcook47/sketches/Dk3Osbx3z
Can’t help with export
But am lookin for testers on import
Library handles some files and fragments

@klavsbuss
Copy link

+1

@bobcgausa
Copy link

bobcgausa commented Feb 20, 2021 via email

@nataliefreed
Copy link

+1 on this. Is there a place where this (support for vector exports from P5 for use with pen plotters and other digital fabrication workflows) is being discussed? I know there was a discussion here a while back, and that it's not an easy thing to implement. But not sure if it's a design question or an issue of finding someone with the expertise and time. The workflow for this is so nice in Processing, it would be incredible to have that capability in shareable web apps. There are other Javascript libraries that handle SVGs of course, but there's nothing like P5.js for tinkering and teaching.

@limzykenneth
Copy link
Member

@nataliefreed No current discussions that I know of is going on though there had been pretty consistent interest in this. I think the lack of progress is mostly due to lack expertise and time. It's not a high priority project for p5.js officially at this time and I don't know of any addon projects that are working on this at the moment.

@zenozeng
Copy link
Member

zenozeng commented Jun 6, 2021

@nataliefreed

Hi, I just released [email protected], which fixes a lot of bugs and should work with [email protected].

And the following are the examples for SVG imports and exports

@jimmymorris
Copy link

@zenozeng thanks for updating! this is super exciting, look forward to trying it out!

@aafiyahtech
Copy link

Hi @zenozeng Cool, let me check

There could be huge scope if we could import an SVG as a shape and then manipulate it in p5js, as the native shape doesn't properly support the translate function. So moving the shape becomes difficult

@agrshch
Copy link
Contributor

agrshch commented May 29, 2024

It's great to see that the SVG support is added as a proposal for 2.0!
SVG runtime by @zenozeng is truly amazing, but it doesn't cover all the use cases and it can be significantly slower than regular canvas. It's a solvable issue though. I used tricks like drawing everything on the canvas for preview and creating (and deleting) the second p5 instance to export the result as SVG. But it would be really nice to have an opportunity to load and export SVG files without switching runtime. Like in Processing

@davepagurek
Copy link
Contributor

Some prior discussion on importing SVG is here for context: #5779

@Qianqianye Qianqianye self-assigned this Jun 18, 2024
@thrly
Copy link

thrly commented Sep 18, 2024

+1 on an officially supported SVG export sometime please 🙏

@goldwasser
Copy link

Also adding +1 on official support for SVG import/export.

I believe a more fundamental change that might be a precursor to this is support for shapes as first-class objects, somewhat akin to the PShape class in the Java Processing library. Having shapes as first-class objects would not only be useful/necessary when modeling data associated with an SVG file but would have impact even when not using SVG files. While createShape/endShape can currently be used to render a custom shape, they do not create a first-class object that can be stored or later manipulated or restyled.

Given the advantages of javascript, it would also be great to allow a PShape-like class register callbacks for mouse events such as onEnter, onExit, onClick, and so those would already provide very useful new functionality for a variety of shapes, helping automate tasks such as determining which "shape" is the topmost one underneath a mouse location.

I don't see any open issues about first-class shapes, and I could split this and start a new issue. But given that this particular issue has been tagged for p5.js 2.0, I thought I'd start by adding to this thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Proposal
Development

No branches or pull requests