Prototyping 2013-09-23 (Networked Media): Difference between revisions

From XPUB & Lens-Based wiki
 
(9 intermediate revisions by the same user not shown)
Line 2: Line 2:


Sept 23 2013: 1.02 "Turtles & Ducks"
Sept 23 2013: 1.02 "Turtles & Ducks"
== Promiscious bits ==
Last week the question came up of transforming audio to text and back again. What does it mean to re-interpret bits as another media? Examples.


== Promiscous interfaces ==
== Promiscous interfaces ==


Computer languages are naturally "promiscuous" in that the interesting things they do are typically provided by libraries -- which is like a software application that you use by programming through the language.
Generally the interesting things you can do with a programming language are provided by specific libraries. A code library is like a software application that you use via programming. Code written for a specific library often remains "glued" to it in the sense that if the specific library isn't available on another platform, or changes, the code will either not work or break. A degree of "promiscuity" or in this case robustness occurs when the "bindings" are less specific and code can change on "both sides" of the abstraction of a libraries interface allowing changes in one to not break the other.


Python supports a flexible concept of typing sometimes called [[Wikipedia:Duck typing|duck typing]]. What if we secretly replaced our turtle with another turtle trained to respond in exactly the same way as the one built-in to Python, but with a alternative agenda ;)
Python supports a flexible concept of typing sometimes called [[Wikipedia:Duck typing|duck typing]]. What if we secretly replaced our turtle with another turtle trained to respond in exactly the same way as the one built-in to Python, but with a alternative agenda ;)
Line 17: Line 12:


* [[Inkscape]] A free-software [[Vector graphics]] editor
* [[Inkscape]] A free-software [[Vector graphics]] editor
* [[SVG]] An [[wikipedia:open standard|open standard]] for vector graphics
* [[XML]] A standard way of creating (text) documents using "markup" with tags, designed for "interoperability"
* [[XML]] "Universal" Markup for all kinds of documents
* [[SVG]] An [[wikipedia:open standard|open standard]] for vector graphics, based on XML
* [[Inkscape Plugin]] (a ([[Python]]) program that transforms an SVG file, typically run from within the Inkscape interface)
* [[Inkscape Plugin]] A ([[Python]]) program that transforms an SVG file, typically run from within the Inkscape interface


== Rough Notes ==
== Rough Notes ==
Line 30: Line 25:
[[Seymour]]!
[[Seymour]]!


