Wednesday, June 25, 2014

While planning a sunny day trip to Wiltshire it occurred to me that I had some 1970s colour slide photographs of the Caen Lock flight at Devizes. The lock flight is a remarkable set of sixteen locks that let canal boats climb a Caen Hill and reach the town of Devizes. I got Tammy to print out the pictures so that we could do a "then and now" set. Peter Coleman (Stonehouse Wheelers member 2) took the 1970s images and Tammy took all the new photographs last Tuesday afternoon. These images are straight from Tammy's Sony RX100 MkII. Peter's slide numbering indicates that the date of the images is approximately mid nineteen seventies. There does appear to be some water in the canal but also a lot of weeds. There were no lock gates or bridges, not even derelict bits of them. From archive accounts it appears that all of these old structures were removed by fishermen and replaced by dams to maintain the fishes.

The first image is lock 42 near the top of the flight. The bottom of the lock was wet and without much weeds. The top layer of bricks are white faced. This lock was identified by the top paving layer. It gets thicker towards the gate, presumably to compensate for the bricks not being laid quite level.
Not clickable (yet)
Lock 42 in working order but the bricks look rather dull. There is a new ladder on the path side. There were no ladders on the path side of the canal so this looks like a modern addition. It is also full of water because a boat has recently passed on the way up. A plaque says that this lock is called "Monument", in honour of the Monument Trust.
Further down is lock 39 and this can be identified by the markings on the stones around the gate. The distant trees are apparently elms so this dates the photograph. Dutch elm disease destroyed these trees around 1975.

Lock 39 as it is today. Out of shot is a plaque to the Scaggs Foundation.
YYYYY
Looking back up the lock flight.  Weeds had taken over. Now it is looking well maintained and smart and indeed a popular day out with a cafĂ© visible just to the left at the start of the flight.
Looking up the flight


Lock flight under weedsWithout gates and bridges you could see straight up the flight. If you click on the old image to make it bigger you should be able to see the fishermen's dams at each level.ABCDEFG.


From lock 28
From lock 28 there was no water to be seen, just weeds. Now fully operating and some boats moored. These boats were not heading anywhere as they had just lit their barbecues.
From lock 28

Tuesday, December 10, 2013


This entry is about writing an app for Android using App Inventor 2. It is a tutorial for making a clock app for Android. Making apps is a lot easier than it used to be and App Inventor is particularly easy to use.

Getting Started

The tutorial assumes that you are familiar with App Inventor and that you can use the Component Designer to lay out a screen, and the Blocks Editor to specify the behaviour of the app. If not then head on over to the MIT App Inventor site and click on Getting Started. This will take you through the installation and a few tutorials. You'll need to have done at least one introductory tutorial to make sure that everything works and that you have mastered the basics.

If you want to make your own clock hands you will need to know how to create images with transparency. Paint.NET can make PNG files with transparency. Don't worry if this sounds a bit tricky, You can use some of my hands instead.

So now you've got your system set up you can start on this tutorial.

Clock Tutorial

This tutorial demonstrates how sprites can be used to animate the hands of a clock. You can build a clock with any face and hands that you design or choose.

The end result will be a simple clock that has moving hours, minutes and seconds.

This tutorial covers:
Using the sprite component on a canvas including the position, scaling and rotation properties.
Using the clock component to tick seconds and drive the hands.
Scaling the app. to suit the screen size. 
Using the screen orientation property to rescale the app. when the screen is turned.

Part 1 - Start a new project and add the components

We'll build this app in stages doing a little bit at a time. Log into App Inventor and start a new project. Name it "Clock". When the Design window opens notice that App Inventor automatically names the screen "Screen1", but you can set the Title of the screen, which will show up in the top bar of the app. Think of a title for your clock, or feel free to use the suggested title "Clock", and type it into the Properties pane on the right side of the Designer. In the Screen Properties (shown in right-hand pane): Uncheck the checkbox labeled "Scrollable" so that the screen will not scroll when the app is running. Screens that are set to scroll do not have a height. We’ll need our clock to have a defined height in order to scale it properly. The hands must be created in a paint program like Paint.NET. The hands will be loaded as sprites. Sprites rotate about their centre but clock hands rotate about one end. You can change the centre of rotation by working out the x/y offsets but this is tedious arithmetic. Instead if you make the hands the full height of the clock it will rotate about the correct axis. But you don't want the clock to have propellers for hands. The trick is to make the bits that you don't want transparent. How to make the hands in a paint program. Make a thin vertical rectangle the height of the clock face. This same rectangle will be used for all of the hands so make it wide enough. Make the whole rectangle transparent and draw the hand on it. Here are three hands that were used. The transparent area is painted in red so that you can see it. The hour hand is short and fat, the minute hand is long and thin. The second is long and thinner. Each hand has a small black edge to lift the hand from the background. They all rotate about their centre.  
Add these components and name them
Drawing and Animation -> Canvas
>

