<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sun, May 12, 2013 at 1:02 AM, Jonathan Wilkes <span dir="ltr">&lt;<a href="mailto:jancsika@yahoo.com" target="_blank">jancsika@yahoo.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">&gt;From: s p &lt;<a href="mailto:sebpiq@gmail.com">sebpiq@gmail.com</a>&gt;<br>
&gt;To: Jonathan Wilkes &lt;<a href="mailto:jancsika@yahoo.com">jancsika@yahoo.com</a>&gt;<br>
&gt;Cc: PD List &lt;<a href="mailto:pd-list@iem.at">pd-list@iem.at</a>&gt;<br>
&gt;Sent: Saturday, May 11, 2013 4:37 PM<br>
&gt;Subject: Re: [PD] pd -&gt; svg<br>
&gt;<br>
&gt;Thanks Jonathan,<br>
&gt;<br>
&gt;I don&#39;t really have the time to take care about this those days, but I&#39;ll fix it as soon as possible, and post here when that&#39;ll be done.<br>
&gt;<br>
&gt;Cheers,<br>
&gt;<br>
&gt;Sébastien<br>
Here&#39;s an idea...<br>
<br>
Suppose I build a Pd gui-plugin that exports a Pd file to svg.  It takes the toplevel patch and makes the drawing instructions like my example in the OP.  But it also draws a little navigation bar at the bottom with 1) a little image with id=&quot;source patchname&quot;, 2) a play button with id = &quot;webpd-play patchname&quot;, 3) a stop button with id = &quot;webpd-stop patchname&quot;<br>


<br>
The image with id=&quot;source patchname&quot; is the base64-encoded source of the patch.  This would be neat because:<br>
<br>
a) Anyone could export to svg and get a file that can be displayed in any modern browser (with searchable/selectable text in most of them).<br>
b) Since the drawing instructions Pd uses are so simple the svg will probably display on mobile devices (even older ones).<br>
c) Since the source is embedded in the file, webpd js could just listen for clicks to any webpd-play buttons in the page, and when it catches one it looks for an svg image with id &quot;source&quot; plus the same patchname as the webpd-play button.  It then decodes the image, loads it and plays it until it receives a &quot;webpd-stop&quot; button click.<br>


<br>
This method has the benefit of degrading gracefully; that is, if someone using NoScript wants to read a forum with pd patch svg images in it, they will still be able to view the image.  Moreover, a forum admin or blog owner can post the svgs simply to show pictures of patches; then later when the audio api becomes more common than just firefox nightly they can add the webpd code once and all their images will now feature audio.<br>


<br>
-Jonathan<br>
</blockquote><div> <br></div><div>This sounds extremely appealing to me.<br><br></div><div>About the HTML side, be careful with using the ID field because it can be used only once and then other uses become impossible. Also, it has to be unique which would effectively prevent the same patch from being embedded more than once.<br>

<br>You might want to consider the CLASS field instead which can hold an unlimited number (theoretically; the practical limit is around 2000) of classes, and classes are already used deliberately to signify different attributes of HTML elements. <br>

</div><div>I&#39;d also recommend prepending the string with something constant that will allow the automatic discovery of such strings among other, non-pd-parseable strings (versus having plain base64-encoded strings, which are not detectable by themselves, or, at least, must be decoded before recognized). For separating the prepended part from the base64 part, CSS allows for any  ISO 10646
  character higher than U+00A1 to be used, or even lower characters when escaped with backslash.  (I don&#39;t recommend an escaped character because the backslash might &quot;disappear&quot; while the HTML get processed by various scripts here and there.)<br>

For example: &lt;img src=&quot;mypatch.svg&quot; class=&quot;thisclass thatclass pd-source_ABC123BASE64STRING&quot; /&gt; would be a nice extendable format.<br><br></div><div>But even better, CSS attributes could be used, which can hold URL values without base64-encoding, and they are also more variable (can be defined elsewhere than in the HTML source, can be overwritten/cascaded without Javascript).<br>

</div><div>This way, the pd-source defined right in the HTML source would look like: &lt;img src=&quot;mypatch.svg&quot; style=&quot;thisproperty: 4px; thatproperty: 30%; -pd-source: url(file://C:\Users\Joe\Desktop\mypatch.pd)&quot; /&gt;<br>

</div><div>Note that the etiquette for introducing non-standard CSS attributes is to start them with the hyphen. (E.g.: -moz-box-shadow) (Similar to custom mime-types beginning with &quot;x-something-&quot;)<br></div><div>

This method would open up an unlimited number of possibilities, just to note a few:<br></div><div>- the pd source could be at any URI that the client can parse: a local filesystem, the web, ftp, or even git<br></div><div>

- it would be easy to parametrize a patch using further attributes (even addressing recieves!) like -pd-param-myparameter (and note that CSS has official support for units like colors, angles, times, and frequencies)<br>
</div>
<div>- there are robust classes available for the management of CSS attributes, first of all with Javascript of course<br></div><div>- seamless integration with a JSON based pd source format would be trivial (<a href="http://lists.puredata.info/pipermail/pd-dev/2012-06/018436.html">http://lists.puredata.info/pipermail/pd-dev/2012-06/018436.html</a>)<br>

</div><div><br><a href="http://www.w3.org/TR/2008/REC-CSS2-20080411/syndata.html">http://www.w3.org/TR/2008/REC-CSS2-20080411/syndata.html</a><br></div><div><br>András
</div></div></div></div>