Thursday, 14 October 2010

Tapulla Release on Android Market

After much fun and hard work, I am proud to announce that I have released a game on the Android Market!
It was written using Processing's Android Tool
Tapulla features original chill out music and is ideal for winding down with, when commuting home from work. The children will like it too and you can compete to see who is the overall family champion.
Tapulla only costs 2 pounds and is well worth it! (Well, I would say that wouldn't I :))
More levels free on next update too!
More info on the website

Thursday, 3 June 2010

Processing in Android - Very Desirable

My chunks for the OU book are finally done and I posted the last errata today...phew!
Having chosen Java whenever possible to obtain my degree it was great to learn to use Processing too. It allows me to use Java and make use of all the Processing facilities at the same time.
Any Java programmer would probably be interested in using Android for mobile phones and I have been no exception. I have been hankering after one of these phones for over a year now but they are so pricey! I was absolutely delighted, therefore when my husband got me my HTC Desire! Then when I discovered that Processing have brought out a Beta tool for Android I was literally over the moon.
The tool at the moment has an Android emulator and a Present tool which allows you to attach the phone and see if your prog works correctly. The export facility generates a debug version apk file. This works for emulator and Present mode. To get the sketch to run standalone on your Android phone you just need to sign it with your private key. They are working on the"export application" option so that it produces a release version apk file that is digitally signed.

Chunk 16 on Android Emulator

Tuesday, 5 January 2010

Chunk 55

I will be completing Chunk 55 which explains how polynomials can be used to draw different types of curves in Processing.
The introduction to polynomials has already been written by Barry and I will attempt to carry on from there. This will mean that this chunk will be co-authored by Barry and myself.

Text for Chunk 55 following Barry's introduction.

Each component of a polynomial expression is called a term, and these are usually ordered from the highest exponent to the lowest. Polynomial expressions do not contain negative or fractional exponents. A typical polynomial expression would have an ordered syntax:E.g. 6xcubed+5xsquared+7x-12 (Not sure how superscript is used in blogger)
In this expression the leading term which has the largest exponent is 6xcubed and its degree is 3. ie 6x6x6 meaning 6 to the power of 3.
The leading term has a coefficient of 6, the second term coefficient is 5, the third term has a coefficient of 7 and the final term, which is a constant, doesn't have a coefficient.
Monomial expressions have only one term, binomials have 2 and trinomials 3.
When working with polynomials it is usual to name them for their leading degree (largest exponent) The expression 6xcubed + 5xsquared +7x - 12 would therefore be a 3rd degree polynomial or cubic.
Polynomials of 2 degrees are called quadratics
Polynomials of 3 degrees are called cubics
Polynomials of 4 degrees are called quartics
Polynomials of 5 degrees are called quintics
In Chunk55 we will only be dealing with quadratic and cubic polynomials but it is interesting to see how the degree and coefficient of a polynomial expression affect the curves when plotted on a graph.
Polynomials with an even numbered degree in their leading term, always enter and leave in the same direction. ie up or down. Therefore, quadratic polynomials are always parabolas.
If the coefficient is even, then the curve will enter and leave at the top of the graph and if the coefficient is odd, it will enter and leave at the bottom.
Polynomials with an odd numbered degree in their leading term, however, have curves that start and end in opposite directions. An odd numbered leading degree with a positive coefficient, will have a curve that starts at the bottom and exits at the top, while a negative coefficient, will have its starting curve coming in from the top and exiting at the bottom.
To plot quadratic polynomials, we need to be able to place the x and y coordinates from 0 to the size of the window. We do this by using an offset of half the width/height of the window.
The width of the parabola is shifted right by adding half the width of the window to the x coordinate and this variable has been named xShift.
The height of the parabola is shifted down by subtracting half the height of the window from the y coordinate and this variable has been named yShift. This allows both upfacing and downfacing curves to be displayed to be displayed together in the window.
An example quadratic such as:
y= 6xsquared-7x+10 In Processing is written as:
y= 6* pow(x, 2)-7*x + 10;
We know that the Processing display screen's coordinates start at the upper left corner,
which is the opposite of a Cartesion Grid's layout, therefore we plot x and y with the statement:
point(x+xShift, yShift-y*ratio); In our sketch we want to be able to display positive and negative versions of a quadratic expression at the same time so we must use yShift variable
to place the curves centrally in our display window. The ratio uses our maximum coEfficient to
calculate the spacing for our plots. As our maximum coEfficient is 50 we work out the scale with
the statement:
float ratio = height/(50*pow(loopLimit-1, 2)-50*loopLimit-1 + 100);
The statements: for (int i=-xShift; i<loopLimit; i++){ y = coEfficient* pow(x, 2)-7*x + 1; point(x+xShift, yShift-y*ratio); }
would draw one curve with plots of x and y for our chosen quadratic expression.
In this sketch, we will replace the leading term's coEfficient, with a variable between 2 and 50, in a for next loop. This will give us a graph of nested parabolas with a variable coEfficient.
s the exponent is an even number, we know our curves will all enter and leave in the same direction, also because our equation is quadratic we will have a parabola and because the coEfficient is even its opening will be at the top.

graph of y= coEfficient*xsquared-7x+10
where coEfficient=2 To 50
When we add a plot of a quadratic parabola, with a negative coefficient in its leading term, we end up with this graph:

graph of y= coEfficient*xsquared-7x+10 and
y= -coEfficient*xsquared-7x+10

Code for final quadratic sketch:
/*author: Rosie Wood
January 2010*/
size(400, 400);
float x = 0, y = 0;
int loopLimit = 200;
//shifts curve to the right
int xShift = width/2;
int yShift = height/2;
/*As explained in Greenberg if magic numbers are used, the curves can
be too large for the display window. He used the
polynomial and plugged in the loop limit to get the maximum. This
way if the window size changes, the program should still work.
In this sketch I have tried to get a ratio that will work as long
as the leading term's coEfficient is <=50 the second term coefficient
does not make much difference and can be greater than 100 and still fit in the window. A constant also makes little difference to how well the curve fits in the window
although the beginning and end of the curves could be outwith the
boundaries of the display window*/
float ratio = height/(50*pow(loopLimit-1, 2)-50*loopLimit-1 + 100);
int coEfficient=0;
for (int i=-xShift; i<loopLimit; i++){

x = i;
/*Here the coefficient of the leading term is positive so the parabola
should enter and leave at the top*/

y = coEfficient* pow(x, 2)-7*x + 1;
point(x+xShift, yShift-y*ratio);
/*Here the coefficient of the leading term is negative so the parabola
should enter and leave at the bottom*/

y = -coEfficient* pow(x, 2)-7*x + 1;
point(x+xShift, yShift-y*ratio);

Cubic Polynomials
When graphing polynomials, the maximum number of bumps is equal to the degree of the polynomial-1. i.e. n-1 , where n =the degree of the leading term.
A cubic polynomial has a degree of 3 in its leading term (x*x*x), so it will have at most 2 bumps (inflections/changes of direction).

Cubic Polynomial with a
positive coefficient in it's

leading term.

Cubic Polynomial with a
negative coefficient in it's
leading term.

This sketch shows both types
of polynomials

To be co

Wednesday, 19 August 2009

Unwanted Ads

I dont think Google should be posting advertisements for DVDs and such on my blog. I only signed up for the endangered animal of the day panel and I don't think this has anything to do with DVDs etc!

Also I am fed up of the Flat Belly tip advert that keeps showing up when I'm browsing. Who told them I had a flat belly? Maybe I was only doing research for a friend when I clicked that lose fat advert!

Also the advert that has, "Look how good I look at 'my age'". I dont go online to be subjected to catty comments.:p

Tuesday, 11 August 2009

Fingers Crossed

I'm hoping that Darrel has managed to edit Chunk 16 OK as the last I heard there were some problems....gulp
I do think that a live forum would have made communication easier on the project.
Is it alright to put some of the applets on our own sites?
If we don't include the source code, I think it would help sales of the forthcoming OU Processing book.
I don't know about the rest of you, but I really miss writing for my OU Processing blog...
I've been busy trying to do search optimization on Solundria
I know this is a shameless plug but there's a lot of good content there! Honest...
I used some of my processing programs to generate images for my snap games. I even made a Snappy Easter version with Easter eggs. This involved using 3d spheres with some of the Chunky program's images.
Details are available in this blog somewhere.

Wednesday, 27 May 2009

Chunk 16 - Product Line is an interesting new website and I just had to try its design a product widgets using chunk 16 images. This could be a good way of generating money for the Open University Student Hardship fund.
I intend adding some more products and will perhaps use Chunk 46 images too.
Watch this space for more funky chunky products!

Wednesday, 8 April 2009

Mix Up

We learned in Chunk45 how we can use the mask method to create an image from two other images. Chunk46 images can be used to create a mask. Instead of using one mask we shall explore how we can use a different mask on each image in a folder of generated images.

We need to decide on the file type and the size of the images we would like to make. The size of our window, masks and images must be the same size, although they can be of different file types. We can use any sketch that loops through the draw method. If we examine the code for Chunk16 we can see, that a new image is generated and displayed, at the end of every iteration of draw. We will therefore use Chunk16 as an example. As a new image is displayed at the end of draw it would make sense to place the save statement there. We initialize an integer as a global variable so its value can be referenced outside of draw. We increment the integer by one at the start of draw and at the end of draw we just add a save statement e.g.:
Where name is the name of the file each image will have followed by a sequential number n. We can increase the frame rate and use the exit method to close Chunk16 when it has generated the required amount of images. We would add an if statement to control how many images were generated like so:
Next we perform the same process on the Chunk 46 code to produce the same amount of images, changing the name so the images wont be overwritten when moved.
Next we write a simple sketch to use the Chunk46 images as a mask on the Chunk 16 images. (or vica versa)

Here is the code for the masking program:
int n=0; void setup(){ size(700, 700); frameRate(.2); } void draw(){ n++; if(n>50)n=0; PImage img = loadImage("c"+n+".jpg"); PImage i= loadImage("line"+n+".gif"); //PImage img= loadImage("line20.gif"); image(i, 0, 0, 700, 700); filter(GRAY); loadPixels(); img.mask(pixels); image(img, 0, 0, 700, 700); save("mix"+n+".gif"); }

As you can see it uses the code we have just discussed to save a copy of each masked image. If you add an image to the sketch then save it, a data folder will be created, where we can copy the images in Chunk16 and Chunk 46 to.

The new images will be saved in the new sketch's folder.