Sunday, 1 May 2011

Porting from Flash to Flash Builder... Warning!

Hm so I feel quite annoyed with myself for failing to see the point of using Flash Builder. For anyone that doesn't know: Flash Builder is used for building *applications*, i.e. data intensive, drop-down menu-ie type things they use in banks (well not banks, but you get what I mean). It is DEFINITELY NOT for geometric animations, so don't even bother.

My aim was to use its brilliantly simple UI 'mockup' interface, and quickly hook up my ActionScript 3 class file to the controls. This was achieved without any problem. The problem was in getting Flash Builder to recognise the actual animation process that would otherwise come so naturally to the typical Flash setup.

So it was with great disappointment I read this intriguing article about building a pizza companies order form...

It's the best bit of writing on developing I've stumbled upon because it's a hilarious take on exactly what I DO NOT want to be doing: namely building the UI for a pizza delivery company. This made me feel really stupid... but in a good way. From Aral Balkan who knows a thing or two about Flash.

The gist of it is: DO NOT USE FLEX AND BUILDER. Not if you are not making maybe an app for ordering pizza. Definitely not. There's so little info out there on Flash Builder, all in all, compared with Flash, I should've realised.

Anyway, full steam ahead for a new and swanky user interface, comin at cha'

Monday, 18 April 2011

Flash vs. JavaScript - The times they are a-changin'



Recently I started delving into Adobe's journey through code, via ActionScript 3.0. The 3+ version of ActionScript is what I'd describe as nearly object oriented. It's got classes, like Java, but it reads like JavaScript. Rest assured it's hanging on the Java tree as far as language inheritance goes.

It's actually based on the ECMA scripting language (same as JS), and so naturally it shares a lot with JavaScript. The utility of the Flash runtime is it's native geometric toolkit for drawing shapes and making animations. It also has a variety of open-source classes available, ported from other languages to be fully compatible with the Flash runtime.

Although Flash is the 'de facto' toolkit for web graphics because of its popularity with designers, currently more and more people are using the native web language HTML and JavaScript only. HTML5 has a canvas for creating and modifying shapes, like Flash. Apparently, it's quite good.

More and more ports to WebGL in JavaScript are cropping up, through the development of extensive library packages like this one. Also Mr Doob and AlteredQualia have written a port to WebGL for JavaScript called three.js, and it is pure delight to see the results they've got out of it. The equivalent for Flash is the slightly less sophisticated, but still highly useable Papervision3D.



An example of the difference between a series of Bezier curves (top) and a spline curve - spline much smoother and more 'natural'.













The way that graphics software developers (read: mathematicians) think is this: what formula best summarises the 'physics' of what you want to see on the screen? For example fire is a common request. In order to make a 'virtual fire' you have to create all the necessary elements for it to work. You have to feed it fuel and oxygen, and you have to represent the burning through the use of the Planck Energy Distribution Equation. I find this very interesting. And if you like that sort of thing, there's a very well written web page here by Hugo Elias.

Here is an explanation of the Planck Energy Distribution Equation.

The availability of pseudocode is essential for the transfer of knowledge across the dark art of computer programming.

Friday, 25 March 2011

Jim Jarmusch Quote About Theft, Cinematography, Creativity - Multimedia



Theft is beautiful. Like Picasso said "good artists copy, great artists steal". Originality is impossible without inspiration.



The photograph was taken by me with UCLU PhotoSoc in the studio of Huntley Street Students Union building (possibly to be got rid of, which would be rubbish). You can see the originals and more sets of photos here.

Wednesday, 2 March 2011

Homer Simpson - QuadTree Art



Here is Homer. He's been dismantled into a trillion micro-bytes and recombobulated around about tea time, presently.

Homer wants to transport himself using tiny packets and send himself far across the ocean to the other side of the universe. Why? Just in case there's something interesting over there.


------------------------------------------------------------
The reason Homer looks strange is because the quadtree being used was for square shaped segments, but the picture here is clearly not a square, and so the size mis-match has caused a misalignment.

Saturday, 26 February 2011

Seeking to Please is a Perilous Trap

In trying to please other people, we find ourselves misdirected toward what lies outside our sphere of influence. In doing so we lose our hold on life's purpose.
Content yourself with being a lover of wisdom, a seeker of the truth. Return and return again to what is essential and worthy.
Do not try to seem wise to others.
If you wanted to live a wise life, live it on your own terms.

