Resolved
I had the issue that the XML feed was not changing colour properly. I have been able to deal with this problem by swapping some codes around and using fill(); to help gain two of the colours I wanted. Blue will be used as slow and red is used for fast. I have also moved the raio = raio + (100 - raio)*0.025; from the void update() and have placed it into the if and else if statement.. so if the value is under a certain number, the radius of the moving circles will be smaller and blue if its above a value then it has a high radius and the colour becomes red.
I've been able to get this working and I'm proud of it!
Still can't make a timer though...
Sunday 18 April 2010
It's Complete! But with an error...
The Processing task is complete and it looks brilliant, however theres a problem with the way the xml feeds get sent to me and the way the framerates work. It's basically picking up 30 pieces of information per second from the server because of the 30 frame rate I have in place. This could bring down a server if it wasnt strong enough. So my code is basically asking the server 30 times a second: "Give me data!" This could be a problem.. But I don't know how to sort it out!
Tuesday 13 April 2010
Processing: Development Part 3
Adding the XML feeds
The most awkward task now is to effectively extract data from the Plymouth Universities ARCH-OS system and place it onto each circle to represent visual data using colour as the basis of displaying the results..
I will need to start with importing the xml from the processing libraries along with each XML Element I need to use.
import processing.xml.*;
XMLElement xml;
XMLElement[] title;
XMLElement[] pubDate;
XMLElement[] value;
Each of these elements identify titles, dates and values from the feeds.
In my void setup(){ I have to add code to string the website address and use the getChildren command to extract every piece of data from the server.
For the XML feed I have chosen windspeed. This matches my criteria because of the movement is that of a wind vane spinning. To indicate the windspeed I may choose various colours to represent the speeds.
void setup
String url ="http://x2.i-dat.org/archos/archive.rss?source=bms_.WindSpeed";
XMLElement xml = new XMLElement(this, url);
title = xml.getChildren("channel/item/title");
pubDate = xml.getChildren("channel/item/pubDate");
value = xml.getChildren("channel/item/description");
The code below displays the use of .getContent().charAt(1)) which is used to extract the numerical values needed to represent the data onto my sketch. By using another For Loop, I can simply print the data to the sketch with the help of 'println(a+" "+c)'. So this is extracting the values in a loop and producing them onto the sketch.
void update
for (int j = 0; j < 5; j++){
int a = int(title[j].getContent().charAt(1));
int b = int(pubDate[j].getContent().charAt(1));
int c = int(value[j].getContent().charAt(2));
println(a+" "+c)
Colour Changing
To represent the data onto my circles, I need to create an If/Else statement from the code above. I firstly need to create three new floats in the class Circle area which are:
float greenslow = 255;
float bluemed = 255;
float redfast = 255;
Green is slow, blue is medium and red is fast. These display the speeds of the wind depending on the winds speeds.
The code below shows the last part of the code I have used. The if/else statement is basically saying that if the value of the feed drops below 50, it changes colour to green, if it's above 50 then it will remain red showing that it's fast.
//If/Else statement: Colour changing to display speeds.
if (c <= 50) {
greenslow = 255;
bluemed = 18;
redfast = 0;
}
else if (c > 51) {
greenslow = 0;
bluemed = 0;
redfast = 255;
}
//Fill the greenslow,bluemed and redfast with colour
fill(greenslow,bluemed,redfast);
ellipse(xpos, ypos, diameter, diameter);
}
}
}
This last snippet of code shows that the greenslow, bluemed and redfast has been put into the fill to display the colours and the ellipse uses the xpos, ypos and diameters to basically make the ellipses travel in a circular motion.
The most awkward task now is to effectively extract data from the Plymouth Universities ARCH-OS system and place it onto each circle to represent visual data using colour as the basis of displaying the results..
I will need to start with importing the xml from the processing libraries along with each XML Element I need to use.
import processing.xml.*;
XMLElement xml;
XMLElement[] title;
XMLElement[] pubDate;
XMLElement[] value;
Each of these elements identify titles, dates and values from the feeds.
In my void setup(){ I have to add code to string the website address and use the getChildren command to extract every piece of data from the server.
For the XML feed I have chosen windspeed. This matches my criteria because of the movement is that of a wind vane spinning. To indicate the windspeed I may choose various colours to represent the speeds.
void setup
String url ="http://x2.i-dat.org/archos/archive.rss?source=bms_.WindSpeed";
XMLElement xml = new XMLElement(this, url);
title = xml.getChildren("channel/item/title");
pubDate = xml.getChildren("channel/item/pubDate");
value = xml.getChildren("channel/item/description");
The code below displays the use of .getContent().charAt(1)) which is used to extract the numerical values needed to represent the data onto my sketch. By using another For Loop, I can simply print the data to the sketch with the help of 'println(a+" "+c)'. So this is extracting the values in a loop and producing them onto the sketch.
void update
for (int j = 0; j < 5; j++){
int a = int(title[j].getContent().charAt(1));
int b = int(pubDate[j].getContent().charAt(1));
int c = int(value[j].getContent().charAt(2));
println(a+" "+c)
Colour Changing
To represent the data onto my circles, I need to create an If/Else statement from the code above. I firstly need to create three new floats in the class Circle area which are:
float greenslow = 255;
float bluemed = 255;
float redfast = 255;
Green is slow, blue is medium and red is fast. These display the speeds of the wind depending on the winds speeds.
The code below shows the last part of the code I have used. The if/else statement is basically saying that if the value of the feed drops below 50, it changes colour to green, if it's above 50 then it will remain red showing that it's fast.
//If/Else statement: Colour changing to display speeds.
if (c <= 50) {
greenslow = 255;
bluemed = 18;
redfast = 0;
}
else if (c > 51) {
greenslow = 0;
bluemed = 0;
redfast = 255;
}
//Fill the greenslow,bluemed and redfast with colour
fill(greenslow,bluemed,redfast);
ellipse(xpos, ypos, diameter, diameter);
}
}
}
This last snippet of code shows that the greenslow, bluemed and redfast has been put into the fill to display the colours and the ellipse uses the xpos, ypos and diameters to basically make the ellipses travel in a circular motion.
Processing: Development Part 2
Let the Movement Begin
By learning about the Class construct I have been able to establish blueprints to help build the movement for the circles. The classes instance is called Circle. It will be used to describe the state of behaviour that the objects of the class all share. I have also studied trigonometry and the use of movement using xpos, ypos, speed and distance. These will all be used within a float to then be updated with the circles. Also what is added is angulo which forms as the angle using a random equation of PI times 2 divided by 2, times by two. This will be combined later in the update with raio which will class as the radius of the circle. In the same Class, the speed and diameter is declared through the float as s and d.
Void update is the most important as it constantly changes the angle and movement of the moving circles (ellipses) in the sketch. angluo is more or equal to radians which is speed determined by the speed. raio is subtracted by any number (100 is used for radius here) and is then multiplied by 0.025.
xpos is then calculated through cos which is a trigonomic function (acts as adjacent divided by hypotenuse) which will be equal to angulo which is multiplied by raio and then added by xpos' width divided by 2. (Confusing...)
ypos is calculated through sin which is yet another trigonomic function (acts as opposite divided by hypotenuse) which will be angulo which is multiplied by raio byt added with ypos' height divided by 2. (Confusing again...)
After many days of confusion and almost utter breakdown I managed to produce this pretty cool sketch I needed badly!
The image above displays the movement of each ellipse as they go along the path. They move correctly and in the areas that I wanted. The ellipses move around at various speeds (5 different settings) due to the use of the random number in the For Loop void setup. So this is highly useful for representing the idea of visualising data by creating an animative effect. All I need to do now is add the Xml feed to change the colour of the circles whenever there is a change in data.
I can increase and decrease the circles distance from the center from the 'raio = raio + (100 - raio)*0.025;' by changing the '100' it can produce some interesting displays.
By learning about the Class construct I have been able to establish blueprints to help build the movement for the circles. The classes instance is called Circle. It will be used to describe the state of behaviour that the objects of the class all share. I have also studied trigonometry and the use of movement using xpos, ypos, speed and distance. These will all be used within a float to then be updated with the circles. Also what is added is angulo which forms as the angle using a random equation of PI times 2 divided by 2, times by two. This will be combined later in the update with raio which will class as the radius of the circle. In the same Class, the speed and diameter is declared through the float as s and d.
Void update is the most important as it constantly changes the angle and movement of the moving circles (ellipses) in the sketch. angluo is more or equal to radians which is speed determined by the speed. raio is subtracted by any number (100 is used for radius here) and is then multiplied by 0.025.
xpos is then calculated through cos which is a trigonomic function (acts as adjacent divided by hypotenuse) which will be equal to angulo which is multiplied by raio and then added by xpos' width divided by 2. (Confusing...)
ypos is calculated through sin which is yet another trigonomic function (acts as opposite divided by hypotenuse) which will be angulo which is multiplied by raio byt added with ypos' height divided by 2. (Confusing again...)
After many days of confusion and almost utter breakdown I managed to produce this pretty cool sketch I needed badly!
The image above displays the movement of each ellipse as they go along the path. They move correctly and in the areas that I wanted. The ellipses move around at various speeds (5 different settings) due to the use of the random number in the For Loop void setup. So this is highly useful for representing the idea of visualising data by creating an animative effect. All I need to do now is add the Xml feed to change the colour of the circles whenever there is a change in data.
I can increase and decrease the circles distance from the center from the 'raio = raio + (100 - raio)*0.025;' by changing the '100' it can produce some interesting displays.
Monday 12 April 2010
Processing Development Part 1
Processing Development Part 1
Now I have decided what my plan is going to be like, it is now time to experiment with various codes and see what I can do with them. The rules imply on the basis that a processing sketch must use Animation and an XML RSS feed from Plymouth's ARCH-OS websites. We are not allowed to use interactivity with the sketch so it's only visual-based.
My first stages are to basically produce the circles I need and draw them onto the sketch along with some form of animative movements using trigonometry (which is awkward). The circles can be produced like this:
The code and above displays the foundations of the 'stage' area. Starting at the top, I have created an integer which declares the name num and the number is 10 (this can be changed to any number and this will be for the amount of objects (circles) in the sketch.) It can be any number as long as it's not too big as the amount of processing will cause the computer to crash.
An array is declared to announce the name Circle and circles which are used later as a Class and in For Loops to help duplicate the circles I need.
I have then created a void setup(){ to produce some of the extra features of the sketch such as adding smoothing, establishing the size of the sketch along with adding the frame rate which is set to 30. A for loop begins here which sets up circles I need for the sketch, int i is declared and is used as a new circle to create a Random generation of circles (in this code there is 5 variations of movement for the circles). The size of each circle is set to 15.
I then established a void draw(){ which projects everything onto the sketch. I have currently provided a basic shape such as an ellipse to draw as my boundary. This will be filled to become a dark background. The ellipse and it's fill doesn't need to be there but when the trigonometry it will be needed to check if the moving circles are in the right path. Another For Loop statement is used as an 'Updater' to constantly update the position of the moving circles on the drawed sketch. The circles[i] is used from For Loop in the void setup(){ to produce the sketch.
Now I have decided what my plan is going to be like, it is now time to experiment with various codes and see what I can do with them. The rules imply on the basis that a processing sketch must use Animation and an XML RSS feed from Plymouth's ARCH-OS websites. We are not allowed to use interactivity with the sketch so it's only visual-based.
My first stages are to basically produce the circles I need and draw them onto the sketch along with some form of animative movements using trigonometry (which is awkward). The circles can be produced like this:
The code and above displays the foundations of the 'stage' area. Starting at the top, I have created an integer which declares the name num and the number is 10 (this can be changed to any number and this will be for the amount of objects (circles) in the sketch.) It can be any number as long as it's not too big as the amount of processing will cause the computer to crash.
An array is declared to announce the name Circle and circles which are used later as a Class and in For Loops to help duplicate the circles I need.
I have then created a void setup(){ to produce some of the extra features of the sketch such as adding smoothing, establishing the size of the sketch along with adding the frame rate which is set to 30. A for loop begins here which sets up circles I need for the sketch, int i is declared and is used as a new circle to create a Random generation of circles (in this code there is 5 variations of movement for the circles). The size of each circle is set to 15.
I then established a void draw(){ which projects everything onto the sketch. I have currently provided a basic shape such as an ellipse to draw as my boundary. This will be filled to become a dark background. The ellipse and it's fill doesn't need to be there but when the trigonometry it will be needed to check if the moving circles are in the right path. Another For Loop statement is used as an 'Updater' to constantly update the position of the moving circles on the drawed sketch. The circles[i] is used from For Loop in the void setup(){ to produce the sketch.
Thursday 11 March 2010
Processing
Processing is a computer program that uses Java as the sole purpose of it's language. I have found it more difficult compared to the likes of Actionscript 3.0. It's a very confusing language but has to be studied for a long time in order to understand what it wants and what you want out of it as a final product.
The assignment is to base RSS feeds from an Arch OS system and use them to make a visual representation of what they would look like in Processing. I have drawn up some plans which maybe useful to my designs.
The design that I have come up with is based on simple circles that rotate in either different positions or closeby each other in the same moving path. Each circle will be based on the various data from the feeds and will be different colours depending on how high or low they are.
The assignment is to base RSS feeds from an Arch OS system and use them to make a visual representation of what they would look like in Processing. I have drawn up some plans which maybe useful to my designs.
The design that I have come up with is based on simple circles that rotate in either different positions or closeby each other in the same moving path. Each circle will be based on the various data from the feeds and will be different colours depending on how high or low they are.
Monday 1 February 2010
Final Flash Game Product
Lee Cunnington.co.uk/Fun
Here is the final version of the Flash game which I have created. The current errors which were troubling me have been changed and removed, so it is now a 100% clean working Flash Game.
http://www.leecunnington.co.uk/Fun
Here is the final version of the Flash game which I have created. The current errors which were troubling me have been changed and removed, so it is now a 100% clean working Flash Game.
http://www.leecunnington.co.uk/Fun
Subscribe to:
Posts (Atom)