The clock will have a background image for the clockface. Draw your own or Google "clock face" to pick something suitable, A suitable clock face will be square with a size of  over 500 pixels or a high enough resolution to suit your phone. Upload this Media asset and make it the screen background. You'll see the clockface get stretched but you will fix that later. The clockface that I used had a black background so I set the screen background color to black to match.

Set the background image of the Canvas to the clock face.
And in the canvas add the hands
Drawing and Animation -> ImageSprite -> hour.png -> hourSprite
Drawing and Animation -> ImageSprite -> minute.png -> minuteSprite
Drawing and Animation -> ImageSprite -> second.png -> secondSprite
User Interface -> Clock -> -> Clock1
Don't worry about the scaling and where the hands are positioned, this is fixed later on.
This completes the component layout.

Part 2 - Adding the behaviours

To make something happen right away, switch to the block editor and lets put in the clock event. The angle of the hands is controlled by the heading property.
This creates a local variable which is the current time. We only read this once so that each update will use this time value throughout. A second hand ticks 6 degrees every second so we multiply the seconds by 6. But it is -6 because the clock rotates, well clockwise. If you run this the second hand will animate, but it will be in completely the wrong place.
Now we can add the other hands. Unlike the second hand they move smoothly and not in discrete steps. This means that we need to calculate the angle for a particular time. The calculations are a bit more complicated. For the minutes the hand moves 6 degrees per step and the hour hand is 30 degrees. The final calculation is shown here.
Now the hands are moving and pointing in the correct direction, But they are still randomly positioned. Note that I have coloured the transparent parts of the hands red so that you can so how it is working. Normally the red bits are erased. The background is also stretched to fill the screen. Lets fix that next.

Part 3 - Scaling the canvas

The clock background is square so we need to make the height the same as the width.To do this try making this fragment:
Test it out by right clicking on it and selecting Do It. The clock face will magically be scaled correctly. Now turn your phone sideways and select Do It again. The clock face will become too big so we need a more elaborate scaling routine. 
We add a test to check which is shorter, the width or the height and set the canvas dimensions to that value. Then we bundle this up into a procedure called scale. To set up the correct scale we add it to the screen initialise event. We also call it when the screen is rotated so that it always fits the available space.

Part 4 - Scaling and positioning the hands

We need to move the hands to the centre of the clock face. Another way to look at it is the coordinate will be half of the width of the clock face.
Just extend the scale procedure so it uses the width value that we found to set the height of the hands. Then we divide the width by two and use that to set the X and Y of each hand. Note that due to the width of the hands (23) we need an x offset of -12 to move the hands exactly to the centre. The final code will look like this:

Now the clock is working what else could you do with it? A cartoon character with pointing hands like the Mickey Mouse watch. An elaborately decorated face with intricate hands. A clock that changes faces during the day. A clock that has a sunrise and sunset dial. A clock with a moon phase display. Translucent hands are also possible if you know how to control transparency in PNGs. My clock does something especially useless. The hands fall loose when you shake the phone.

Source files for the project are in this archive




Saturday, April 21, 2012

Westbury Court Gardens

Westbury Court Gardens fell into disrepair and by the 1960s were in a very poor state. Saved by the National Trust too late to save the big house but the gardens and the tall pavilion could be restored. This is what it looked like some time in the early 1970s. There were a couple of tall (poplar?) trees at the back and the yew hedges had just been planted.
From G1681
And this is what it looked like on the in April 2012. The huge tulip tree and the holm oak still looking much the same but the tall trees are gone. If you come back in ten years time the fear is that global warming will have acted to kill the yews. They are already being replaced by other hedging plants.
From 2012-04-21

Tuesday, April 10, 2012

Tewkesbury 50 Years Ago

Peter Coleman's randonnées often took him and his camera to Tewkesbury. I have mainly located his pictures using Google Earth but today I decided that it was time to do a then and now on them. Old buildings in the high street are mostly unchanged because since the 1960s most of these have been preserved. First is Out of the Hat, 100 Church Street, Tewkesbury. I've no idea what it used to be.
From Box-G4
Since the 2007 flood it has been restored as a tourist information centre. The optician on the left is now an employment agency.
From 2012-04-10 Tewkesbury
Round the corner is The Cross House and in front is Milward and Sons.
From Box-G4
The shop with the big clock which was Milwards is now Design for Flowers. The clock still seems to be operating but the shop was closed for Easter.
From 2012-04-10 Tewkesbury
The alley between Cross House and Design for Flowers.
From Box-G4
The alleyway hasn't changed much.
From 2012-04-10 Tewkesbury
Number 9 is Key House. It is also known as Nodding Gables due to a fault in the roof. It is home to the Halifax Bank but it used to be full of paint when it was a hardware shop called Mills and Carter. There are several years between the first two images. The key faces inwards in the first. The key faces out some years later and the AA sign has been modernised.
From Box-G4
From G1601
The key reverts to facing inwards. The Swan Hotel and its AA rating sign have been replaced by Superdrug. Well where would you park the car these days?
From 2012-04-10 Tewkesbury
At the north end of the High Street we get to Ye Olde Black Bear. It is gleaming an impossible white. This is due to being scanned with a rather shoddy Veho scanner and I haven't redone it yet. The Riverside Restaurant seems to have morphed into the Riverside Nightclub. The big sign now only says "Rest urants"
From Box-G6
When I took the picture a Triumph Herald NNK 224H with a friendly smiling driver came round the corner giving the picture a period feel.
From 2012-04-10 Tewkesbury
Lastly is Abbey Row Cottages. Time really has stood still. The only change here is that the three benches at the end of the terrace has been replaced by a single bench.
From Box-G6
From 2012-04-10 Tewkesbury

