Sept 23 2013: 1.02 "Turtles & Ducks"
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
- Inkscape: XML Editor
- SVG: Open in a text editor... draw by typing, search and replace
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?)
Results for search "Joining nodes inkscape":
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:
So to convert the BBC's news feed:
You could use this URL:
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:
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: