Wednesday 3 December 2008

So Simple to Program!



I coded the basic outline of the program for chunk 16. This only took a few hours to write and its amazing the amount of work achieved with very little research.
The code is in a right mess and needs to be commented and edited.
I will need to ensure that it conforms to the 100 lines constraint.
I dont think the comments are included in the line count but I will check.
The application draws a random pattern about every second. Colour, stroke weight and pattern function are completely randomized and this makes the application very interesting to watch. I could end up looking at it for hours!
The code is very simple and I have tried to keep it consistent with what the user will know after reading up to page 192.
I have only used the ellipses and rect functions so far but I may add some triangle and line functions if they are an improvement.
I discovered that the content of the draw function is drawn to the screen when the function has ended and I couldnt find an easy way of drawing a line at a time, that would fit in with the rest of the application.
This is no great disadvantage, as by using a for next loop the program can run many functions before each frame is drawn to the screen.
I couldn't get over how easy it was to put the program up on my web site. The viewers can watch the applet, run the standalone application or download a copy of the standalone, so they can run it totally separate from a browser and offline.
The applet runs with no problems in Internet Explorer but there is a permission problem when using FireFox. I'm not sure if this could be a problem with an absolute URL as it objects to host 'solundrian.com'. I'll try fixing this today...
I think it will be quite easy at some point to adjust the application, allowing the user to save some of their favourite pics so they can be viewed later.
You can see the finished randomizer here.

4 comments:

  1. Too right about firefox, my browser crashed (Firefox 3.04) on Ubuntu 8.10, one the varieties of Linux I run...

    ReplyDelete
  2. Those Ubuntu boys were trying to be too clever by half. Their java plugin is based on a gcj implementation of java. Your applet works fine on Firefox-2.0.0.18 on gentoo linux with Suns plugin. I'll have to try and remember that before posting..

    ReplyDelete
  3. I used to enjoy Linux but I blew up my Linux box when it had a kernel panic attack!
    I reinstalled on another box but it wasnt able to access the network or Internet and I just dont have the time to configure it at the moment.
    I would likely have to spend days googling and it took me ages to download the 6/7 cds for fedora!
    Nice to know the applet can run on some Linux setups anyway!
    Thanks

    ReplyDelete
  4. You mainly only need one cd these days for most varieties linux, as for kernel panic, I've had a few, the thing to do is stay calm. Mostly its what you do after the kernel panic that causes any problem, even overwriting masterboot record can normally be recovered.

    ReplyDelete