Friday, March 9, 2012

~ATH ROAD

Found on Google Earth:
~ATH(THIS) {
   Cats
} EXECUTE(NULL);
THIS.DIE();

Friday, February 10, 2012

Winter ride to the river

After a week of hard frost -10C (or 14F in old money) and heavy snow, the Wheelers didn't want to tackle the icy slopes of the high ground. Instead the ride got routed through to Arlingham which is a flat and low journey down to the river. The remaining snow was melting fast. At Frocester we saw several buzzards in the trees overhanging the road. They weren't bothered by cyclists at all. Near Eastington we saw a group of donkeys in a snowy field with people passing them carrots over the fence.
At Rasher Farm there was a herd of llamas.
From 2012-02-05

The snow from the day before had a victim in a ditch. A blue car had mysteriously gone badly out of control on a flat and straight section of road and got wedged into the ditch. This is a new meaning for "Car Down".
From 2012-02-05

Saturday, February 4, 2012

BRAG Bikefest 2011 Part 4

DAY THREE


Sunday morning up with the lark. I packed all my belongings into the car and set out my wash things and a change of clothes ready in order to make a quick exit when I got back. I downloaded another Archers and settled into the car with my Brazilian Roast. Went back for a refill and by this time the jug contained Peruvian coffee. Tasted the same to me. Waited until the clock hit 7.30am and I hit the chill morning air on the trail. Susan was already up and wished me a good ride. My hosts from the night before were packing up and just waiting until the morning sun burned the dew off the tent.

I set off at rogue’s pace enjoying the chilly morning.
https://picasaweb.google.com/lh/photo/sAyQwQu0lZY_oMKNneKMP9MTjNZETYmyPJy0liipFm0?feat=directlink
I tracked a couple going fast on really fancy bikes. I stopped occasionally to take a picture and then carried on catching up with them.
From BRAG Bikefest 2011 Columbus

From BRAG Bikefest 2011 Columbus

I got to the first rest stop in no time. Not having had breakfast I devoured a PB&J and a banana and carried on this time following the fast couple. They both had Corima four spoke rear wheels and a fancy bike to match. Even one Corima wheel would cost more than five times that of my Walmart road bike. We picked our way through the massive military base, Fort Benning and stopped often to check the route. No pictures on base. I didn't want to get arrested as a spy! Soon we got onto the airfield and picked up lots of speed on the level perimeter road, keeping a steady 22 MPH for a few miles. I was quite enjoying this burst of speed but when we slowed down it was apparent that the woman wasn’t so happy and wobbled quite a bit until she got her composure back. I think I may have been pushing them a bit too hard on my bike-shaped-object.

We went through the checkpoint and gingerly picked our way across the bridge expansion joints, which could easily swallow my 32 mm tyres let alone their 22mm. The next rest stop was at a recreation park connected to the military base. We were the first riders that day to reach it. I had some more breakfast and then visited the loo. When I got out, the couple had already departed. I raced out and saw them in the distance. I almost caught up with them when we crossed the bridge again.
From BRAG Bikefest 2011 Columbus

I realised that the mats there had been placed by the organisers to cover the expansion joint but that these had been displaced by cars. I pulled them back into place. The other couple were far in the distance but after a mile I was back up with them. We worked our way up around the far side of the airfield and along the scenic Dixie Road. Then we got to a junction where the route warned of construction. It turned out that this construction was road resurfacing and the construction gang had obliterated all of the route markings. Needless to say, people got lost. I saw a family sailing on towards Highway 182. I passed the couple who were pondering which way to go. It was obviously the wrong way but soon I found Edwards St and I was at the end of it instead of half way along so I could pick up the correct trail. Getting back to the riverwalk I found outbound people getting lost and to make it worse I think I sent them the wrong way as the Lumpkin Rd crossing looks very much like 10th Division Rd. At least I wasn’t lost any more and I motored the last eight miles back to HQ, the first bike back. I never saw the couple again and they may still be circling Fort Benning looking for the route mark. So I told the organisers about the pitfalls I found on the way and saw the BRAG hats. I reckoned that there was enough money to buy fuel for the return drive so I got a $10 hat.
From BRAG Bikefest 2011 Columbus

I rushed into the shower, jumped in the car and once I hit the highway it was non stop 55mph cruise control for the next 100 miles to catch to the tail end of the Sunday family gathering that Tammy had organised.