This excerpt was taken from a book called The Art of Living: The Classic Manual on Virtue, Happiness, and Effectiveness and was written by followers of the Stoic philosopher Epictetus around 100AD (Epictetus didn't write his words down).

What I think the words mean encompasses what it is to be a Stoic or to act stoically. That is, to stop trying to control things that are beyond your control and to concentrate on what's important.

Sunday, 6 February 2011

Introducing spirals.

Spirals are strange. Especially when you think about it mathematically and geometrically.

Below are some examples of spirals I've made using pure code alone. The 3D effect is done using rectangle instead of more conventional lines. It looks a lot more cool if you do this, even if it is in 2D!

Spiral 1:





Spiral 2:





I like this one, even if it's a bit abstract:





Spirally spiral:





----------------------------------------------------
Finally, here is some of the code for the spirals above. Please note, the `z` variable is commented out because I don't actually use it, although perhaps will do with future graphics stuff.


The Game that is the Economy



So this week I visited the Institue of Child Health, one of the many medical departments of University College London. This had nothing to do with health though apart from I suppose the health of the economy.

The keynote speakers can be seen here.

This was a chance to get a thoroughly academic view on the state of finances within each of the international economies. The conference started with a look into the 'traditional' theories surrounding microeconomics, involving several of the games that agents are known to play in abstracted economic thought experiments.

Agents in economics are elemental actors within the economic space, often individuals with some kind of (usually liquid) capital. Agents interact with each other creating transactions. Within micro-economics agents are more individualistic although the size of agents can be treated in a more macroscopic view when dealing with macroeconomics instead.

The emphasis on textbook economics and econometrics is based on the assumtption of rational gain, whereby agents are treated as fundamentally greedy and self-interested.

This view leads to problems. The difficulties here were most obviously exposed during and in the aftermath of the financial crisis...

This paper highlights the emerging economic thought over 'traditional' micro-economics of self interest.

The talks were a mix between these macro- and microeconomics perspectives. The first, from Dr Pete Lunn, was about behavioural economics and neuroscience, given his background. He seemed to be suggesting that decisions were based on thresholds of acceptance rather than simple self-interest and absolute 50:50 rationality (viz. 'traditional' economic theory). These thresholds were later shown to be based on many cultural and psychological factors involving the degrees to which people are willing to accept offers made to them.

The over-arching 'game' introduced during the talks was called the Ultimatum Game. This game involves two agents acting out an economic scenario. The first agent has for example £100. Now they can only keep any of that money if the second agent allows them to by her coming to an agreement about how to split the total. If the first agent suggests say £50 then the second is almost certainly going to accept. Several studies have shown that if the offer is below £20 then most people will reject doing a deal.

The £20 figure is what varies across cultures and amongst differing psychological profiles.

More to follow...

Friday, 7 January 2011

Finding a route on the Underground using pure Java code

I started my project by being impressed by the interesting possibilities involved with developing my own software that could traverse the entire London Underground network. It read as follows:

Q3. A classic but interesting to write program: Write a Java program to find the route between any
two stations on the London Underground network (and now London Overground). The user should
be able to select a start and destination station and the program then finds the route between
them, printing out travel instructions such as which line to take, where to change lines, and so on.
The data describing the network should be stored in one or more files, and read when the program
is run.


Of course I hadn’t reckoned on how hard it would be.

First off, I hadn’t previously considered the nature of a graph data structure.

A graph (in computer science) is a collection of nodes and edges. Nodes in my case represent stations. Each node has a set of items called edges. Edges represent the links between the nodes, in a way that reflects the true inter-connectedness of the tube network.

Each edge comes with three parts to it. There’s the name of the starting node, the name of the endpoint node (on the other end), and the name of the line that the edge is describing.

So you see, a working route finder is very dependent on having the right data available.

First off I had to get my data in manageable format. I extracted the data, and organized it in such a way as to make it useable. I used this data to create what is know as an ‘adjacency list’. This special type of list contains information about the entire network using a Hash Map. The use of a Hash Map helped in improving the efficiency of the adjacency list as it meant avoiding a full traversal to locate items within it. This aspect was very important.

One key reason for creating the Breadth First Search.

The Breadth First Search algorithm (BFS) is, unlike its counter part Depth First, useful in traversing adjacency lists that do not include any weighted edge data. My data only represented the nodes and not the distance between them.

If I’d had distance data then I would have used Dijkstra’s algorithm or possibly A* to do the traversing.

So I spent some time mulling over just how I was going to get back the shortest path for any two stops. It was hard work and involved several re-writes to get it.

The real breakthrough was in understanding the nature of tree traversal. Although the breadth-first algorithm is designed to traverse a graph of any shape, the resulting path it makes is one involving all sibling nodes on any given level. Therefore I had to track which level the search was at in the tree.




















Knowing this meant I could then retrace the steps from which I had come, because the parent of any node was any node that was exactly one level less than the current. I was then able to create a list of all stations visited (in reverse order). So, finished by flipping those round and the output is there including all stations and lines involved. ☺

Please take a look over the code I wrote to see what you think.


Here's the whole class file with everything including data and simple UI for compilation. Please note the package name as it might cause problems.

Tuesday, 21 December 2010

Print the "99 bottles of beer on a wall" song... in LOLCODE

I came by this (the other day). And I just can't resist putting it on here.

The program is from:

Language LOLCODE

Print the "99 bottles of beer on a wall" song

in lolcode:

BTW LOLCODE version of 99 Bottles of beer
BTW By Mike Gogulski (http://www.gogulski.com/) 13 July 2007
BTW LOLCODE is a programming language by and for lolcats
BTW http://www.lolcode.com/
BTW
BTW Tested with:
BTW sjlol version 1.1 for lolcode 1.0
BTW Win32 binary: http://www.rit.edu/~sjl7678/sjlol.zip
BTW Home: http://lolcode.com/implementations/sjlol
BTW Online interpreter: http://wealhtheow.rh.rit.edu:8080/index
BTW (Doesn't work with comments, so delete all "BTW" lines)
BTW
BTW Save as 99BOTTLZ.LOL, start with "sjlol 99bottlz.lol"
BTW
BTW LOLCATZ CNT SPEL 2 GUD
BTW
HAI
VISIBLE "O HAI! IM IN UR BEERZ!"
I HAS A VAR
LOL VAR R 99
IM IN YR LOOP
VISIBLE VAR!
VISIBLE " BOTTLZ OF BEER N TEH WALL, "!
VISIBLE VAR!
VISIBLE " BOTTLZ OF BEER!"
VISIBLE "TAKE 1 DWN, PAS IT AROUN, "!
NERFZ VAR!!
IZ VAR LIEK 0?
YARLY
VISIBLE "NO MOAR"!
NOWAI
VISIBLE VAR!
KTHX
VISIBLE " BOTTLZ OF BEER N TEH WALL!"
IZ VAR LIEK 0?
GTFO
KTHX
KTHX
VISIBLE "GIEV MOAR PLZ! KTHXBAI!"
KTHXBYE

Friday, 17 December 2010

I'm on a Mac... rap by Lee Hughes

From Lee Hughes:

Shortayyy) Ahh sh*t!
Get your laptops ready, it's about to go down
Everybody on YouTube, watch the f***in screen
But stay on this muthaf***in page
We runnin this - let's go

I'm on a Mac, I'm on a Mac
Everybody look at me
Cause I'm clickin on a Mac
I'm on a Mac, I'm on a Mac
Take a good hard look at the muthaf***in Mac!

I'm on a Mac, muthaf***a, take a look at me,
Straight iPhone'in hard, got the 3G
Bumpin iTunes, CoverFlow to be exact
You can't stop me muthaf***a, cause I'm on a Mac!
Eat a virus bro
I'm on a Mac Pro
We rockin 8 cores hard
Watch the screen go
I got my SuperDrive
And my mighty mice-es
I'm pluggin girls
You at work, pluggin in devices
I'm on a tandem fixie
And a 64-bit
Friends are jealous
Cause Parallels can run their sh*t
But this ain't P.C.,
this is real as it gets
I'm on a Mac, mutherf***er
don't you ever forget!
I'm on a Mac and,
it's runnin fast and,
I bought a neopreen green scuba sleve sham
I'm the king of the Jobs, on a Mac for real
If you're on a PC, then you're not C.E.O.

Get the f*** up, this Mac is real!
F*** a Zune, I'm on a Mac, motherf***a!
F*** right click, multi-touch, motherf***a!
I'm on iChat with my boys, motherf***a!
These turtlenecks ain't cheap, motherf***a!
Hey, y'all, now I'm an Apple whiz
I never need to learn what a driver is
Gonna say goodbye to all viruses
Like a Nano in pink, anything is possible!
Yeah, never thought I'd be on a Mac
It's like a streamlined good-for-you crack
Wozniiiaaaaak, look at me ooohhhh

I'm on a Mac, I'm on a Mac
Take a good hard look at the muthaf***in Mac!