Export SVG file from p5.js?

ReferenceError: SVG is not defined

You have to have the following line of code in index.html:

<script src=“https://unpkg.com/p5.js-svg@1.3.1”></script>

Which then yields this output.
svg

For some reason it only wants to open in a word processing app (Atom) which reveals lots of lines of data, in contradistinction to the first method which has only sparse data. It will open in either Safari or Chrome browsers but is a small image; not sure if that is what is intended or it is only a thumbnail. I also tried to import it into the Photos.app but it complains that it can’t read the metadata. I checked the latter in one of my own apps and there is indeed metadata which is shown below.

MetaData: 
_kMDItemDisplayNameWithExtensions      = “mySVG.svg”
com_apple_metadata_modtime             = 682494077.1811185
kMDItemContentCreationDate             = 2022-08-18 05:41:17 +0000
kMDItemContentCreationDate_Ranking     = 2022-08-18 00:00:00 +0000
kMDItemContentModificationDate         = 2022-08-18 05:41:17 +0000
kMDItemContentModificationDate_Ranking = 2022-08-18 00:00:00 +0000
kMDItemContentType                     = “public.svg-image”
kMDItemContentTypeTree                 = (
    “public.svg-image”,
    “public.image”,
    “public.data”,
    “public.item”,
    “public.content”,
    “public.xml”,
    “public.text”
)
kMDItemDateAdded                       = 2022-08-18 05:42:31 +0000
kMDItemDateAdded_Ranking               = 2022-08-18 00:00:00 +0000
kMDItemDisplayName                     = “mySVG.svg”
kMDItemDocumentIdentifier              = 0
kMDItemFSContentChangeDate             = 2022-08-18 05:41:17 +0000
kMDItemFSCreationDate                  = 2022-08-18 05:41:17 +0000
kMDItemFSCreatorCode                   = “”
kMDItemFSFinderFlags                   = 0
kMDItemFSHasCustomIcon                 = (null)
kMDItemFSInvisible                     = 0
kMDItemFSIsExtensionHidden             = 0
kMDItemFSIsStationery                  = (null)
kMDItemFSLabel                         = 0
kMDItemFSName                          = “mySVG.svg”
kMDItemFSNodeCount                     = (null)
kMDItemFSOwnerGroupID                  = 20
kMDItemFSOwnerUserID                   = 501
kMDItemFSSize                          = 22764
kMDItemFSTypeCode                      = “”
kMDItemInterestingDate_Ranking         = 2022-08-18 00:00:00 +0000
kMDItemKind                            = “SVG document”
kMDItemLastUsedDate                    = 2022-08-18 05:44:33 +0000
kMDItemLastUsedDate_Ranking            = 2022-08-18 00:00:00 +0000
kMDItemLogicalSize                     = 22764
kMDItemPhysicalSize                    = 24576
kMDItemUseCount                        = 3
kMDItemUsedDates                       = (
    “2022-08-18 05:00:00 +0000”
)

I am unfamiliar with the .svg format and am unclear about what advantages there are to using it.

2 Likes