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

From XPUB & Lens-Based wiki
(Created page with "{{under construction}} Sept 23 2013: 1.02 "Turtles & Ducks" Promiscious Bits * Playing audio as text and back again... "Promiscous" interfaces - what if turtle is reprogra...")
 
 
(15 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{under construction}}
{{underconstruction}}


Sept 23 2013: 1.02 "Turtles & Ducks"
Sept 23 2013: 1.02 "Turtles & Ducks"


== Promiscous interfaces ==


Promiscious Bits
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.
* Playing audio as text and back again...


"Promiscous" interfaces
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 ;)
- what if turtle is reprogrammed...
as an Inkscape Plugin!


* Inkscape
== Some tools + concepts ==
* SVG
* XML / Markup
* Plugin


** XML Editor -- show source....
* [[Inkscape]] A free-software [[Vector graphics]] editor
** Open Inkscape Drawing in Text Editor
* [[XML]] A standard way of creating (text) documents using "markup" with tags, designed for "interoperability"
* [[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
 
== Rough Notes ==
 
* Inkscape: XML Editor
* SVG: Open in a text editor... draw by typing, search and replace
 
== Turtle Vectors ==


[[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 ?!)
* Python: Load a JSON feed (following Max's example?)
* Python: Load a JSON feed (following Max's example?)
* Inkscape: Apply path tools to a resulting drawing (need good example -- how to join nodes ?!)


== Inkscape forums ==
== Inkscape forums ==
Line 34: Line 37:
* http://imagesbyheatherm.wordpress.com/2009/10/09/joining-lines-in-inkscape-using-the-node-tool/
* http://imagesbyheatherm.wordpress.com/2009/10/09/joining-lines-in-inkscape-using-the-node-tool/


(Afternoon: Practice with Seymour / Extra: Think about other Inkscape/Python plugins)
== 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...
<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


> evt show archipel? (SVG + html)
The project made use of the following code:


Putting SVG Online
* 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: