Anxious Silence

Spring Darkness

Posted April 29th, 2010 19:36 by Bob

Quick photo catchup. Accidentally have a mix of slightly dark/gothic looking pics and assorted spring pics (not really a surprise). We took a trip to West Wycombe with Emily and Katie during which everything seemed to be unnecessarily expensive, £5 each to walk round the park, £5 each to go in the caves (we didn’t bother), couple of quid each to climb the church tower (we didn’t bother).

Recent favourites:

DSC_6485Noisy Tits in the garden

DSC_6451House by All Saints Cemetery in Maidenhead. Up for sale, very tempting.

DSC_6622Somewhere in Shiplake

DSC_6464In the woods…

DSC_6500Karen, Emily and Katie posing for their Indie-rock album cover (by the Temple of Venus in West Wycombe park)

DSC_6583

DSC_6599

DSC_6627


HTML 5 Graph Slider

Posted April 27th, 2010 23:17 by Bob

HTML5 Graph Slider_1272407446781

Been having a play with HTML5, very excited by the new semantics and especially keen on the new canvas tag. Aware that it’s not going to be supported everywhere in the immediate future but it’s a great step in the right direction. I don’t think it’s going to be the immediate flash killer some have made it out to be anytime soon (I love flash and AS and have no desire to see them go), but it can certainly work as a good alternative to flash for simple animation and interactivity. Once the decent JS frameworks add more functionality to support it it’s going to make life a lot more interesting.

I’ve put together a couple of experimental demos with HTML5 this week, this is the first. It’s a dynamic graph viewer. It can accept data via javascript and update the graphs on the fly. The data in question in the demo is supplied by the sliders but it can come from anywhere you like. I’ve kept the graphics basic for the sake of the demo.

View Demo.

I’ve not written any sort of tutorial/code article before, so bear with me, feel free to just download the source.

I’ve used jQuery and jQuery UI in the name of agile development. The jQuery ui for the sliders and a couple of jQuery statements to get measurements and deal with events, these could be easily swapped out for alternative frameworks or more verbose standard javascript.

The HTML

View the source of the demo for the full HTML, I’ll just include the pertinent parts here:

  1. <div id="Graphs">
  2.         <canvas width="200" height="150" id="Graph1"></canvas>
  3.         <canvas width="200" height="150" id="Graph2"></canvas>
  4. </div>
  5. <div id="Controls">
  6.         <div id="Slider1"></div>
  7.         <div id="Slider2"></div>
  8.         <div id="Slider3"></div>
  9.         <div id="Slider4"></div>
  10. </div>

This sets up two canvases, one for each graph, I’ve named them the imaginative ‘Graph1′ and ‘Graph2′. The controls div contains four divs to be converted to jQuery UI sliders (one for each point / bar on the graphs).

The Javascript

First off we set up a couple of global variables:

  1. var graphPadding = 10;
  2. var colours = new Array("rgb(200,0,0)","rgb(0,200,0)","rgb(0,0,200)","rgb(0,200,200)");

graphPadding is just a number to use for spacing items of the graphs out. I’ve just set a single number to use for all margins, spacing, etc to keep things simple. colours is an array of colour codes, one for each of the graph points.

Next we initialise with the nice jQuery document.ready function:

  1. jQuery(document).ready(function($){
  2.  
  3.         /* Generate Nice jQuery UI Sliders */
  4.         $(‘#Slider1, #Slider2, #Slider3, #Slider4′).slider({
  5.                 slide: function(event,ui){drawGraphs();}
  6.         });
  7.  
  8.         /* Set some random initial values for the sliders */
  9.         $(‘#Slider1, #Slider2, #Slider3, #Slider4′).each(
  10.                 function(){
  11.                         $(this).slider(‘value’,Math.random() * 100);
  12.                 }
  13.         );
  14.  
  15.         drawGraphs();
  16.  
  17. });

The first command sets up the jQuery UI sliders including giving them the appropriate event handler to redraw the graph whenever any of them are changed. The second command just sets each slider to a random value. Next we call drawGraphs to draw their initial state.

Now we have the main graph drawing function, this is set up to draw both graphs in one go.

  1. function drawGraphs(){
  2.         /* Get the canvas dimensions, we know they are both the same so we shall be lazy and only check once */
  3.         var cHeight = parseInt($(‘#Graph1′).height());
  4.         var cWidth = parseInt($(‘#Graph1′).width());
  5.  
  6.         /* Clear the Canvases */
  7.         clearCanvas($(‘#Graph1′));
  8.         clearCanvas($(‘#Graph2′));

First we get the canvas dimensions, these could be stored as constants/globals somewhere or hard coded but I like the flexibility of checking on the fly. Really we should check each one individually and split the graph drawing into two functions but it’s a demo and I don’t care. Then we clear each canvas to start drawing on it using a function which will be defined below.

  1. /* Graph 1  - The line graph */
  2.         // Get Context
  3.         var canvas = document.getElementById("Graph1");
  4.         var ctx = canvas.getContext("2d");
  5.  
  6.         // Set Stroke Style
  7.         ctx.strokeStyle = "rgb(0,0,0)";

Prepare to draw the first graph by getting a reference to the appropriate canvas then calling getContext on it. Then we set the stroke style to black.

  1. // Draw Axis
  2.         ctx.beginPath();
  3.         ctx.moveTo(graphPadding, graphPadding);
  4.         ctx.lineTo(graphPadding,cHeight - graphPadding);
  5.         ctx.lineTo(cWidth - graphPadding, cHeight - graphPadding);
  6.         ctx.stroke();
  7.         ctx.closePath();

Draw the axis, a simple case of drawing two straight lines. We use a combination of the canvas dimensions and the graphPadding global to work out the positions.

  1. // Display a point for each slider, spaced equally
  2.         var availableSpace = cWidth - (graphPadding * 4);
  3.         var horizSpace = availableSpace / 3;
  4.         var vertSpace = cHeight - (graphPadding * 4);

Work out how much space we actually have to draw the points in. The first point is two sets of graphPadding from the left and the last is two from the right hence the * 4. Same applies vertically.

  1. // Create an array of y points
  2.         var points = new Array();
  3.         for(var i = 0;i < 4;i++){
  4.                 // Get Ypos
  5.                 var yPercent  = ($(‘#Slider’ + (i + 1)).slider(‘value’) - 100) * -1;
  6.                 var yPos = (vertSpace * (yPercent / 100) + (graphPadding * 2));
  7.                 points.push(yPos);
  8.         }

The points will be equally spaced horizontally so we just need to get their vertical position. Loop through the sliders, get the value for each one (0 – 100), work out the percentage of the available vertical space and add it to the points array.

  1. // Draw Lines
  2.         var xPos = graphPadding * 2;
  3.         ctx.beginPath();
  4.         for(i = 0;i < 4;i++){
  5.                 if(i == 0){
  6.                         ctx.moveTo(xPos, points[i]);
  7.                 }else{
  8.                         ctx.lineTo(xPos, points[i]);
  9.                 }
  10.                 xPos += horizSpace;
  11.         }
  12.         ctx.stroke();
  13.         ctx.closePath();

Draw the graph lines. We separate the line drawing and point drawing as when we draw a circle it calls closePath which knackers up our lines (there’s probably a better way). To draw the lines we loop through the points and draw a line between each one.

  1. // Draw Dots
  2.         var xPos = graphPadding * 2;
  3.         for(i = 0;i < 4;i++){
  4.                 drawCircle(ctx, xPos, points[i], 4, colours[i]);
  5.                 xPos += horizSpace;
  6.         }

To draw the points we just loop through the points array again, drawing a circle at each one, again the horizontal position of each point is fixed.

I’ll cut out most of the code for Graph 2 as it’s identical. The part of interest is:

  1. // Work out width of each bar
  2.         var availableWidth = cWidth - (graphPadding * 6);
  3.         var barWidth = availableWidth / 4;
  4.         var maxHeight = cHeight - (graphPadding * 3);
  5.  
  6.         // Draw bars
  7.         var xPos = graphPadding * 2;
  8.         for(i = 0;i < 4;i++){
  9.                 // Work out height
  10.                 var h = maxHeight * ($(‘#Slider’ + (i + 1)).slider(‘value’) / 100);
  11.                 var yPos = cHeight - h - (graphPadding * 2);
  12.                 ctx.fillStyle = colours[i];
  13.                 ctx.fillRect(xPos, yPos, barWidth, h);
  14.  
  15.                 xPos += barWidth + graphPadding;
  16.  
  17.         }

Here we work out the available space for the bars by subtracting the appropriate number of graphPaddings from the total available space then dividing the result by the number of bars. We work out the max height of each bar by deleting 4 * graphPadding from the total available height.

Then we loop through the sliders, get the percentage value from each one and set it’s bar to the given percentage of the total height.

That’s pretty much it. I’ve used two additional helper functions which are based on those found at the Mozilla Canvas tutorial, they shouldn’t need any explanation:

  1. /**
  2.  * clearCanvas
  3.  * Clears a canvas, by setting it’s width.
  4.  */
  5. function clearCanvas(element){
  6.         $(element).attr(‘width’,$(element).attr(‘width’));
  7. }
  8.  
  9. /**
  10.  * drawCircle
  11.  * Draws a circle
  12.  */
  13. function drawCircle(ctx, x, y, radius, colour){
  14.         ctx.fillStyle = colour;
  15.         ctx.beginPath();
  16.     ctx.arc(x, y, radius,0,Math.PI*2,true); // Outer circle
  17.     ctx.fill();
  18.  
  19. }

So, there you go. Dynamic graphs without flash or server side graphics libraries. These could of course be achieved pretty much entirely with CSS and JS but it’s been a nice intro to HTML5 and the canvas tag.

I’ve not given this a huge amount of testing (or thought) as really for my own entertainment but hope it’s of interest.


Grumpy Developers (it’s all just work isn’t it?)

Posted April 25th, 2010 11:20 by Bob

I’ve always assumed I’m the most difficult, argumentative developer/designer in the country. Apparently not, there are far worse and they’re everywhere. A couple of longstanding clients have recently commented on how comparatively easy I am to work with, specifically my degree of tact when dealing with difficult projects. I am not being ironic.

I bitch and moan constantly about some of the work I have to do, friends, relatives and the less knowledgeable project managers look at me like I’m mental and trot out the traditional line “well, it’s all paid work isn’t it?”. Here’s the problem, it’s not about whether it’s paid work or not. Anyone who has entered a creative industry through choice generally has an expectation of the quality of work they will be doing, an expectation of job satisfaction. Sounds pompous, probably is, but that’s the reality. Often I can deal with crappy deadlines and budgets better than bad design and implementation decisions, I don’t expect to have much say on budget or timeline (for agency run jobs), but I’d like to at least have my opinion heard when a client makes a stupid decision which may damage the final quality or outcome of a project.

From a personal perspective, here’s why your developer/designer may be getting the arse with you for what you perceive to be completely reasonable requests:

The constant redo
Asking them to redo the same piece of work over and again because the client can’t quite decide if it should have the blue border or the green border? The repetition can make me very stabby indeed. There’s the next part of the project to move onto and I’ve just wasted a day shifting the same pixels back and forth (or worse a week), and really I already know which is the best decision and have probably yelled it down the phone a couple of times.

The Neverending Project
Mmmm… scope creep the bane of my existence.  Several things here, firstly project fatigue, after a while of staring at the same project you just can’t face it any longer, you need to switch to something else for a while. Adding just another page/button/function may seem trivial but even that ten minute task can make you lose the will to live. Secondly, on a more pragmatic level we’ve probably got something else lined up to be getting on with and if the scope creep has pushed us past deadline there’s someone else on our case about starting their project. Finally, and most importantly, an awful lot of scope creep includes totally unnecessary and pointless additions which I feel (sometimes incorrectly) will have a negative impact on the final outcome, I don’t want to release something crappy and bloated if it can be avoided.

You’re wrong, wrong wrong
Faced with a decision that’s clearly bollocks by a client or project manager I have two options. I can shut up, carry out the bad instruction and take the cash or I can explain why it’s clearly bollocks. The latter has a tendency to go down like I’ve just murdered someone’s granny. Some idiot somewhere has made the clearly bollocks decision and may well be very proud of it (recently: “I’ve used MS Paint to adjust our website layout, can you please implement this”) so there’s a high chance they are going to get offended when you tell them as much, the project manager doesn’t want to pass this message on and so pushes for the clearly bollocks decision to be implemented regardless of how wacky it is, I dig my heels in and explain repeatedly how clearly bollocks it is. No-one is happy. Don’t let the client get involved in the creative process, they’ll only arse it up and piss of those who are being paid to design.

I want to do it properly
Especially with a big project, I might be putting months of my life into a website. I don’t want the end result to be a bucket of sick. It’s partly the portfolio argument, in that I want to be able to proudly display every site I do in my portfolio to try and garner new work, but in reality I never update my portfolio (so rarely I’m not even going to link to it). More seriously, it’s pride in my work, I know that if I release anything that’s got even the slightest issue that’s will be the only thing I will notice when I look at it again, I’ll never be able to show someone the website without apologising in advance for the strange way the menu works or the odd clash of colours in the footer.

There’s plenty more that gets on my tits on a daily basis but it’s nice outside and I don’t want to stare at a screen all weekend. Generalising horribly, if your developer or designer doesn’t get the nark on with you from time to time, they probably don’t give a crap about their work and could work a little harder at it (or they are bottling it up and will one day come at you with a sharp pencil).


Photo Catchup

Posted April 11th, 2010 20:45 by Bob

In lieu of actually writing anything, here’s a quick roundup of recent(ish) photos…

Knowl Hill in the Snow:

Braving the wastelands of Knowl Hill in the snow:

DSC_6318Katie – Rescuer of abandoned Christmas Ornaments

DSC_6196_1 DSC_6209 DSC_6244

DSC_6312Ed’s favourite ride

Full set of Knowl Hill Snow expedition photos.

Avebury:

Quick visit to Avebury for lunch with Dad and Jan.

DSC_6393_1 DSC_6402 DSC_6405

DSC_6363

Full set of Avebury photos.

DSC_6145Wargrave Commission, Maidenhead in the Snow

More shots of Maidenhead in the snow.


Books of joy #2 – Typaedia

Posted April 9th, 2010 00:05 by Bob

Hush now Daily Mail readers, Typaedia has nothing to do with children. I love this book, mostly for nostalgic reasons but also for the little bit of history as well.

The Typaedia is exactly what it looks like, a great big book of index numbered typefaces which you could leaf through to order sheets of letraset-type font sheets to create layouts, negatives and all the other stuff a working print-shop may use typefaces for. There’s an introduction page:

Introducing Conways’ Typaedia*
Conway’s Typaedia is a unique collection of some 4000 display faces.
Each is shown in its entirety, with caps, lower case, variants, punctuation and signs, arranged alphabetically in two separate sections, and all available at Conways’ as headline photosetting.
The first section shows the bulk of the faces – 3300 in alphabetical order with the second section showing 700 faces in the Agency series.
There is an Introduction to each section, a Latest additions section and a comprehensive Index.
The first section of 3300 faces is enclosed along with with the full Index.
The Agency section together with the introductions and the Latest additions, all at present at the printers, will be delivered to you early 1980.
Altogether…a unique work of reference
* Typaedia,-paedia (Latin,fem), a doctrine or learning.

From there we just dive into pages and pages of fonts, no other explanation needed. It’s a lovely catalogue, nicely spaced with no unnecessary crap, no explanations, no sales pitch it assumes the reader knows it’s purpose and doesn’t need to patronise or hard sell at them. Lessons on simplicity could be learned from here (mostly by me).

It’s a great reminder of how stupidly easy it is for us these days even in comparison to 30 years ago. When we need a new typeface we can purchase it and be using it within a couple of minutes, back then you had to go collect them or wait for an order to turn up. Every character you used had a cost, if you knackered up your design there was no undo, it was back to the supplier to get another sheet. And most importantly you had to keep your stash of lettering safe from your 8 year old who found the whole concept fascinating and would happily apply your lettering to any surface given half a chance.

My Dad gave me this book recently, which was really cool. For most of my childhood he ran a print shop (and still does), and I have some really happy memories of laying into his assorted work materials and making crap with them. I have especially fond memories of letraset and some really sharp memories of sitting on the floor rubbing the letters onto whatever materials happened to be around. Not with any real creative intent, I just found the whole process amazing, it held an almost bubble-wrap type fascination. The Typaedia was never that far from hand.

The book itself is well used, covered with splatters of ink, random bookmarks, biro scribbles and the other assorted grunge of a workshop. It’s almost comforting to have on my bookshelf. I’m slightly annoyed that I forgot to photograph the back cover which has one of Dad’s promotional stickers on it as drawn by a local illustrator (Peter Classey), as they also form a strong part of my early memories.

Thanks Dad.

Full set of Typaedia photos on Flickr.

DSC_5945

DSC_5946 DSC_5955 DSC_5958

DSC_5968

DSC_5982 DSC_5986 DSC_5997

DSC_6004


A dance as old as time

Posted April 7th, 2010 10:11 by Bob

A beautiful dance, reflecting the struggles of mankind in an act as simple as sending a mass-email.

We meet once a week
I’m emailed that week’s marketing email.

and we talk of what’s to come…
I insist we put a delay on the delivery so they can properly proof read it, fair chance no-one has yet, they insist it’s MEGAURGENT and must be sent IMMEDIATELY, NO DELAY!!!

We take our first steps…
I correct the horrific spelling errors and lightly proofread the mailout. I would proof-read it more thoroughly but hard to do so when being constantly questioned IS IT DONE YET IS IT DONE YET IS IT DONE YET?

The dance proper begins…
I queue the mailout up to be sent in an hour and send them test copies. They say URGENT SEND NOW NO DELAY!!11!! I insist they read the test copies and check them. They say URGENT SEND NOW NO DELAY!!11!! (for even a 20 minute delay will weaken their marketing message until it is nothing but a fine morning mist dissipating in the sun. I pretend I have gone deaf and leave the delay on.

We conclude our dance for this time.
Two minutes before the mailout is queued to go I’m contacted with MEGAURGENT FIX IT FIX IT FIX IT!!111!! For why? Because there were some glaring inaccuracies and the name of the MD was spelled wrong (again).

And onto the next time, when it will be as though we haven’t already done this a thousand times before. Each time fresh, the same steps, although with slightly different timing.