An Analog Vector Graphics Clock Using MyXaml and VG.net

An analog clock created with VG.net

The latest VG.net beta release includes a MyXaml serializer, allowing you to save VG.net Pictures as xml files. Marc Clifton has written an article on CodeProject describing how we created an analog clock using the VG.net designer and a few lines of code for animation.

Download the MyXaml clock sample.

We first created the clock was as a standard VG.net application. We set the new MyXamlExport property to true in the designer, causing the designer to save a copy of the Clock Picture as a .myxaml file every time you click “Save.” Then we copied the animation code to the .myxaml file, to make it self-contained. You can also put dynamically compiled animation code in a separate code-behind file.

Here is another Picture included in the MyXaml sample (not animated yet):

An robot arm created with VG.net

At some point, we will make an animated robot arm.

Here is a small "LED bar" created in the VG.net designer: An LED bar created with VG.net

Here is the MyXaml output for the image above. It is straightforward and easy to read. Each Ellipse has a separate Fill, so they can be independently animated:

<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!--Generated by the VG.net designer at 4/13/2004 5:54:50 PM-->
<MyXaml xmlns:def="Definition"

xmlns="Prodige.Drawing, Prodige.Drawing"
xmlns:pds="Prodige.Drawing.Styles, Prodige.Drawing">
<Picture Name="LedBar">
<Elements>
<Rectangle Name="bar" Location="0, 0" Size="120, 30" CornerRadius="20" StyleReference="Bar"

DrawAction="Fill" />
<Ellipse Name="led1" Location="12.63158, 6" Size="18.94737, 18" DrawAction="Fill">
<Fill>
<pds:SolidFill Color="50, 205, 50" />
</Fill>
</Ellipse>
<Ellipse Name="led2" Location="37.89474, 6" Size="18.94737, 18" DrawAction="Fill">
<Fill>
<pds:SolidFill Color="50, 205, 50" />
</Fill>
</Ellipse>
<Ellipse Name="led3" Location="63.1579, 6" Size="18.94737, 18" DrawAction="Fill">
<Fill>
<pds:SolidFill Color="50, 205, 50" />
</Fill>
</Ellipse>
<Ellipse Name="led4" Location="88.42103, 6" Size="18.94737, 18" DrawAction="Fill">
<Fill>
<pds:SolidFill Color="50, 205, 50" />
</Fill>
</Ellipse>
</Elements>
<Styles>
<pds:Style Name="Bar">
<pds:Fill>
<pds:LinearGradientFill Angle="90" StartColor="128, 128, 255" />
</pds:Fill>
</pds:Style>
</Styles>
</Picture>
</MyXaml>

Update: version 2.2 of VG.net includes a much more beautiful version of the analog vector graphics clock. See this blog entry for more information, or download and run the clock. A screenshot is below:

Analog Vector Graphics Clock Using VG.net

2 Comments

  • Hi Don! Yes, your example was the inspiration for this clock. With all due respect, I think declarative animation is inappropriate for a clock, or any graphical component displaying real-time data.

  • Frank,

    nice blog entry. the vb graphics are very nice and there are some projects in the past where this would have been an awesome implementation (e.g. i did a project where i streamed media to some different headends for some cable providers). Right now, I am most interested in its applicability for windows or web-based business applications...if it makes sense at all. What is your take on this? Or should I just use a more traditional windows and/or web based approach.

    -Mathew Nolton

Comments have been disabled for this content.