== Promiscuity ==
== New possibilities in the intersection of tools ==
* Inkscape: Apply path tools to a resulting drawing (need good example -- how to join nodes ?!)
* Inkscape: Apply path tools to a resulting drawing (need good example -- how to join nodes ?!)
* Python: Load a JSON feed (following Max's example?)
* Python: Load a JSON feed (following Max's example?)
Line 47: Line 42:


Extra: Think about other Inkscape/Python plugins
Extra: Think about other Inkscape/Python plugins
== Reading an RSS Feed as JSON in Python ==
The following website can convert an RSS feed into JSON:
http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=
So to convert the BBC's news feed:
http://feeds.bbci.co.uk/news/rss.xml
You could use this URL:
http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://feeds.bbci.co.uk/news/rss.xml
== About embedding SVG ==
You can place an SVG "inline" (ie cut and paste the code into an HTML page).
In addition, there are different ways to embed an external SVG image, see:
http://tecfa.unige.ch/guides/svg/ex/html5/circle.html


== Examples ==
== Examples ==
* http://archipels.be A website I worked on that uses SVG+html plus some other random tools


Putting SVG Online
Reading from a feed...
<source lang="python">
import urllib2
import json
 
# url = "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://feeds.bbci.co.uk/news/rss.xml"
url = "http://gdata.youtube.com/feeds/api/standardfeeds/top_rated?v=2&alt=jsonc"
 
f = urllib2.urlopen(url)
 
data = json.load(f)
# things = data['responseData']['feed']['entries']
things = data['data']['items']
for i in things:
    print i['title']
</source>
 
 
Now using Seymour:
<source lang="python">
import urllib2
import json
 
# url = "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://feeds.bbci.co.uk/news/rss.xml"
url = "http://gdata.youtube.com/feeds/api/standardfeeds/top_rated?v=2&alt=jsonc"
 
f = urllib2.urlopen(url)
 
data = json.load(f)
# things = data['responseData']['feed']['entries']
things = data['data']['items']
for i in things:
    turtle.pd()
    turtle.fd(100)
    turtle.pu()
    turtle.text(i['title'])
    turtle.fd(10)
</source>
 
 
 
* http://archipels.be is a website project I worked on that uses SVG+html plus some other random tools to make a browser of avant-garde music
 
The project made use of the following code:


* http://code.google.com/p/svgpan/
* http://code.google.com/p/svgpan/
* http://www.cyberz.org/projects/SVGPan/tiger.svg  ... cue 80s music!
* http://www.cyberz.org/projects/SVGPan/tiger.svg  ... cue 80s music!

Latest revision as of 15:53, 23 September 2013

Construction.gif This page is currently being worked on.

Sept 23 2013: 1.02 "Turtles & Ducks"

Promiscous interfaces

Generally the interesting things you can do with a programming language are provided by specific libraries. A code library is like a software application that you use via programming. Code written for a specific library often remains "glued" to it in the sense that if the specific library isn't available on another platform, or changes, the code will either not work or break. A degree of "promiscuity" or in this case robustness occurs when the "bindings" are less specific and code can change on "both sides" of the abstraction of a libraries interface allowing changes in one to not break the other.

Python supports a flexible concept of typing sometimes called duck typing. What if we secretly replaced our turtle with another turtle trained to respond in exactly the same way as the one built-in to Python, but with a alternative agenda ;)

Some tools + concepts

  • Inkscape A free-software Vector graphics editor
  • XML A standard way of creating (text) documents using "markup" with tags, designed for "interoperability"
  • SVG An open standard for vector graphics, based on XML
  • Inkscape Plugin A (Python) program that transforms an SVG file, typically run from within the Inkscape interface

Rough Notes

  • Inkscape: XML Editor
  • SVG: Open in a text editor... draw by typing, search and replace

Turtle Vectors

Seymour!

New possibilities in the intersection of tools

  • Inkscape: Apply path tools to a resulting drawing (need good example -- how to join nodes ?!)
  • Python: Load a JSON feed (following Max's example?)

Inkscape forums

Results for search "Joining nodes inkscape":

Afternoon

Practice with Seymour

Extra: Think about other Inkscape/Python plugins

Reading an RSS Feed as JSON in Python

The following website can convert an RSS feed into JSON:

http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=

So to convert the BBC's news feed:

http://feeds.bbci.co.uk/news/rss.xml

You could use this URL:

http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://feeds.bbci.co.uk/news/rss.xml

About embedding SVG

You can place an SVG "inline" (ie cut and paste the code into an HTML page).

In addition, there are different ways to embed an external SVG image, see:

http://tecfa.unige.ch/guides/svg/ex/html5/circle.html

Examples

Reading from a feed...

import urllib2
import json

# url = "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://feeds.bbci.co.uk/news/rss.xml"
url = "http://gdata.youtube.com/feeds/api/standardfeeds/top_rated?v=2&alt=jsonc"

f = urllib2.urlopen(url)

data = json.load(f)
# things = data['responseData']['feed']['entries']
things = data['data']['items']
for i in things:
    print i['title']


Now using Seymour:

import urllib2
import json

# url = "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://feeds.bbci.co.uk/news/rss.xml"
url = "http://gdata.youtube.com/feeds/api/standardfeeds/top_rated?v=2&alt=jsonc"

f = urllib2.urlopen(url)

data = json.load(f)
# things = data['responseData']['feed']['entries']
things = data['data']['items']
for i in things:
    turtle.pd()
    turtle.fd(100)
    turtle.pu()
    turtle.text(i['title'])
    turtle.fd(10)


  • http://archipels.be is a website project I worked on that uses SVG+html plus some other random tools to make a browser of avant-garde music

The project made use of the following code: